mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Fix:修复节点前后自定义内容导出图片时显示空白的问题
This commit is contained in:
parent
b8a23beba4
commit
79755e80b9
@ -11,7 +11,8 @@ import { CONSTANTS } from '../../../constants/constant'
|
||||
import {
|
||||
copyNodeTree,
|
||||
createForeignObjectNode,
|
||||
createUid
|
||||
createUid,
|
||||
addXmlns
|
||||
} from '../../../utils/index'
|
||||
|
||||
// 节点类
|
||||
@ -204,10 +205,7 @@ class Node {
|
||||
}
|
||||
// 如果没有返回内容,那么还是使用内置的节点内容
|
||||
if (this._customNodeContent) {
|
||||
this._customNodeContent.setAttribute(
|
||||
'xmlns',
|
||||
'http://www.w3.org/1999/xhtml'
|
||||
)
|
||||
addXmlns(this._customNodeContent)
|
||||
return
|
||||
}
|
||||
this._imgData = this.createImgNode()
|
||||
@ -220,9 +218,15 @@ class Node {
|
||||
this._prefixData = createNodePrefixContent
|
||||
? createNodePrefixContent(this)
|
||||
: null
|
||||
if (this._prefixData && this._prefixData.el) {
|
||||
addXmlns(this._prefixData.el)
|
||||
}
|
||||
this._postfixData = createNodePostfixContent
|
||||
? createNodePostfixContent(this)
|
||||
: null
|
||||
if (this._postfixData && this._postfixData.el) {
|
||||
addXmlns(this._postfixData.el)
|
||||
}
|
||||
}
|
||||
|
||||
// 计算节点的宽高
|
||||
|
||||
@ -5,7 +5,8 @@ import {
|
||||
addHtmlStyle,
|
||||
checkIsRichText,
|
||||
isUndef,
|
||||
createForeignObjectNode
|
||||
createForeignObjectNode,
|
||||
addXmlns
|
||||
} from '../../../utils'
|
||||
import { Image as SVGImage, SVG, A, G, Rect, Text } from '@svgdotjs/svg.js'
|
||||
import iconsSvg from '../../../svg/icons'
|
||||
@ -157,7 +158,7 @@ function createRichTextNode() {
|
||||
div.innerHTML = html
|
||||
let el = div.children[0]
|
||||
el.classList.add('smm-richtext-node-wrap')
|
||||
el.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml')
|
||||
addXmlns(el)
|
||||
el.style.maxWidth = textAutoWrapWidth + 'px'
|
||||
let { width, height } = el.getBoundingClientRect()
|
||||
// 如果文本为空,那么需要计算一个默认高度
|
||||
|
||||
@ -1335,7 +1335,7 @@ export const handleGetSvgDataExtraContent = ({
|
||||
if (!res) return
|
||||
const { el, cssText, height } = res
|
||||
if (el instanceof HTMLElement) {
|
||||
el.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml')
|
||||
addXmlns(el)
|
||||
const foreignObject = createForeignObjectNode({ el, height })
|
||||
callback(foreignObject, height)
|
||||
}
|
||||
@ -1525,3 +1525,8 @@ export const defenseXSS = text => {
|
||||
// 返回最终结果
|
||||
return result
|
||||
}
|
||||
|
||||
// 给节点添加命名空间
|
||||
export const addXmlns = el => {
|
||||
el.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user