Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13223

Vanessaeca2678012a9
diff --git a/app/src/protyle/render/chartRender.ts b/app/src/protyle/render/chartRender.ts
index 1243d205a2..3f0250c76c 100644
--- a/app/src/protyle/render/chartRender.ts
+++ b/app/src/protyle/render/chartRender.ts
@@ -18,19 +18,11 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
if (echartsElements.length > 0) {
addScript(`${cdn}/js/echarts/echarts.min.js?v=5.3.2`, "protyleEchartsScript").then(() => {
addScript(`${cdn}/js/echarts/echarts-gl.min.js?v=2.0.9`, "protyleEchartsGLScript").then(() => {
+ const wysiswgElement = hasClosestByClassName(element, "protyle-wysiwyg", true);
let width: number = undefined;
- if (echartsElements[0].firstElementChild.clientWidth === 0) {
- const tabElement = hasClosestByClassName(echartsElements[0], "layout-tab-container", true);
- if (tabElement) {
- Array.from(tabElement.children).find(item => {
- if (item.classList.contains("protyle") && !item.classList.contains("fn__none")) {
- width = item.querySelector(".protyle-wysiwyg").firstElementChild.clientWidth;
- return true;
- }
- });
- }
+ if (wysiswgElement && wysiswgElement.clientWidth > 0 && echartsElements[0].firstElementChild.clientWidth === 0 && wysiswgElement.firstElementChild) {
+ width = wysiswgElement.firstElementChild.clientWidth;
}
- const wysiswgElement = hasClosestByClassName(element, "protyle-wysiwyg", true);
echartsElements.forEach(async (e: HTMLDivElement) => {
if (e.getAttribute("data-render") === "true") {
return;
diff --git a/app/src/protyle/render/flowchartRender.ts b/app/src/protyle/render/flowchartRender.ts
index 7415723c42..40b2ebad02 100644
--- a/app/src/protyle/render/flowchartRender.ts
+++ b/app/src/protyle/render/flowchartRender.ts
@@ -20,15 +20,19 @@ 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 hideElement = hasClosestByAttribute(flowchartElements[0], "fold", "1");
- if (!hideElement) {
- return;
- }
const observer = new MutationObserver(() => {
initFlowchart(flowchartElements);
observer.disconnect();
});
- observer.observe(hideElement, {attributeFilter: ["fold"]});
+ const hideElement = hasClosestByAttribute(flowchartElements[0], "fold", "1");
+ if (hideElement) {
+ observer.observe(hideElement, {attributeFilter: ["fold"]});
+ } else {
+ const cardElement = hasClosestByClassName(flowchartElements[0], "card__block", true);
+ if (cardElement) {
+ observer.observe(cardElement, {attributeFilter: ["class"]});
+ }
+ }
} else {
initFlowchart(flowchartElements);
}
diff --git a/app/src/protyle/render/mermaidRender.ts b/app/src/protyle/render/mermaidRender.ts
index 753d8bbccd..f68353801b 100644
--- a/app/src/protyle/render/mermaidRender.ts
+++ b/app/src/protyle/render/mermaidRender.ts
@@ -41,15 +41,19 @@ export const mermaidRender = (element: Element, cdn = Constants.PROTYLE_CDN) =>
}
window.mermaid.initialize(config);
if (mermaidElements[0].firstElementChild.clientWidth === 0) {
- const hideElement = hasClosestByAttribute(mermaidElements[0], "fold", "1");
- if (!hideElement) {
- return;
- }
const observer = new MutationObserver(() => {
initMermaid(mermaidElements);
observer.disconnect();
});
- observer.observe(hideElement, {attributeFilter: ["fold"]});
+ const hideElement = hasClosestByAttribute(mermaidElements[0], "fold", "1");
+ if (hideElement) {
+ observer.observe(hideElement, {attributeFilter: ["fold"]});
+ } else {
+ const cardElement = hasClosestByClassName(mermaidElements[0], "card__block", true);
+ if (cardElement) {
+ observer.observe(cardElement, {attributeFilter: ["class"]});
+ }
+ }
} else {
initMermaid(mermaidElements);
}
diff --git a/app/src/protyle/render/mindmapRender.ts b/app/src/protyle/render/mindmapRender.ts
index 0934138b61..ada453bbf1 100644
--- a/app/src/protyle/render/mindmapRender.ts
+++ b/app/src/protyle/render/mindmapRender.ts
@@ -15,19 +15,11 @@ export const mindmapRender = (element: Element, cdn = Constants.PROTYLE_CDN) =>
return;
}
addScript(`${cdn}/js/echarts/echarts.min.js?v=0.0.0`, "protyleEchartsScript").then(() => {
+ const wysiswgElement = hasClosestByClassName(element, "protyle-wysiwyg", true);
let width: number = undefined;
- if (mindmapElements[0].firstElementChild.clientWidth === 0) {
- const tabElement = hasClosestByClassName(mindmapElements[0], "layout-tab-container", true);
- if (tabElement) {
- Array.from(tabElement.children).find(item => {
- if (item.classList.contains("protyle") && !item.classList.contains("fn__none") && item.querySelector(".protyle-wysiwyg").firstElementChild) {
- width = item.querySelector(".protyle-wysiwyg").firstElementChild.clientWidth;
- return true;
- }
- });
- }
+ if (wysiswgElement && wysiswgElement.clientWidth > 0 && mindmapElements[0].firstElementChild.clientWidth === 0 && wysiswgElement.firstElementChild) {
+ width = wysiswgElement.firstElementChild.clientWidth;
}
- const wysiswgElement = hasClosestByClassName(element, "protyle-wysiwyg", true);
mindmapElements.forEach((e: HTMLDivElement) => {
if (e.getAttribute("data-render") === "true") {
return;