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: https://github.com/siyuan-note/siyuan/pull/17651
Vanessaa809dcaab17d
diff --git a/app/src/protyle/util/blockFold.ts b/app/src/protyle/util/blockFold.tsindex e7b8382880..15df8f6239 100644--- a/app/src/protyle/util/blockFold.ts+++ b/app/src/protyle/util/blockFold.ts@@ -94,25 +94,24 @@ export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: booleareturn {fold: !hasFold ? 1 : 0, undoOperations, doOperations};};-export const foldBlocksRecursively = (protyle: IProtyle, nodeElements: Element[]) => {- const doOperations: IOperation[] = [];- const undoOperations: IOperation[] = [];+const isFoldable = (el: Element) => {+ const type = el.getAttribute("data-type");+ return type === "NodeHeading" ||+ (type === "NodeCallout" && el.querySelector(".callout-content").childElementCount > 1) ||+ ((type === "NodeListItem" || type === "NodeBlockquote" || type === "NodeSuperBlock") && el.childElementCount > 3);+};+export const foldBlocksRecursively = (protyle: IProtyle, nodeElements: Element[]) => {const result: Set<Element> = new Set();- const isFoldable = (el: Element) => {- const type = el.getAttribute("data-type");- return type === "NodeHeading" ||- ((type === "NodeListItem" || type === "NodeBlockquote" || type === "NodeSuperBlock") && el.childElementCount > 3);- };-nodeElements.forEach(element => {if (isFoldable(element)) {result.add(element);}- element.querySelectorAll("[data-type='NodeHeading'], [data-type='NodeListItem'], [data-type='NodeBlockquote'], [data-type='NodeSuperBlock']").forEach(child => {+ element.querySelectorAll("[data-type='NodeHeading'], .li, .bq, .sb, .callout").forEach(child => {if (isFoldable(child)) {// Skip headings inside list items to avoid "double dot" and gutter icon conflicts- if (child.getAttribute("data-type") === "NodeHeading" && child.parentElement?.getAttribute("data-type") === "NodeListItem") {+ if (child.getAttribute("data-type") === "NodeHeading" &&+ child.parentElement?.getAttribute("data-type") === "NodeListItem") {return;}result.add(child);@@ -128,10 +127,11 @@ export const foldBlocksRecursively = (protyle: IProtyle, nodeElements: Element[]if (isFoldable(nextElement)) {result.add(nextElement);}- nextElement.querySelectorAll("[data-type='NodeHeading'], [data-type='NodeListItem'], [data-type='NodeBlockquote'], [data-type='NodeSuperBlock']").forEach(child => {+ nextElement.querySelectorAll("[data-type='NodeHeading'], .li, .bq, .sb, .callout").forEach(child => {if (isFoldable(child)) {// Skip headings inside list items to avoid "double dot" and gutter icon conflicts- if (child.getAttribute("data-type") === "NodeHeading" && child.parentElement?.getAttribute("data-type") === "NodeListItem") {+ if (child.getAttribute("data-type") === "NodeHeading" &&+ child.parentElement?.getAttribute("data-type") === "NodeListItem") {return;}result.add(child);@@ -162,12 +162,11 @@ export const foldBlocksRecursively = (protyle: IProtyle, nodeElements: Element[]return 0;});+ const doOperations: IOperation[] = [];+ const undoOperations: IOperation[] = [];elementsToFold.forEach(element => {const hasFold = element.getAttribute("fold") === "1";- if (isFoldAll && hasFold) {- return;- }- if (!isFoldAll && !hasFold) {+ if ((isFoldAll && hasFold) || (!isFoldAll && !hasFold)) {return;}const ops = setFold(protyle, element, !isFoldAll, false, false, true);@@ -180,7 +179,7 @@ export const foldBlocksRecursively = (protyle: IProtyle, nodeElements: Element[]if (doOperations.length > 0) {transaction(protyle, doOperations, undoOperations);preventScroll(protyle);- scrollCenter(protyle, isFoldAll ? elementsToFold[elementsToFold.length - 1] : elementsToFold[0]);+ scrollCenter(protyle, elementsToFold[0]);}};