mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Feat:新增MOVE_UP_ONE_LEVEL命令将节点上移一个层级
This commit is contained in:
parent
a5b3efd272
commit
a4f83437c9
@ -180,6 +180,9 @@ class Render {
|
||||
// 下移节点
|
||||
this.downNode = this.downNode.bind(this)
|
||||
this.mindMap.command.add('DOWN_NODE', this.downNode)
|
||||
// 将一个节点上移一个层级
|
||||
this.moveUpOneLevel = this.moveUpOneLevel.bind(this)
|
||||
this.mindMap.command.add('MOVE_UP_ONE_LEVEL', this.moveUpOneLevel)
|
||||
// 移动节点
|
||||
this.insertAfter = this.insertAfter.bind(this)
|
||||
this.mindMap.command.add('INSERT_AFTER', this.insertAfter)
|
||||
@ -890,6 +893,22 @@ class Render {
|
||||
this.mindMap.render()
|
||||
}
|
||||
|
||||
// 将节点上移一个层级,多个节点只会操作第一个节点
|
||||
moveUpOneLevel(node) {
|
||||
node = node || this.activeNodeList[0]
|
||||
if (!node || node.isRoot || node.layerIndex <= 1) {
|
||||
return
|
||||
}
|
||||
const parent = node.parent
|
||||
const grandpa = parent.parent
|
||||
const index = getNodeIndexInNodeList(node, parent.children)
|
||||
const parentIndex = getNodeIndexInNodeList(parent, grandpa.children)
|
||||
// 节点数据
|
||||
parent.nodeData.children.splice(index, 1)
|
||||
grandpa.nodeData.children.splice(parentIndex + 1, 0, node.nodeData)
|
||||
this.mindMap.render()
|
||||
}
|
||||
|
||||
// 复制节点
|
||||
copy() {
|
||||
this.beingCopyData = this.copyNode()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user