优化:手动创建节点时立即聚焦

This commit is contained in:
wanglin2 2022-09-24 20:38:47 +08:00
parent 6a3f016920
commit 34ef1e908e
2 changed files with 9 additions and 1 deletions

View File

@ -694,7 +694,7 @@ class Node {
if (this.mindMap.opt.readonly) { if (this.mindMap.opt.readonly) {
return return
} }
e.stopPropagation() e && e.stopPropagation()
if (this.nodeData.data.isActive) { if (this.nodeData.data.isActive) {
return return
} }
@ -769,6 +769,12 @@ class Node {
} }
})) }))
} }
// 手动插入的节点立即获得焦点并且开启编辑模式
if (this.nodeData.inserting) {
delete this.nodeData.inserting
this.active()
this.mindMap.emit('node_dblclick', this)
}
} }
/** /**

View File

@ -413,6 +413,7 @@ class Render {
} }
let index = this.getNodeIndex(first) let index = this.getNodeIndex(first)
first.parent.nodeData.children.splice(index + 1, 0, { first.parent.nodeData.children.splice(index + 1, 0, {
"inserting": true,
"data": { "data": {
"text": text, "text": text,
"expand": true "expand": true
@ -438,6 +439,7 @@ class Render {
} }
let text = node.isRoot ? '二级节点' : '分支主题' let text = node.isRoot ? '二级节点' : '分支主题'
node.nodeData.children.push({ node.nodeData.children.push({
"inserting": true,
"data": { "data": {
"text": text, "text": text,
"expand": true "expand": true