diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 89b320728..fce18dbd3 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -262,21 +262,26 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi icon: "iconTrashcan", label: window.siyuan.languages.delete, click() { - const previousElement = rowElements[0].previousElementSibling as HTMLElement; + const avID = blockElement.getAttribute("data-av-id") + const undoOperations: IOperation[] = []; + rowElements.forEach(item => { + undoOperations.push({ + action: "insertAttrViewBlock", + avID, + previousID: item.previousElementSibling?.getAttribute("data-id") || "", + srcIDs: [item.getAttribute("data-id")], + isDetached: item.querySelector('.av__cell[data-detached="true"]') ? true : false, + }) + }) transaction(protyle, [{ action: "removeAttrViewBlock", srcIDs: blockIds, - avID: blockElement.getAttribute("data-av-id"), - }], [{ - action: "insertAttrViewBlock", - avID: blockElement.getAttribute("data-av-id"), - previousID: previousElement?.getAttribute("data-id") || "", - srcIDs: rowIds, - }]); + avID, + }], undoOperations); rowElements.forEach(item => { item.remove(); }); - updateHeader(previousElement); + updateHeader(blockElement.querySelector(".av__row")); } }); if (rowIds.length === 1) { diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 049186273..1500c14aa 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -877,6 +877,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { avID, previousID, srcIDs: sourceIds, + isDetached: false, }], [{ action: "removeAttrViewBlock", srcIDs: sourceIds, @@ -934,6 +935,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { avID, previousID, srcIDs: ids, + isDetached: false, }], [{ action: "removeAttrViewBlock", srcIDs: ids,