Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX:修复公式中的大于小于号导致导出异常 #831

Open
wants to merge 3 commits into
base: feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion simple-mind-map/src/plugins/Export.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ class Export {
if (this.mindMap.richText) {
const foreignObjectList = svg.find('foreignObject')
if (foreignObjectList.length > 0) {
foreignObjectList[0].add(SVG(`<style>${resetCss}</style>`))
foreignObjectList[0].add(
SVG(`<style>${resetCss}</style>`),
SVG(
'<style>.katex-html[aria-hidden=true]{display:none !important;}</style>'
)
)
for (const v of document.getElementsByTagName('style')) {
foreignObjectList[0].add(SVG(v.outerHTML))
}
svgIsChange = true
}
// 如果还开启了数学公式,还要插入katex库的样式
Expand Down
11 changes: 5 additions & 6 deletions simple-mind-map/src/plugins/Formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ 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',
value.replace(/</g, '&lt;').replace(/>/g, '&gt;')
)
}
return node
}
Expand Down Expand Up @@ -110,11 +113,7 @@ class Formula {
for (const el of els)
nodeText = nodeText.replace(
el.outerHTML,
`\$${el
.getAttribute('data-value')
.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')}\$`
`$${el.getAttribute('data-value')}$`
)
}
return nodeText
Expand Down