From afd1ea9dc275abd3d8e7aab8cb8b884ac85f6d04 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 2 Jan 2024 23:24:05 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/10054 --- app/src/protyle/render/av/asset.ts | 4 ++++ app/src/protyle/render/av/select.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.ts index d9a9eddf5..26cb69c20 100644 --- a/app/src/protyle/render/av/asset.ts +++ b/app/src/protyle/render/av/asset.ts @@ -103,6 +103,7 @@ export const updateAssetCell = (options: { const colId = options.cellElements[0].dataset.colId; const cellDoOperations: IOperation[] = []; const cellUndoOperations: IOperation[] = []; + let mAssetValue: IAVCellAssetValue[] options.cellElements.forEach((item, elementIndex) => { if (!options.blockElement.contains(item)) { const rowElement = hasClosestByClassName(item, "av__row"); @@ -151,6 +152,9 @@ export const updateAssetCell = (options: { } else { cellValue.mAsset = options.replaceValue; } + mAssetValue = cellValue.mAsset + } else { + cellValue.mAsset = mAssetValue } cellDoOperations.push({ action: "updateAttrViewCell", diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts index fc8528808..e77ea632f 100644 --- a/app/src/protyle/render/av/select.ts +++ b/app/src/protyle/render/av/select.ts @@ -54,6 +54,7 @@ export const removeCellOption = (protyle: IProtyle, data: IAV, cellElements: HTM const colId = cellElements[0].dataset.colId; const doOperations: IOperation[] = []; const undoOperations: IOperation[] = []; + let mSelectValue: IAVCellSelectValue[]; cellElements.forEach((item, elementIndex) => { if (!blockElement.contains(item)) { item = cellElements[elementIndex] = blockElement.querySelector(`.av__cell[data-id="${item.dataset.id}"]`) as HTMLElement; @@ -62,14 +63,16 @@ export const removeCellOption = (protyle: IProtyle, data: IAV, cellElements: HTM const cellValue = genCellValueByElement(getTypeByCellElement(item) || item.dataset.type as TAVCol, item); const oldValue = JSON.parse(JSON.stringify(cellValue)); if (elementIndex === 0) { - cellValue.mSelect?.find((item: { content: string }, index: number) => { + cellValue.mSelect?.find((item, index) => { if (item.content === target.dataset.content) { cellValue.mSelect.splice(index, 1); return true; } }); + mSelectValue = cellValue.mSelect; + } else { + cellValue.mSelect = mSelectValue; } - doOperations.push({ action: "updateAttrViewCell", id: cellValue.id, @@ -455,6 +458,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H const cellDoOperations: IOperation[] = []; const cellUndoOperations: IOperation[] = []; + let mSelectValue: IAVCellSelectValue[]; cellElements.forEach((item, index) => { const itemRowElement = hasClosestByClassName(item, "av__row"); if (!itemRowElement) { @@ -483,6 +487,9 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H content: currentElement.dataset.name }]; } + mSelectValue = cellValue.mSelect; + } else { + cellValue.mSelect = mSelectValue; } const rowID = itemRowElement.dataset.id; cellDoOperations.push({