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/12691

Vanessa2735b3269cab
diff --git a/app/src/protyle/preview/diagram.ts b/app/src/protyle/preview/diagram.ts
index 749a41738c..577a362cd3 100644
--- a/app/src/protyle/preview/diagram.ts
+++ b/app/src/protyle/preview/diagram.ts
@@ -2,7 +2,7 @@ import {Constants} from "../../constants";
import {addScript} from "../util/addScript";
import {previewImages} from "./image";
-const DIAGRAM_SUBTYPES = ["mermaid", "graphviz", "flowchart", "plantuml", "echarts"];
+const DIAGRAM_SUBTYPES = ["mermaid", "graphviz", "flowchart", "echarts"];
export const getDiagramBlock = (element: HTMLElement) => {
if (!element) {
@@ -15,29 +15,25 @@ export const getDiagramBlock = (element: HTMLElement) => {
};
/**
- * Open a rendered diagram (mermaid / graphviz / flowchart / plantuml / mindmap) in a
+ * Open a rendered diagram (mermaid / graphviz / flowchart / echarts) in a
* full-screen viewer that supports zoom, pan and rotation. The diagram's SVG is rasterized
* to a PNG via html-to-image (the same library used by the "export as image" action) and
* handed to the existing image viewer so diagrams get the same controls as image previews.
- *
- * https://github.com/siyuan-note/siyuan/issues/12691
*/
export const previewDiagram = (diagramElement: HTMLElement) => {
addScript(`${Constants.PROTYLE_CDN}/js/html-to-image.min.js?v=1.11.13`, "protyleHtml2image").then(async () => {
const type = diagramElement.getAttribute("data-subtype");
- let renderElement = diagramElement.querySelector('[contenteditable="false"] svg');
- if (type === "plantuml") {
- renderElement = diagramElement.querySelector("object");
- } else if (type === "echarts") {
- renderElement = diagramElement.querySelector("canvas");
- }
+ const renderElement = type === "echarts" ?
+ diagramElement.querySelector("canvas") :
+ diagramElement.querySelector('[contenteditable="false"] svg');
+
let blob: Blob;
try {
blob = await window.htmlToImage.toBlob(renderElement, {backgroundColor: "#fff"});
} catch (e) {
return;
}
- const url = URL.createObjectURL(blob);
- previewImages([url], url, () => URL.revokeObjectURL(url));
+ const objectURL = URL.createObjectURL(blob);
+ previewImages([objectURL], objectURL, () => URL.revokeObjectURL(objectURL));
});
};