Feat:优化子节点的插入:1.同时对多个节点插入子节点时,不进入编辑状态;2.新插入的子节点自动进入激活状态
This commit is contained in:
parent
fcf48ca3dc
commit
a97d549d69
@ -510,6 +510,7 @@ class Render {
|
|||||||
defaultInsertBelowSecondLevelNodeText
|
defaultInsertBelowSecondLevelNodeText
|
||||||
} = this.mindMap.opt
|
} = this.mindMap.opt
|
||||||
let list = appointNodes.length > 0 ? appointNodes : this.activeNodeList
|
let list = appointNodes.length > 0 ? appointNodes : this.activeNodeList
|
||||||
|
let handleMultiNodes = list.length > 1
|
||||||
list.forEach(node => {
|
list.forEach(node => {
|
||||||
if (node.isGeneralization) {
|
if (node.isGeneralization) {
|
||||||
return
|
return
|
||||||
@ -522,12 +523,13 @@ class Render {
|
|||||||
: defaultInsertBelowSecondLevelNodeText
|
: defaultInsertBelowSecondLevelNodeText
|
||||||
let isRichText = !!this.mindMap.richText
|
let isRichText = !!this.mindMap.richText
|
||||||
node.nodeData.children.push({
|
node.nodeData.children.push({
|
||||||
inserting: openEdit,
|
inserting: handleMultiNodes ? false : openEdit,// 如果同时对多个节点插入子节点,那么无需进入编辑模式
|
||||||
data: {
|
data: {
|
||||||
text: text,
|
text: text,
|
||||||
expand: true,
|
expand: true,
|
||||||
richText: isRichText,
|
richText: isRichText,
|
||||||
resetRichText: isRichText,
|
resetRichText: isRichText,
|
||||||
|
isActive: handleMultiNodes || !openEdit,// 如果同时对多个节点插入子节点,那么需要把新增的节点设为激活状态。如果不进入编辑状态,那么也需要手动设为激活状态
|
||||||
...(appointData || {})
|
...(appointData || {})
|
||||||
},
|
},
|
||||||
children: [...appointChildren]
|
children: [...appointChildren]
|
||||||
@ -538,6 +540,10 @@ class Render {
|
|||||||
node.destroy()
|
node.destroy()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 如果同时对多个节点插入子节点,需要清除原来激活的节点
|
||||||
|
if (handleMultiNodes || !openEdit) {
|
||||||
|
this.clearActive()
|
||||||
|
}
|
||||||
this.mindMap.render()
|
this.mindMap.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user