From 12f9e03f63210bbe0dc7603a19b5299c52ab4efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Thu, 25 Jan 2024 15:24:41 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E5=A4=A7=E7=BA=B2=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8C=89Shift+Tab=E5=B0=86=E8=8A=82=E7=82=B9=E4=B8=8A?= =?UTF-8?q?=E7=A7=BB=E4=B8=80=E4=B8=AA=E5=B1=82=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/config/en.js | 30 +++++++++++++++++++ web/src/config/zh.js | 30 +++++++++++++++++++ web/src/pages/Edit/components/Outline.vue | 18 +++++++++-- web/src/pages/Edit/components/OutlineEdit.vue | 8 ++++- 4 files changed, 83 insertions(+), 3 deletions(-) diff --git a/web/src/config/en.js b/web/src/config/en.js index 2d57e7b6..96cbbf83 100644 --- a/web/src/config/en.js +++ b/web/src/config/en.js @@ -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' + }, + ] } ] diff --git a/web/src/config/zh.js b/web/src/config/zh.js index e8036390..f06815f7 100644 --- a/web/src/config/zh.js +++ b/web/src/config/zh.js @@ -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' + }, + ] } ] diff --git a/web/src/pages/Edit/components/Outline.vue b/web/src/pages/Edit/components/Outline.vue index 0e7d663e..ef32ed35 100644 --- a/web/src/pages/Edit/components/Outline.vue +++ b/web/src/pages/Edit/components/Outline.vue @@ -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 diff --git a/web/src/pages/Edit/components/OutlineEdit.vue b/web/src/pages/Edit/components/OutlineEdit.vue index 1ab514fd..a2a752fe 100644 --- a/web/src/pages/Edit/components/OutlineEdit.vue +++ b/web/src/pages/Edit/components/OutlineEdit.vue @@ -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(() => {