diff --git a/simple-mind-map/example/exampleData.js b/simple-mind-map/example/exampleData.js index 5a1bb5cd..1fd46fb5 100644 --- a/simple-mind-map/example/exampleData.js +++ b/simple-mind-map/example/exampleData.js @@ -10,7 +10,10 @@ const createFullData = () => { "tag": ["标签1", "标签2"], "hyperlink": "http://lxqnsys.com/", "hyperlinkTitle": "理想青年实验室", - "note": "理想青年实验室\n一个有意思的角落" + "note": "理想青年实验室\n一个有意思的角落", + // 自定义位置 + // "customLeft": 1318, + // "customTop": 374.5 }; } diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index e209760b..e68f29ab 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -222,6 +222,13 @@ class Render { this.mindMap.keyCommand.addShortcut('Control+a', () => { this.mindMap.execCommand('SELECT_ALL') }) + // 一键整理布局 + this.mindMap.keyCommand.addShortcut('Shift+l', this.resetLayout) + // 上移节点 + this.mindMap.keyCommand.addShortcut('Control+Up', this.upNode) + // 下移节点 + this.mindMap.keyCommand.addShortcut('Control+Down', this.downNode) + // 复制节点、剪切节点、粘贴节点的快捷键需开发者自行注册实现,可参考demo } /** @@ -890,7 +897,7 @@ class Render { return } this.activeNodeList.forEach((node) => { - if (node.nodeData.data.generalization) { + if (node.nodeData.data.generalization || node.isRoot) { return } this.setNodeData(node, { diff --git a/web/src/config/index.js b/web/src/config/index.js index 68399c03..b5a1d3ab 100644 --- a/web/src/config/index.js +++ b/web/src/config/index.js @@ -214,10 +214,20 @@ export const shortcutKeyList = [ name: '插入同级节点', value: 'Enter' }, + { + icon: '', + name: '上移节点', + value: 'Ctrl + ↑' + }, + { + icon: '', + name: '下移节点', + value: 'Ctrl + ↓' + }, { icon: 'icongaikuozonglan', name: '插入概要', - value: 'Shift + s' + value: 'Shift + S' }, { icon: 'iconzhankai', @@ -229,6 +239,21 @@ export const shortcutKeyList = [ name: '删除节点', value: 'Delete | Backspace' }, + { + icon: '', + name: '复制节点', + value: 'Ctrl + C' + }, + { + icon: '', + name: '剪切节点', + value: 'Ctrl + X' + }, + { + icon: '', + name: '粘贴节点', + value: 'Ctrl + V' + }, { icon: 'iconbianji', name: '编辑节点', @@ -253,7 +278,12 @@ export const shortcutKeyList = [ icon: 'iconquanxuan', name: '全选', value: 'Ctrl + A' - } + }, + { + icon: '', + name: '一键整理布局', + value: 'Shift + L' + }, ] }, { diff --git a/web/src/pages/Edit/components/Contextmenu.vue b/web/src/pages/Edit/components/Contextmenu.vue index 600c27a5..3358540a 100644 --- a/web/src/pages/Edit/components/Contextmenu.vue +++ b/web/src/pages/Edit/components/Contextmenu.vue @@ -11,14 +11,23 @@ :class="{ disabled: insertNodeBtnDisabled }" > 插入同级节点 + Enter + +
+ 插入子级节点 + Tab +
+
+ 插入概要 + Shift + s
-
插入子级节点
上移节点 + Ctrl + ↑
下移节点 + Ctrl + ↓ +
+
+ 删除节点 + Delete +
+
+ 复制节点 + Ctrl + C +
+
+ 剪切节点 + Ctrl + X
-
删除节点
-
复制节点
-
剪切节点
粘贴节点 + Ctrl + V
@@ -107,6 +130,10 @@ export default { this.$bus.$on("expand_btn_click", this.hide); this.$bus.$on("svg_mousedown", this.onMousedown); this.$bus.$on("mouseup", this.onMouseup); + // 注册快捷键 + this.mindMap.keyCommand.addShortcut('Control+c', this.copy); + this.mindMap.keyCommand.addShortcut('Control+v', this.paste); + this.mindMap.keyCommand.addShortcut('Control+x', this.cut); }, beforeDestroy() { this.$bus.$off("node_contextmenu", this.show); @@ -115,6 +142,10 @@ export default { this.$bus.$off("expand_btn_click", this.hide); this.$bus.$on("svg_mousedown", this.onMousedown); this.$bus.$on("mouseup", this.onMouseup); + // 移除快捷键 + this.mindMap.keyCommand.removeShortcut('Control+c', this.copy); + this.mindMap.keyCommand.removeShortcut('Control+v', this.paste); + this.mindMap.keyCommand.removeShortcut('Control+x', this.cut); }, methods: { /** @@ -215,6 +246,33 @@ export default { } this.hide(); }, + + /** + * @Author: 王林25 + * @Date: 2022-08-04 14:25:45 + * @Desc: 复制 + */ + copy() { + this.exec("COPY_NODE"); + }, + + /** + * @Author: 王林25 + * @Date: 2022-08-04 14:26:43 + * @Desc: 粘贴 + */ + paste() { + this.exec("PASTE_NODE"); + }, + + /** + * @Author: 王林25 + * @Date: 2022-08-04 14:27:32 + * @Desc: 剪切 + */ + cut() { + this.exec("CUT_NODE"); + } }, }; @@ -222,7 +280,7 @@ export default { diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index d65c766b..dc8654ce 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -9,7 +9,7 @@ - +