fix: removed theme dependency in syntaxhighlighterprovider, added mermaid delay

This commit is contained in:
kangfenmao 2024-11-09 15:02:38 +08:00
parent 6536ec227a
commit 8a8deda002
2 changed files with 10 additions and 8 deletions

View File

@ -49,7 +49,7 @@ export const SyntaxHighlighterProvider: React.FC<PropsWithChildren> = ({ childre
} }
initHighlighter() initHighlighter()
}, [highlighterTheme, theme]) }, [highlighterTheme])
const codeToHtml = async (code: string, language: string) => { const codeToHtml = async (code: string, language: string) => {
if (!highlighter) return '' if (!highlighter) return ''

View File

@ -23,13 +23,15 @@ export const useMermaid = () => {
}, []) }, [])
useEffect(() => { useEffect(() => {
if (window.mermaid) { setTimeout(() => {
window.mermaid.initialize({ if (window.mermaid) {
startOnLoad: true, window.mermaid.initialize({
theme: theme === ThemeMode.dark ? 'dark' : 'default' startOnLoad: true,
}) theme: theme === ThemeMode.dark ? 'dark' : 'default'
window.mermaid.contentLoaded() })
} window.mermaid.contentLoaded()
}
}, 2000)
}, [theme]) }, [theme])
useEffect(() => { useEffect(() => {