blob: bb25f2d30b1fe9ac9a189634efd704239a3a488e (
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
|
'use client';
import { useEffect, useRef } from 'react';
import mermaid from 'mermaid';
mermaid.initialize({
startOnLoad: false,
theme: 'default',
});
export function Mermaid({ chart }: { chart: string }) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
mermaid.run({
nodes: [ref.current],
});
}
}, [chart]);
return (
<div className="not-prose my-6">
<div ref={ref} className="mermaid">
{chart}
</div>
</div>
);
}
|