Demo:大纲支持按Shift+Tab将节点上移一个层级

This commit is contained in:
街角小林 2024-01-25 15:24:41 +08:00
parent a4f83437c9
commit 12f9e03f63
4 changed files with 83 additions and 3 deletions

View File

@ -330,6 +330,36 @@ export const shortcutKeyList = [
value: 'Ctrl + i' 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'
},
]
} }
] ]

View File

@ -397,6 +397,36 @@ export const shortcutKeyList = [
value: 'Ctrl + i' 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'
},
]
} }
] ]

View File

@ -99,6 +99,7 @@ export default {
// //
if (this.notHandleDataChange) { if (this.notHandleDataChange) {
this.notHandleDataChange = false this.notHandleDataChange = false
this.isAfterCreateNewNode = false
return return
} }
if (this.isAfterCreateNewNode) { if (this.isAfterCreateNewNode) {
@ -223,17 +224,30 @@ export default {
// //
onNodeInputKeydown(e) { onNodeInputKeydown(e) {
if (e.keyCode === 13 && !e.shiftKey) { if (e.keyCode === 13 && !e.shiftKey) {
//
e.preventDefault() e.preventDefault()
this.insertType = 'insertNode' this.insertType = 'insertNode'
e.target.blur() e.target.blur()
} }
if (e.keyCode === 9) { if (e.keyCode === 9) {
e.preventDefault() e.preventDefault()
this.insertType = 'insertChildNode' if (e.shiftKey) {
e.target.blur() //
this.insertType = 'moveUp'
e.target.blur()
} else {
//
this.insertType = 'insertChildNode'
e.target.blur()
}
} }
}, },
//
moveUp() {
this.mindMap.execCommand('MOVE_UP_ONE_LEVEL')
},
// //
insertNode() { insertNode() {
this.notHandleDataChange = true this.notHandleDataChange = true

View File

@ -178,7 +178,13 @@ export default {
} }
if (e.keyCode === 9) { if (e.keyCode === 9) {
e.preventDefault() 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.save()
this.$nextTick(() => { this.$nextTick(() => {