Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7633,6 +7633,7 @@ import mermaid from "mermaid";
var mermaidInit = () => {
mermaid.initialize({
theme: "base",
flowchart: { htmlLabels: false },
themeVariables: {
primaryColor: "#FFFFFF",
primaryTextColor: "#142032",
Expand Down Expand Up @@ -8006,10 +8007,9 @@ var MermaidDiagram = ({ node, ...props }) => {
setHeight(ref.current?.clientWidth / 2);
});
const mermaidRenderer = async function() {
const { svg } = await mermaid2.render("mermaid-id", props.children);
setDiagram(
svg.replace('id="mermaid-id"', "").replaceAll("#mermaid-id", "")
);
const id = `mermaid-${crypto.randomUUID()}`;
const { svg } = await mermaid2.render(id, props.children);
setDiagram(svg);
};
mermaidRenderer();
if (ref.current)
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/lib/markdown-renderer/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,13 @@ const MermaidDiagram = ({ node, ...props }: Component) => {
setWidth(ref.current?.clientWidth ?? 0)
setHeight(ref.current?.clientWidth / 2 ?? 0)
})

const mermaidRenderer = async function () {
const { svg } = await mermaid.render('mermaid-id', props.children)
setDiagram(
svg.replace('id="mermaid-id"', '').replaceAll('#mermaid-id', '')
)
const id = `mermaid-${crypto.randomUUID()}`
const { svg } = await mermaid.render(id, props.children)
setDiagram(svg)
}

mermaidRenderer()
if (ref.current) resizeObserver.observe(ref.current)
}, [])
Expand Down
1 change: 1 addition & 0 deletions src/utils/mermaidInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mermaid from 'mermaid'
const mermaidInit = () => {
mermaid.initialize({
theme: 'base',
flowchart: { htmlLabels: false },
themeVariables: {
primaryColor: '#FFFFFF',
primaryTextColor: '#142032',
Expand Down
Loading