blob: d408aad5d6417c7dd8b7e72538a7cbb6d1c5b7ae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
"use client";
import mermaid from "mermaid";
import { useEffect, useRef } from "react";
mermaid.initialize({
startOnLoad: false,
theme: "default",
});
export function Mermaid({ chart }: { chart: string }) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
ref.current.innerHTML = chart;
mermaid.run({
nodes: [ref.current],
});
}
}, [chart]);
return (
<div className="not-prose my-6">
<div ref={ref} className="mermaid">
{chart}
</div>
</div>
);
}
|