From 030fa52c73ccf3d5136bd4f52b41409e2b3b1fd9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 22 Oct 2025 17:28:00 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16113 --- app/src/protyle/hint/index.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 707ca04f0..30603097c 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -805,16 +805,13 @@ ${genHintItemHTML(item)} if (value === "
") { newHTML = `
${genIconHTML()}
${Constants.ZWSP}
`; } - const doOperations: IOperation[] = []; - const undoOperations: IOperation[] = []; + const oldHTML = nodeElement.outerHTML; + let foldData; if (nodeElement.getAttribute("data-type") === "NodeHeading" && nodeElement.getAttribute("fold") === "1") { - const foldData = setFold(protyle, nodeElement, true, false, false, true); - doOperations.push(...foldData.doOperations); - undoOperations.push(...foldData.undoOperations); + foldData = setFold(protyle, nodeElement, true, false, false, true); } nodeElement.insertAdjacentHTML("afterend", newHTML); - const oldHTML = nodeElement.outerHTML; const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22); nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`); // https://github.com/siyuan-note/siyuan/issues/6864 @@ -823,7 +820,7 @@ ${genHintItemHTML(item)} item.style.minWidth = "60px"; }); } - doOperations.push({ + const doOperations: IOperation[] = [{ data: oldHTML, id, action: "update" @@ -832,15 +829,19 @@ ${genHintItemHTML(item)} id: newId, previousID: id, action: "insert" - }); - undoOperations.push({ + }]; + const undoOperations: IOperation[] = [{ id: newId, action: "delete" }, { data: html, id, action: "update" - }); + }]; + if (foldData) { + doOperations.push(...foldData.doOperations); + undoOperations.push(...foldData.undoOperations); + } transaction(protyle, doOperations, undoOperations); } if (value === "
" || value === "$$" || (value.indexOf("```") > -1 && (value.length > 3 || nodeElement.classList.contains("render-node")))) {