An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/11312
Vanessad12451e90e0a
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex b827cefb40..bd781c455d 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -1935,7 +1935,7 @@ 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" src="/stage/loading-pure.svg"></div>');+ 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/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 5f1df1c27c..d95b3a3db6 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -45,6 +45,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ranlet listElement: Element;let topParentElement: Element;hideElements(["select"], protyle);+ let foldPreviousId: stringselectElements.find((item: HTMLElement) => {const topElement = getTopAloneElement(item);topParentElement = topElement.parentElement;@@ -74,13 +75,27 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ranif (topElement.getAttribute("data-type") === "NodeHeading" && topElement.getAttribute("fold") === "1") {// https://github.com/siyuan-note/siyuan/issues/2188setFold(protyle, topElement, undefined, true);+ let previousID = topElement.previousElementSibling ? topElement.previousElementSibling.getAttribute("data-node-id") : ""+ if (typeof foldPreviousId !== "undefined") {+ previousID = foldPreviousId;+ }inserts.push({action: "insert",data: topElement.outerHTML,id,- previousID: selectElements[0].previousElementSibling ? selectElements[0].previousElementSibling.getAttribute("data-node-id") : "",+ previousID: previousID,parentID: topElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID});+ // 折叠块和非折叠块同时删除时撤销异常 https://github.com/siyuan-note/siyuan/issues/11312+ let foldPreviousElement = getPreviousBlock(topElement);+ while (foldPreviousElement && foldPreviousElement.childElementCount === 3) {+ foldPreviousElement = getPreviousBlock(foldPreviousElement);+ }+ if (foldPreviousElement) {+ foldPreviousId = foldPreviousElement.getAttribute("data-node-id");+ } else {+ foldPreviousId = "";+ }// https://github.com/siyuan-note/siyuan/issues/4422topElement.firstElementChild.removeAttribute("contenteditable");// 在折叠标题后输入文字,然后全选删除再撤销会重建索引。因此不能删除折叠标题后新输入的输入折叠标题下的内容@@ -97,11 +112,15 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ranif (topElement.classList.contains("render-node") || topElement.querySelector("div.render-node")) {data = protyle.lute.SpinBlockDOM(topElement.outerHTML); // 防止图表撤销问题}+ let previousID = topElement.previousElementSibling ? topElement.previousElementSibling.getAttribute("data-node-id") : "";+ if (typeof foldPreviousId !== "undefined") {+ previousID = foldPreviousId;+ }inserts.push({action: "insert",data,id,- previousID: topElement.previousElementSibling ? topElement.previousElementSibling.getAttribute("data-node-id") : "",+ previousID,parentID: topElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID});if (topElement.getAttribute("data-subtype") === "o" && topElement.classList.contains("li")) {diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex c181951eb5..c6b92520d7 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -297,6 +297,21 @@ const promiseTransaction = () => {updateRef(protyle, operation.id);}});++ // 删除仅有的折叠标题后展开内容为空+ if (protyle.wysiwyg.element.childElementCount === 0) {+ const newID = Lute.NewNodeID();+ const emptyElement = genEmptyElement(false, true, newID);+ protyle.wysiwyg.element.insertAdjacentElement("afterbegin", emptyElement);+ transaction(protyle, [{+ action: "insert",+ data: emptyElement.outerHTML,+ id: newID,+ parentID: protyle.block.parentID+ }]);+ // 不能撤销,否则就无限循环了+ focusByWbr(emptyElement, range);+ }});};