fix: mermaid图渲染有问题 #310
This commit is contained in:
parent
bac3bad8db
commit
68fa2bad15
@ -36,7 +36,7 @@ export const SyntaxHighlighterProvider: React.FC<PropsWithChildren> = ({ 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()
|
||||
|
||||
@ -26,6 +26,15 @@ const runtimeSlice = createSlice({
|
||||
},
|
||||
setGenerating: (state, action: PayloadAction<boolean>) => {
|
||||
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<boolean>) => {
|
||||
state.minappShow = action.payload
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user