Fix:修复非富文本模式下文本中存在<>&字符时再次编辑时部分文本会消失的问题
This commit is contained in:
parent
0f047da78b
commit
8596e3356d
@ -1,4 +1,10 @@
|
|||||||
import { getStrWithBrFromHtml, checkNodeOuter, focusInput, selectAllInput } from '../../utils'
|
import {
|
||||||
|
getStrWithBrFromHtml,
|
||||||
|
checkNodeOuter,
|
||||||
|
focusInput,
|
||||||
|
selectAllInput,
|
||||||
|
htmlEscape
|
||||||
|
} from '../../utils'
|
||||||
import { ERROR_TYPES } from '../../constants/constant'
|
import { ERROR_TYPES } from '../../constants/constant'
|
||||||
|
|
||||||
// 节点文字编辑类
|
// 节点文字编辑类
|
||||||
@ -167,9 +173,11 @@ export default class TextEdit {
|
|||||||
let scale = this.mindMap.view.scale
|
let scale = this.mindMap.view.scale
|
||||||
let lineHeight = node.style.merge('lineHeight')
|
let lineHeight = node.style.merge('lineHeight')
|
||||||
let fontSize = node.style.merge('fontSize')
|
let fontSize = node.style.merge('fontSize')
|
||||||
let textLines = (this.cacheEditingText || node.nodeData.data.text).split(
|
let textLines = (this.cacheEditingText || node.nodeData.data.text)
|
||||||
/\n/gim
|
.split(/\n/gim)
|
||||||
)
|
.map(item => {
|
||||||
|
return htmlEscape(item)
|
||||||
|
})
|
||||||
let isMultiLine = node._textData.node.attr('data-ismultiLine') === 'true'
|
let isMultiLine = node._textData.node.attr('data-ismultiLine') === 'true'
|
||||||
node.style.domText(this.textEditNode, scale, isMultiLine)
|
node.style.domText(this.textEditNode, scale, isMultiLine)
|
||||||
this.textEditNode.style.zIndex = nodeTextEditZIndex
|
this.textEditNode.style.zIndex = nodeTextEditZIndex
|
||||||
|
|||||||
@ -797,3 +797,15 @@ export const getNodeIndex = node => {
|
|||||||
})
|
})
|
||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// html转义
|
||||||
|
export const htmlEscape = str => {
|
||||||
|
;[
|
||||||
|
['&', '&'],
|
||||||
|
['<', '<'],
|
||||||
|
['>', '>']
|
||||||
|
].forEach(item => {
|
||||||
|
str = str.replace(new RegExp(item[0], 'g'), item[1])
|
||||||
|
})
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user