🐛 数据库删除行后 Ctrl+z

This commit is contained in:
Vanessa 2023-10-18 23:52:20 +08:00
parent cd8d94ae8b
commit b3bc14d9e0
2 changed files with 16 additions and 9 deletions

View file

@ -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) {

View file

@ -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,