diff --git a/src/renderer/src/context/SyntaxHighlighterProvider.tsx b/src/renderer/src/context/SyntaxHighlighterProvider.tsx index 11e5cac5..1ad72151 100644 --- a/src/renderer/src/context/SyntaxHighlighterProvider.tsx +++ b/src/renderer/src/context/SyntaxHighlighterProvider.tsx @@ -36,7 +36,7 @@ export const SyntaxHighlighterProvider: React.FC = ({ childre if (!window.mermaid) { await loadScript('https://unpkg.com/mermaid@11.4.0/dist/mermaid.min.js') window.mermaid.initialize({ - startOnLoad: true, + startOnLoad: false, theme: theme === ThemeMode.dark ? 'dark' : 'default' }) window.mermaid.contentLoaded() diff --git a/src/renderer/src/store/runtime.ts b/src/renderer/src/store/runtime.ts index 06eb72d3..df7a19f0 100644 --- a/src/renderer/src/store/runtime.ts +++ b/src/renderer/src/store/runtime.ts @@ -26,6 +26,15 @@ const runtimeSlice = createSlice({ }, setGenerating: (state, action: PayloadAction) => { state.generating = action.payload + if (!state.generating) { + const mermaidElements = document.querySelectorAll('.mermaid') + for (const element of mermaidElements) { + if (!element.querySelector('svg')) { + element.removeAttribute('data-processed') + } + } + setTimeout(() => window.mermaid.contentLoaded(), 100) + } }, setMinappShow: (state, action: PayloadAction) => { state.minappShow = action.payload