Feat:如果开启了公式插件并且存在公式,那么导出svg时需要传入katex库的样式

This commit is contained in:
街角小林 2024-07-18 10:05:48 +08:00
parent 6382e8acd8
commit 5192753816

View File

@ -4,7 +4,8 @@ import {
readBlob,
removeHTMLEntities,
resizeImgSize,
handleSelfCloseTags
handleSelfCloseTags,
addXmlns
} from '../utils'
import { SVG } from '@svgdotjs/svg.js'
import drawBackgroundImageToCanvas from '../utils/simulateCSSBackgroundInCanvas'
@ -95,6 +96,20 @@ class Export {
foreignObjectList[0].add(SVG(`<style>${resetCss}</style>`))
svgIsChange = true
}
// 如果还开启了数学公式还要插入katex库的样式
if (this.mindMap.formula) {
const formulaList = svg.find('.ql-formula')
if (formulaList.length > 0) {
const styleText = this.mindMap.formula.getStyleText()
if (styleText) {
const styleEl = document.createElement('style')
styleEl.innerHTML = styleText
addXmlns(styleEl)
foreignObjectList[0].add(styleEl)
svgIsChange = true
}
}
}
}
// 自定义处理svg的方法
if (typeof handleBeingExportSvg === 'function') {