From 692d11ab2abb317db1b44665e7ccb5990b40b27e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 30 Dec 2024 16:47:03 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13662 --- app/src/protyle/wysiwyg/transaction.ts | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 1948b2497..745bf8c7c 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -34,16 +34,25 @@ const removeTopElement = (updateElement: Element, protyle: IProtyle) => { }); } topAloneElement.remove(); - if (protyle.block.rootID === protyle.block.id && protyle.wysiwyg.element.childElementCount === 0) { - const newId = Lute.NewNodeID(); - const newElement = genEmptyElement(false, false, newId); - doOperations.push({ - action: "insert", - data: newElement.outerHTML, - id: newId, - parentID: protyle.block.parentID - }); - protyle.wysiwyg.element.innerHTML = newElement.outerHTML; + if (protyle.wysiwyg.element.childElementCount === 0) { + if (protyle.block.rootID === protyle.block.id) { + const newId = Lute.NewNodeID(); + const newElement = genEmptyElement(false, false, newId); + doOperations.push({ + action: "insert", + data: newElement.outerHTML, + id: newId, + parentID: protyle.block.parentID + }); + protyle.wysiwyg.element.innerHTML = newElement.outerHTML; + } else { + zoomOut({ + protyle, + id: protyle.block.rootID, + isPushBack: false, + focusId: protyle.block.id, + }) + } } if (doOperations.length > 0) { transaction(protyle, doOperations, []);