refac/fix: mermaid

This commit is contained in:
Timothy Jaeryang Baek
2025-10-21 17:03:04 -04:00
parent 0a78ceef6d
commit 9942de8011
2 changed files with 20 additions and 3 deletions
+5 -1
View File
@@ -1593,13 +1593,17 @@ export const decodeString = (str: string) => {
}
};
export const renderMermaidDiagram = async (code: string) => {
export const initMermaid = async () => {
const { default: mermaid } = await import('mermaid');
mermaid.initialize({
startOnLoad: false, // Should be false when using render API
theme: document.documentElement.classList.contains('dark') ? 'dark' : 'default',
securityLevel: 'loose'
});
return mermaid;
};
export const renderMermaidDiagram = async (mermaid, code: string) => {
const parseResult = await mermaid.parse(code, { suppressErrors: false });
if (parseResult) {
const { svg } = await mermaid.render(`mermaid-${uuidv4()}`, code);