diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index 1f719d8f..626f73c7 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -1,4 +1,4 @@ -import { imgToDataUrl, downloadFile, readBlob } from '../utils' +import { imgToDataUrl, downloadFile, readBlob, removeHTMLEntities } from '../utils' import { SVG } from '@svgdotjs/svg.js' import drawBackgroundImageToCanvas from '../utils/simulateCSSBackgroundInCanvas' import { transformToMarkdown } from '../parse/toMarkdown' @@ -154,6 +154,7 @@ class Export { */ async png(name, transparent = false) { let { node, str } = await this.getSvgData() + str = removeHTMLEntities(str) // 如果开启了富文本,则使用htmltocanvas转换为图片 if (this.mindMap.richText) { let res = await this.mindMap.richText.handleExportPng(node.node) @@ -207,6 +208,7 @@ class Export { node.first().before(SVG(`${name}`)) await this.drawBackgroundToSvg(node) let str = node.svg() + str = removeHTMLEntities(str) // 转换成blob数据 let blob = new Blob([str], { type: 'image/svg+xml' diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 99470427..f28d757e 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -453,3 +453,11 @@ export const loadImage = imgFile => { } }) } + +// 移除字符串中的html实体 +export const removeHTMLEntities = (str) => { + [[' ', ' ']].forEach((item) => { + str = str.replaceAll(item[0], item[1]) + }) + return str +} \ No newline at end of file