mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Demo:大纲支持按Shift+Tab将节点上移一个层级
This commit is contained in:
parent
a4f83437c9
commit
12f9e03f63
@ -330,6 +330,36 @@ export const shortcutKeyList = [
|
||||
value: 'Ctrl + i'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'Outline Operation',
|
||||
list: [
|
||||
{
|
||||
icon: 'iconhuanhang',
|
||||
name: 'Text Wrap',
|
||||
value: 'Shift + Enter'
|
||||
},
|
||||
{
|
||||
icon: 'iconshanchu',
|
||||
name: 'Delete current node',
|
||||
value: 'Delete'
|
||||
},
|
||||
{
|
||||
icon: 'icontianjiazijiedian',
|
||||
name: 'Inert child node',
|
||||
value: 'Tab'
|
||||
},
|
||||
{
|
||||
icon: 'iconjiedian',
|
||||
name: 'Insert sibling node',
|
||||
value: 'Enter'
|
||||
},
|
||||
{
|
||||
icon: 'icondodeparent',
|
||||
name: 'Move up one level',
|
||||
value: 'Shift + Tab'
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -397,6 +397,36 @@ export const shortcutKeyList = [
|
||||
value: 'Ctrl + i'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: '大纲操作',
|
||||
list: [
|
||||
{
|
||||
icon: 'iconhuanhang',
|
||||
name: '文本换行',
|
||||
value: 'Shift + Enter'
|
||||
},
|
||||
{
|
||||
icon: 'iconshanchu',
|
||||
name: '删除节点',
|
||||
value: 'Delete'
|
||||
},
|
||||
{
|
||||
icon: 'icontianjiazijiedian',
|
||||
name: '插入下级节点',
|
||||
value: 'Tab'
|
||||
},
|
||||
{
|
||||
icon: 'iconjiedian',
|
||||
name: '插入同级节点',
|
||||
value: 'Enter'
|
||||
},
|
||||
{
|
||||
icon: 'icondodeparent',
|
||||
name: '上移一个层级',
|
||||
value: 'Shift + Tab'
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -99,6 +99,7 @@ export default {
|
||||
// 在大纲里操作节点时不要响应该事件,否则会重新刷新树
|
||||
if (this.notHandleDataChange) {
|
||||
this.notHandleDataChange = false
|
||||
this.isAfterCreateNewNode = false
|
||||
return
|
||||
}
|
||||
if (this.isAfterCreateNewNode) {
|
||||
@ -223,17 +224,30 @@ export default {
|
||||
// 节点输入区域按键事件
|
||||
onNodeInputKeydown(e) {
|
||||
if (e.keyCode === 13 && !e.shiftKey) {
|
||||
// 插入兄弟节点
|
||||
e.preventDefault()
|
||||
this.insertType = 'insertNode'
|
||||
e.target.blur()
|
||||
}
|
||||
if (e.keyCode === 9) {
|
||||
e.preventDefault()
|
||||
this.insertType = 'insertChildNode'
|
||||
e.target.blur()
|
||||
if (e.shiftKey) {
|
||||
// 节点上升一级
|
||||
this.insertType = 'moveUp'
|
||||
e.target.blur()
|
||||
} else {
|
||||
// 插入子节点
|
||||
this.insertType = 'insertChildNode'
|
||||
e.target.blur()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 节点上移一个层级
|
||||
moveUp() {
|
||||
this.mindMap.execCommand('MOVE_UP_ONE_LEVEL')
|
||||
},
|
||||
|
||||
// 插入兄弟节点
|
||||
insertNode() {
|
||||
this.notHandleDataChange = true
|
||||
|
||||
@ -178,7 +178,13 @@ export default {
|
||||
}
|
||||
if (e.keyCode === 9) {
|
||||
e.preventDefault()
|
||||
this.$refs.tree.append(data, node)
|
||||
if (e.shiftKey) {
|
||||
// 上移一个层级
|
||||
this.$refs.tree.insertAfter(node.data, node.parent)
|
||||
this.$refs.tree.remove(node)
|
||||
} else {
|
||||
this.$refs.tree.append(data, node)
|
||||
}
|
||||
}
|
||||
this.save()
|
||||
this.$nextTick(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user