Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/7453

Vanessa45302d5a281c
diff --git a/app/src/protyle/markdown/flowchartRender.ts b/app/src/protyle/markdown/flowchartRender.ts
index 762d4c0a05..6d836f6a8d 100644
--- a/app/src/protyle/markdown/flowchartRender.ts
+++ b/app/src/protyle/markdown/flowchartRender.ts
@@ -1,6 +1,6 @@
import {addScript} from "../util/addScript";
import {Constants} from "../../constants";
-import {hasClosestByClassName} from "../util/hasClosest";
+import {hasClosestByAttribute} from "../util/hasClosest";
declare const flowchart: {
parse(text: string): { drawSVG: (type: Element) => void };
@@ -19,22 +19,22 @@ export const flowchartRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
}
addScript(`${cdn}/js/flowchart.js/flowchart.min.js?v=0.0.0`, "protyleFlowchartScript").then(() => {
if (flowchartElements[0].firstElementChild.clientWidth === 0) {
- const tabElement = hasClosestByClassName(flowchartElements[0], "protyle", true);
- if (!tabElement) {
+ const hideElement = hasClosestByAttribute(flowchartElements[0], "fold", "1");
+ if (!hideElement) {
return;
}
const observer = new MutationObserver(() => {
initFlowchart(flowchartElements);
observer.disconnect();
});
- observer.observe(tabElement, {attributeFilter: ["class"]});
+ observer.observe(hideElement, {attributeFilter: ["fold"]});
} else {
initFlowchart(flowchartElements);
}
});
};
-const initFlowchart = (flowchartElements:Element[]) => {
+const initFlowchart = (flowchartElements: Element[]) => {
flowchartElements.forEach((item: HTMLElement) => {
if (item.getAttribute("data-render") === "true") {
return;
diff --git a/app/src/protyle/markdown/mermaidRender.ts b/app/src/protyle/markdown/mermaidRender.ts
index 772ccfbf91..b8e44754c3 100644
--- a/app/src/protyle/markdown/mermaidRender.ts
+++ b/app/src/protyle/markdown/mermaidRender.ts
@@ -1,6 +1,6 @@
import {addScript} from "../util/addScript";
import {Constants} from "../../constants";
-import {hasClosestByClassName} from "../util/hasClosest";
+import {hasClosestByAttribute} from "../util/hasClosest";
declare const mermaid: {
initialize(options: any): void,
@@ -45,15 +45,15 @@ export const mermaidRender = (element: Element, cdn = Constants.PROTYLE_CDN) =>
}
mermaid.initialize(config);
if (mermaidElements[0].firstElementChild.clientWidth === 0) {
- const tabElement = hasClosestByClassName(mermaidElements[0], "protyle", true);
- if (!tabElement) {
+ const hideElement = hasClosestByAttribute(mermaidElements[0], "fold", "1");
+ if (!hideElement) {
return;
}
const observer = new MutationObserver(() => {
initMermaid(mermaidElements);
observer.disconnect();
});
- observer.observe(tabElement, {attributeFilter: ["class"]});
+ observer.observe(hideElement, {attributeFilter: ["fold"]});
} else {
initMermaid(mermaidElements);
}