From b3bc14d9e0a9d872fd995af37a12c732ef3f79cd Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 18 Oct 2023 23:52:20 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=A1=8C=E5=90=8E=20Ctrl+z?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/render/av/action.ts | 23 ++++++++++++++--------- app/src/protyle/util/editorCommonEvent.ts | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) 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,