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.downNode = this.downNode.bind(this)
|
||||||
this.mindMap.command.add('DOWN_NODE', this.downNode)
|
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.insertAfter = this.insertAfter.bind(this)
|
||||||
this.mindMap.command.add('INSERT_AFTER', this.insertAfter)
|
this.mindMap.command.add('INSERT_AFTER', this.insertAfter)
|
||||||
@ -890,6 +893,22 @@ class Render {
|
|||||||
this.mindMap.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() {
|
copy() {
|
||||||
this.beingCopyData = this.copyNode()
|
this.beingCopyData = this.copyNode()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user