Skip to content

Commit

Permalink
fix: Fix mermaid's regression bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
xinkeng0 committed Jan 15, 2024
1 parent 6dae4c4 commit 76690ee
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions console/src/editor/text-diagram/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import TextDiagramView from "./TextDiagramView.vue";
import { markRaw } from "vue";
import icon from "~icons/simple-icons/diagramsdotnet";

export const ExtensionTextDiagram = Node.create({
export type TextDiagramOptions = {
HTMLAttributes: Record<string, any>;
};

export const ExtensionTextDiagram = Node.create<TextDiagramOptions>({
name: "text-diagram",
inline: false,
content: "",
Expand Down Expand Up @@ -62,17 +66,33 @@ export const ExtensionTextDiagram = Node.create({
},
];
},
renderHTML({ HTMLAttributes }) {
return [
"text-diagram",
mergeAttributes(HTMLAttributes),
[
"img",
{
src: HTMLAttributes["data-src"],
},
],
];
renderHTML({ node, HTMLAttributes }) {
switch (node.attrs.type) {
case "plantuml":
return [
"text-diagram",
mergeAttributes(HTMLAttributes),
[
"img",
{
src: HTMLAttributes["data-src"],
},
],
];
case "mermaid":
return [
"text-diagram",
mergeAttributes(HTMLAttributes),
node.attrs.content,
];
default:
// unknown type
return [
"text-diagram",
mergeAttributes(HTMLAttributes),
node.attrs.content,
];
}
},
addNodeView() {
return VueNodeViewRenderer(TextDiagramView);
Expand Down

0 comments on commit 76690ee

Please sign in to comment.