fix: text 是空的时候会报错

This commit is contained in:
wanghao1993
2023-09-21 23:33:06 +08:00
parent ba44f69f9f
commit e1172c8d0d
2 changed files with 12 additions and 2 deletions

View File

@@ -164,7 +164,10 @@ function createTextNode() {
let lineHeight = this.getStyle('lineHeight', false)
// 文本超长自动换行
let textStyle = this.style.getTextFontStyle()
let textArr = this.nodeData.data.text.split(/\n/gim)
let textArr = []
if (this.nodeData.data.text && typeof this.nodeData.data.text === 'string') {
textArr = this.nodeData.data.text.split(/\n/gim)
}
let maxWidth = this.mindMap.opt.textAutoWrapWidth
let isMultiLine = false
textArr.forEach((item, index) => {

View File

@@ -237,7 +237,14 @@ class RichText {
}
if (!node.nodeData.data.richText) {
// 还不是富文本的情况
let text = node.nodeData.data.text.split(/\n/gim).join('<br>')
let text = ''
if (
node.nodeData.data.text &&
typeof node.nodeData.data.text === 'string'
) {
text = node.nodeData.data.text.split(/\n/gim).join('<br>')
}
let html = `<p>${text}</p>`
this.textEditNode.innerHTML = this.cacheEditingText || html
} else {