Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: 数据库删除行后 Ctrl+z

Vanessab3bc14d9e0a9
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 89b320728d..fce18dbd39 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 0491862739..1500c14aa4 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,