From 45302d5a281c557fd6d3166e4dc91b343d9e5b05 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 23 Feb 2023 14:30:17 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/7453 --- app/src/protyle/markdown/flowchartRender.ts | 10 +++++----- app/src/protyle/markdown/mermaidRender.ts | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/protyle/markdown/flowchartRender.ts b/app/src/protyle/markdown/flowchartRender.ts index 762d4c0a0..6d836f6a8 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 772ccfbf9..b8e44754c 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); }