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/7273
Vanessab43f5112bb55
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 82cfab087a..683617de9b 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -17,6 +17,7 @@ import {preventScroll} from "../scroll/preventScroll";import {restoreScroll} from "../scroll/saveScroll";import {removeLoading} from "../ui/initUI";import {isMobile} from "../../util/functions";+import {foldPassiveType} from "../wysiwyg/renderBacklink";export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[] = [], scrollAttr?: IScrollAttr, renderTitle = false) => {protyle.wysiwyg.element.removeAttribute("data-top");@@ -182,25 +183,7 @@ const setHTML = (options: {protyle.wysiwyg.element.innerHTML = options.content;}if (options.action.includes(Constants.CB_GET_BACKLINK)) {- if (protyle.wysiwyg.element.firstElementChild.classList.contains("li")) {- if (options.expand) {- const thirdLiElement = protyle.wysiwyg.element.querySelector(".li .li .li");- if (thirdLiElement) {- thirdLiElement.setAttribute("fold", "1");- }- } else {- protyle.wysiwyg.element.firstElementChild.setAttribute("fold", "1");- }- } else if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-type") === "NodeHeading") {- Array.from(protyle.wysiwyg.element.children).forEach((item, index) => {- if ((options.expand && index > 2) || (!options.expand && index > 1)) {- if ((options.expand && index === 3) || (!options.expand && index === 2)) {- item.insertAdjacentHTML("beforebegin", '<div style="max-width: 100%;justify-content: center;" contenteditable="false" class="protyle-breadcrumb__item"><svg><use xlink:href="#iconMore"></use></svg></div>');- }- item.classList.add("fn__none");- }- });- }+ foldPassiveType(options.expand, protyle.wysiwyg.element);}processRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);diff --git a/app/src/protyle/wysiwyg/renderBacklink.ts b/app/src/protyle/wysiwyg/renderBacklink.tsindex ae90943acb..b70f73c2aa 100644--- a/app/src/protyle/wysiwyg/renderBacklink.ts+++ b/app/src/protyle/wysiwyg/renderBacklink.ts@@ -27,21 +27,20 @@ export const renderBacklink = (protyle: IProtyle, backlinkData: {}};-const setBacklinkFold = (html: string, expand: boolean) => {- const tempDom = document.createElement("template");- tempDom.innerHTML = html;- if (tempDom.content.firstElementChild.classList.contains("li")) {+// 传递型折叠处理+export const foldPassiveType = (expand: boolean, element: HTMLElement | DocumentFragment) => {+ if (element.firstElementChild.classList.contains("li")) {if (expand) {- tempDom.content.querySelectorAll(".li .li .li").forEach(item => {+ element.querySelectorAll(".li .li .li").forEach(item => {if (item.childElementCount > 3) {item.setAttribute("fold", "1");}});} else {- tempDom.content.firstElementChild.setAttribute("fold", "1");+ element.firstElementChild.setAttribute("fold", "1");}- } else if (tempDom.content.firstElementChild.getAttribute("data-type") === "NodeHeading") {- Array.from(tempDom.content.children).forEach((item, index) => {+ } else if (element.firstElementChild.getAttribute("data-type") === "NodeHeading") {+ Array.from(element.children).forEach((item, index) => {if ((expand && index > 2) || (!expand && index > 1)) {if ((expand && index === 3) || (!expand && index === 2)) {item.insertAdjacentHTML("beforebegin", '<div style="max-width: 100%;justify-content: center;" contenteditable="false" class="protyle-breadcrumb__item"><svg><use xlink:href="#iconMore"></use></svg></div>');@@ -50,6 +49,12 @@ const setBacklinkFold = (html: string, expand: boolean) => {}});}+}++const setBacklinkFold = (html: string, expand: boolean) => {+ const tempDom = document.createElement("template");+ tempDom.innerHTML = html;+ foldPassiveType(expand, tempDom.content);return tempDom.innerHTML;};