refac/fix: mermaid
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user