Demo:修复节点内容为html标签时大纲无法显示和编辑的问题

This commit is contained in:
wanglin2 2023-11-20 15:46:33 +08:00
parent 217f5ee95d
commit 0d4cbc7344
3 changed files with 9 additions and 5 deletions

View File

@ -629,7 +629,7 @@ export const textToNodeRichTextWithWrap = html => {
}
return list
.map(item => {
return `<p><span>${item}</span></p>`
return `<p><span>${htmlEscape(item)}</span></p>`
})
.join('')
}

View File

@ -42,7 +42,8 @@ import {
nodeRichTextToTextWithWrap,
textToNodeRichTextWithWrap,
getTextFromHtml,
createUid
createUid,
htmlEscape
} from 'simple-mind-map/src/utils'
//
@ -129,10 +130,11 @@ export default {
let data = this.mindMap.getData()
data.root = true //
let walk = root => {
const text = (root.data.richText
let text = (root.data.richText
? nodeRichTextToTextWithWrap(root.data.text)
: root.data.text
).replaceAll(/\n/g, '<br>')
text = htmlEscape(text)
root.textCache = text //
root.label = text
root.uid = root.data.uid

View File

@ -54,7 +54,8 @@ import {
textToNodeRichTextWithWrap,
getTextFromHtml,
createUid,
simpleDeepClone
simpleDeepClone,
htmlEscape
} from 'simple-mind-map/src/utils'
import { storeData } from '@/api'
@ -102,10 +103,11 @@ export default {
let data = this.mindMap.getData()
data.root = true //
let walk = root => {
const text = (root.data.richText
let text = (root.data.richText
? nodeRichTextToTextWithWrap(root.data.text)
: root.data.text
).replaceAll(/\n/g, '<br>')
text = htmlEscape(text)
root.textCache = text //
root.label = text
root.uid = root.data.uid