Skip to content

Commit c163188

Browse files
authored
💎 feat: remove verify mermaid (#46)
1 parent 6904a23 commit c163188

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/MarkdownPreview/plugins/mermaid.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ export const mermaidPlugin = (md, options = {}) => {
7878
if (cache.has(hash)) {
7979
svg = cache.get(hash)
8080
} else {
81-
const { isValid } = await verifyMermaid(content)
81+
// const { isValid } = await verifyMermaid(content)
8282

83-
if (!isValid) {
84-
return
85-
}
83+
// if (!isValid) {
84+
// return
85+
// }
8686

8787
// 使用唯一 ID 渲染(避免图表冲突)
8888
const { svg: renderedSvg } = await mermaid.render(`mermaid-${ hash }`, content)
@@ -120,22 +120,24 @@ export const mermaidPlugin = (md, options = {}) => {
120120
if (container.dataset.mermaidStatus !== 'pending') {
121121
container.dataset.mermaidStatus = 'pending'
122122
}
123-
renderMermaid(container)
123+
nextTick(() => {
124+
renderMermaid(container)
125+
})
124126
})
125127
}
126128

127129
// 初始化 Mermaid
128130
mermaid.initialize({
129131
startOnLoad: false,
130-
securityLevel: 'antiscript',
132+
securityLevel: 'loose',
131133
markdownAutoWrap: true,
132134
suppressErrorRendering: true,
133135
...options
134136
})
135137

136138
// 触发 Mermaid 图表渲染 export
137139
processMermaid.fn = () => {
138-
requestAnimationFrame(processContainers)
140+
processContainers()
139141
}
140142
}
141143

0 commit comments

Comments
 (0)