An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/11829
Vanessaa1fa1d16bb6e
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 77a1761347..bad0afb1f7 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -707,7 +707,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {if (inlineTypes.includes("code") || inlineTypes.includes("kbd")) {window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.copy,- icon:"iconCopy",+ icon: "iconCopy",click() {writeText(protyle.lute.BlockDOM2StdMd(inlineElement.outerHTML));}@@ -2078,7 +2078,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:return {menus, removeMenus, insertMenus, otherMenus, other2Menus};};-export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolean, isRemove?: boolean) => {+export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolean, isRemove?: boolean, addLoading = true) => {if (nodeElement.getAttribute("data-type") === "NodeListItem" && nodeElement.childElementCount < 4) {// 没有子列表或多个块的列表项不进行折叠return -1;@@ -2124,7 +2124,9 @@ export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: booleaconst id = nodeElement.getAttribute("data-node-id");if (nodeElement.getAttribute("data-type") === "NodeHeading") {if (hasFold) {- nodeElement.insertAdjacentHTML("beforeend", '<div spin="1" style="text-align: center"><img width="24px" height="24px" src="/stage/loading-pure.svg"></div>');+ if (addLoading) {+ nodeElement.insertAdjacentHTML("beforeend", '<div spin="1" style="text-align: center"><img width="24px" height="24px" src="/stage/loading-pure.svg"></div>');+ }transaction(protyle, [{action: "unfoldHeading",id,diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.tsindex 44a98f4e80..29947a70ef 100644--- a/app/src/protyle/wysiwyg/input.ts+++ b/app/src/protyle/wysiwyg/input.ts@@ -13,6 +13,7 @@ import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";import {fetchPost, fetchSyncPost} from "../../util/fetch";import {headingTurnIntoList, turnIntoTaskList} from "./turnIntoList";import {updateAVName} from "../render/av/action";+import {setFold} from "../../menus/protyle";export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: Range, needRender = true, event?: InputEvent) => {if (!blockElement.parentElement) {@@ -155,6 +156,12 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:) {log("SpinBlockDOM", blockElement.outerHTML, "argument", protyle.options.debugger);log("SpinBlockDOM", html, "result", protyle.options.debugger);+ if (blockElement.getAttribute("data-type") === "NodeHeading" && blockElement.getAttribute("fold") === "1" &&+ tempElement.content.firstElementChild.getAttribute("data-subtype") !== blockElement.dataset.subtype) {+ setFold(protyle, blockElement, undefined, undefined, false);+ html = html.replace(' fold="1"', "");+ protyle.wysiwyg.lastHTMLs[id] = blockElement.outerHTML;+ }let scrollLeft: number;if (blockElement.classList.contains("table")) {scrollLeft = blockElement.firstElementChild.scrollLeft;diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 6fb852684b..955c27952d 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -883,7 +883,7 @@ export const turnsIntoTransaction = (options: {selectsElement.forEach((item, index) => {if ((options.type === "Blocks2Ps" || options.type === "Blocks2Hs") &&item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {- setFold(options.protyle, item);+ setFold(options.protyle, item, undefined, undefined, false);}item.classList.remove("protyle-wysiwyg--select");item.removeAttribute("select-start");@@ -1105,18 +1105,20 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoOprotyle.model.headElement.classList.remove("item--unupdate");}protyle.updated = true;-if (needDebounce) {protyle.undo.replace(doOperations, protyle);} else {protyle.undo.add(doOperations, undoOperations, protyle);}}+ window.clearTimeout(transactionsTimeout);// 加速折叠 https://github.com/siyuan-note/siyuan/issues/11828if (doOperations.length === 1 && (doOperations[0].action === "unfoldHeading" ||(doOperations[0].action === "setAttrs" && doOperations[0].data.startsWith('{"fold":')))) {+ // 防止 needDebounce 为 true+ protyle.transactionTime = time + Constants.TIMEOUT_INPUT * 2;fetchPost("/api/transactions", {session: protyle.id,app: Constants.SIYUAN_APPID,@@ -1157,7 +1159,6 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO});}protyle.transactionTime = time;- window.clearTimeout(transactionsTimeout);transactionsTimeout = window.setTimeout(() => {promiseTransaction();}, Constants.TIMEOUT_INPUT * 2);