Skip to content

Commit 30dbbf1

Browse files
committed
🎨 #15396
1 parent 561d4cc commit 30dbbf1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

app/src/protyle/wysiwyg/transaction.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
757757
const cursorElements = [];
758758
if (operation.previousID) {
759759
const previousElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`);
760-
if (previousElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
760+
if (previousElement.length === 0 && isUndo && protyle.wysiwyg.element.childElementCount === 0) {
761+
// https://github.com/siyuan-note/siyuan/issues/15396 操作后撤销
762+
protyle.wysiwyg.element.innerHTML = operation.data;
763+
} else if (previousElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
761764
// 反链面板删除超级块中的最后一个段落块后撤销
762765
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
763766
if (blockElement) {
@@ -1199,7 +1202,11 @@ export const turnsOneInto = async (options: {
11991202
}
12001203
}
12011204
const oldHTML = options.nodeElement.outerHTML;
1202-
const previousId = options.nodeElement.previousElementSibling?.getAttribute("data-node-id");
1205+
let previousId = options.nodeElement.previousElementSibling?.getAttribute("data-node-id");
1206+
if (!options.nodeElement.previousElementSibling && options.protyle.block.showAll) {
1207+
const response = await fetchSyncPost("/api/block/getBlockRelevantIDs", {id: options.id});
1208+
previousId = response.data.previousID;
1209+
}
12031210
const parentId = options.nodeElement.parentElement.getAttribute("data-node-id") || options.protyle.block.parentID;
12041211
// @ts-ignore
12051212
const newHTML = options.protyle.lute[options.type](options.nodeElement.outerHTML, options.level);

0 commit comments

Comments
 (0)