From a1f856676ef46d149df1dca01b42aed34c70789a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 2 Sep 2022 19:38:54 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5785 --- app/src/protyle/wysiwyg/transaction.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index a0a86fb4b..70cb70e2b 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -82,6 +82,7 @@ const promiseTransaction = () => { if (!item.lastElementChild.classList.contains("protyle-attr")) { item.lastElementChild.remove(); } + removeUnfoldRepeatBlock(response.data[0].doOperations[0].retData, protyle); item.insertAdjacentHTML("afterend", response.data[0].doOperations[0].retData); if (doOperations[0].data === "remove") { // https://github.com/siyuan-note/siyuan/issues/2188 @@ -216,6 +217,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b const scrollTop = protyle.contentElement.scrollTop; protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => { if (operation.retData) { // undo 的时候没有 retData + removeUnfoldRepeatBlock(operation.retData, protyle); item.insertAdjacentHTML("afterend", operation.retData); } item.removeAttribute("fold"); @@ -559,6 +561,14 @@ export const turnsIntoOneTransaction = (options: { protyle: IProtyle, selectsEle hideElements(["gutter"], options.protyle); }; +const removeUnfoldRepeatBlock = (html:string, protyle:IProtyle) => { + const temp = document.createElement("template") + temp.innerHTML = html + Array.from(temp.content.children).forEach(item => { + protyle.wysiwyg.element.querySelector(`:scope > [data-node-id="${item.getAttribute("data-node-id")}"]`)?.remove() + }) +} + export const turnsIntoTransaction = (options: { protyle: IProtyle, selectsElement?: Element[],