mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 18:37:43 +08:00
Merge branch 'feature' into tag_color
This commit is contained in:
commit
2a816f62fa
@ -2,7 +2,8 @@
|
||||
"name": "simple-mind-map",
|
||||
"version": "0.7.1-fix.2",
|
||||
"description": "一个简单的web在线思维导图",
|
||||
"authors": [{
|
||||
"authors": [
|
||||
{
|
||||
"name": "街角小林",
|
||||
"email": "1013335014@qq.com"
|
||||
},
|
||||
@ -49,4 +50,4 @@
|
||||
"eslint": "^8.25.0",
|
||||
"prettier": "^2.7.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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'
|
||||
|
||||
// 节点文字编辑类
|
||||
@ -167,9 +173,11 @@ export default class TextEdit {
|
||||
let scale = this.mindMap.view.scale
|
||||
let lineHeight = node.style.merge('lineHeight')
|
||||
let fontSize = node.style.merge('fontSize')
|
||||
let textLines = (this.cacheEditingText || node.nodeData.data.text).split(
|
||||
/\n/gim
|
||||
)
|
||||
let textLines = (this.cacheEditingText || node.nodeData.data.text)
|
||||
.split(/\n/gim)
|
||||
.map(item => {
|
||||
return htmlEscape(item)
|
||||
})
|
||||
let isMultiLine = node._textData.node.attr('data-ismultiLine') === 'true'
|
||||
node.style.domText(this.textEditNode, scale, isMultiLine)
|
||||
this.textEditNode.style.zIndex = nodeTextEditZIndex
|
||||
|
||||
@ -798,6 +798,7 @@ export const getNodeIndex = node => {
|
||||
: 0
|
||||
}
|
||||
|
||||
|
||||
// 根据内容生成颜色
|
||||
export const generateColorByContent = str => {
|
||||
let hash = 0
|
||||
@ -811,3 +812,15 @@ export const generateColorByContent = str => {
|
||||
const h = rng.genrand_int32() % 360
|
||||
return 'hsla(' + h + ', 50%, 50%, 1)'
|
||||
}
|
||||
|
||||
// html转义
|
||||
export const htmlEscape = str => {
|
||||
;[
|
||||
['&', '&'],
|
||||
['<', '<'],
|
||||
['>', '>']
|
||||
].forEach(item => {
|
||||
str = str.replace(new RegExp(item[0], 'g'), item[1])
|
||||
})
|
||||
return str
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user