mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Fix:修复公式中存在<>符号时导出svg报错的问题
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import katex from 'katex'
|
||||
import Quill from 'quill'
|
||||
import { getChromeVersion } from '../utils/index'
|
||||
import { getChromeVersion, htmlEscape } from '../utils/index'
|
||||
import { getBaseStyleText, getFontStyleText } from './FormulaStyle'
|
||||
|
||||
// 数学公式支持插件
|
||||
@@ -58,7 +58,7 @@ class Formula {
|
||||
let node = super.create(value)
|
||||
if (typeof value === 'string') {
|
||||
katex.render(value, node, self.config)
|
||||
node.setAttribute('data-value', value)
|
||||
node.setAttribute('data-value', htmlEscape(value))
|
||||
}
|
||||
return node
|
||||
}
|
||||
@@ -110,11 +110,7 @@ class Formula {
|
||||
for (const el of els)
|
||||
nodeText = nodeText.replace(
|
||||
el.outerHTML,
|
||||
`\$${el
|
||||
.getAttribute('data-value')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')}\$`
|
||||
`\$${htmlEscape(el.getAttribute('data-value'))}\$`
|
||||
)
|
||||
}
|
||||
return nodeText
|
||||
|
||||
Reference in New Issue
Block a user