From d0a10e42d7661264ffeb7c2c6979358ee207298b Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 28 Jun 2024 10:43:23 +0800 Subject: [PATCH] :zap: fix https://github.com/siyuan-note/siyuan/issues/11828 --- app/src/protyle/wysiwyg/transaction.ts | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index d98c6ceb0..6fb852684 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -81,21 +81,6 @@ const promiseTransaction = () => { document.getElementById("toolbarSync").classList.remove("fn__none"); } /// #endif - if (response.data[0].doOperations[0].action === "setAttrs") { - const gutterFoldElement = protyle.gutter.element.querySelector('[data-type="fold"]'); - if (gutterFoldElement) { - gutterFoldElement.removeAttribute("disabled"); - } - // 仅在 alt+click 箭头折叠时才会触发 - protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => { - if (item.querySelector(`[data-node-id="${response.data[0].doOperations[0].id}"]`)) { - item.removeAttribute("data-render"); - blockRender(protyle, item); - } - }); - return; - } - let range: Range; if (getSelection().rangeCount > 0) { range = getSelection().getRangeAt(0); @@ -1127,7 +1112,11 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO protyle.undo.add(doOperations, undoOperations, protyle); } } - if (doOperations.length === 1 && doOperations[0].action === "unfoldHeading") { + // 加速折叠 https://github.com/siyuan-note/siyuan/issues/11828 + if (doOperations.length === 1 && ( + doOperations[0].action === "unfoldHeading" || + (doOperations[0].action === "setAttrs" && doOperations[0].data.startsWith('{"fold":')) + )) { fetchPost("/api/transactions", { session: protyle.id, app: Constants.SIYUAN_APPID, @@ -1139,7 +1128,18 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO response.data[0].doOperations.forEach((operation: IOperation) => { if (operation.action === "unfoldHeading" || operation.action === "foldHeading") { processFold(operation, protyle); - return; + } else if (operation.action === "setAttrs") { + const gutterFoldElement = protyle.gutter.element.querySelector('[data-type="fold"]'); + if (gutterFoldElement) { + gutterFoldElement.removeAttribute("disabled"); + } + // 仅在 alt+click 箭头折叠时才会触发 + protyle.wysiwyg.element.querySelectorAll('[data-type="NodeBlockQueryEmbed"]').forEach((item) => { + if (item.querySelector(`[data-node-id="${operation.id}"]`)) { + item.removeAttribute("data-render"); + blockRender(protyle, item); + } + }); } }); })