新增快捷键
This commit is contained in:
parent
b4193d50a3
commit
10d04549fc
@ -10,7 +10,10 @@ const createFullData = () => {
|
|||||||
"tag": ["标签1", "标签2"],
|
"tag": ["标签1", "标签2"],
|
||||||
"hyperlink": "http://lxqnsys.com/",
|
"hyperlink": "http://lxqnsys.com/",
|
||||||
"hyperlinkTitle": "理想青年实验室",
|
"hyperlinkTitle": "理想青年实验室",
|
||||||
"note": "理想青年实验室\n一个有意思的角落"
|
"note": "理想青年实验室\n一个有意思的角落",
|
||||||
|
// 自定义位置
|
||||||
|
// "customLeft": 1318,
|
||||||
|
// "customTop": 374.5
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -222,6 +222,13 @@ class Render {
|
|||||||
this.mindMap.keyCommand.addShortcut('Control+a', () => {
|
this.mindMap.keyCommand.addShortcut('Control+a', () => {
|
||||||
this.mindMap.execCommand('SELECT_ALL')
|
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
|
return
|
||||||
}
|
}
|
||||||
this.activeNodeList.forEach((node) => {
|
this.activeNodeList.forEach((node) => {
|
||||||
if (node.nodeData.data.generalization) {
|
if (node.nodeData.data.generalization || node.isRoot) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.setNodeData(node, {
|
this.setNodeData(node, {
|
||||||
|
|||||||
@ -214,10 +214,20 @@ export const shortcutKeyList = [
|
|||||||
name: '插入同级节点',
|
name: '插入同级节点',
|
||||||
value: 'Enter'
|
value: 'Enter'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '上移节点',
|
||||||
|
value: 'Ctrl + ↑'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '下移节点',
|
||||||
|
value: 'Ctrl + ↓'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: 'icongaikuozonglan',
|
icon: 'icongaikuozonglan',
|
||||||
name: '插入概要',
|
name: '插入概要',
|
||||||
value: 'Shift + s'
|
value: 'Shift + S'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'iconzhankai',
|
icon: 'iconzhankai',
|
||||||
@ -229,6 +239,21 @@ export const shortcutKeyList = [
|
|||||||
name: '删除节点',
|
name: '删除节点',
|
||||||
value: 'Delete | Backspace'
|
value: 'Delete | Backspace'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '复制节点',
|
||||||
|
value: 'Ctrl + C'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '剪切节点',
|
||||||
|
value: 'Ctrl + X'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '粘贴节点',
|
||||||
|
value: 'Ctrl + V'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: 'iconbianji',
|
icon: 'iconbianji',
|
||||||
name: '编辑节点',
|
name: '编辑节点',
|
||||||
@ -253,7 +278,12 @@ export const shortcutKeyList = [
|
|||||||
icon: 'iconquanxuan',
|
icon: 'iconquanxuan',
|
||||||
name: '全选',
|
name: '全选',
|
||||||
value: 'Ctrl + A'
|
value: 'Ctrl + A'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
icon: '',
|
||||||
|
name: '一键整理布局',
|
||||||
|
value: 'Shift + L'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,14 +11,23 @@
|
|||||||
:class="{ disabled: insertNodeBtnDisabled }"
|
:class="{ disabled: insertNodeBtnDisabled }"
|
||||||
>
|
>
|
||||||
插入同级节点
|
插入同级节点
|
||||||
|
<span class="desc">Enter</span>
|
||||||
|
</div>
|
||||||
|
<div class="item" @click="exec('INSERT_CHILD_NODE')">
|
||||||
|
插入子级节点
|
||||||
|
<span class="desc">Tab</span>
|
||||||
|
</div>
|
||||||
|
<div class="item" @click="exec('ADD_GENERALIZATION')" :class="{ disabled: insertNodeBtnDisabled }">
|
||||||
|
插入概要
|
||||||
|
<span class="desc">Shift + s</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="item" @click="exec('INSERT_CHILD_NODE')">插入子级节点</div>
|
|
||||||
<div
|
<div
|
||||||
class="item"
|
class="item"
|
||||||
@click="exec('UP_NODE')"
|
@click="exec('UP_NODE')"
|
||||||
:class="{ disabled: upNodeBtnDisabled }"
|
:class="{ disabled: upNodeBtnDisabled }"
|
||||||
>
|
>
|
||||||
上移节点
|
上移节点
|
||||||
|
<span class="desc">Ctrl + ↑</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="item"
|
class="item"
|
||||||
@ -26,23 +35,37 @@
|
|||||||
:class="{ disabled: downNodeBtnDisabled }"
|
:class="{ disabled: downNodeBtnDisabled }"
|
||||||
>
|
>
|
||||||
下移节点
|
下移节点
|
||||||
|
<span class="desc">Ctrl + ↓</span>
|
||||||
|
</div>
|
||||||
|
<div class="item danger" @click="exec('REMOVE_NODE')">
|
||||||
|
删除节点
|
||||||
|
<span class="desc">Delete</span>
|
||||||
|
</div>
|
||||||
|
<div class="item" @click="exec('COPY_NODE')">
|
||||||
|
复制节点
|
||||||
|
<span class="desc">Ctrl + C</span>
|
||||||
|
</div>
|
||||||
|
<div class="item" @click="exec('CUT_NODE')">
|
||||||
|
剪切节点
|
||||||
|
<span class="desc">Ctrl + X</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="item danger" @click="exec('REMOVE_NODE')">删除节点</div>
|
|
||||||
<div class="item" @click="exec('COPY_NODE')">复制节点</div>
|
|
||||||
<div class="item" @click="exec('CUT_NODE')">剪切节点</div>
|
|
||||||
<div
|
<div
|
||||||
class="item"
|
class="item"
|
||||||
:class="{ disabled: copyData === null }"
|
:class="{ disabled: copyData === null }"
|
||||||
@click="exec('PASTE_NODE')"
|
@click="exec('PASTE_NODE')"
|
||||||
>
|
>
|
||||||
粘贴节点
|
粘贴节点
|
||||||
|
<span class="desc">Ctrl + V</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="type === 'svg'">
|
<template v-if="type === 'svg'">
|
||||||
<div class="item" @click="exec('RETURN_CENTER')">回到中心</div>
|
<div class="item" @click="exec('RETURN_CENTER')">回到中心</div>
|
||||||
<div class="item" @click="exec('EXPAND_ALL')">展开所有</div>
|
<div class="item" @click="exec('EXPAND_ALL')">展开所有</div>
|
||||||
<div class="item" @click="exec('UNEXPAND_ALL')">收起所有</div>
|
<div class="item" @click="exec('UNEXPAND_ALL')">收起所有</div>
|
||||||
<div class="item" @click="exec('RESET_LAYOUT')">一键整理布局</div>
|
<div class="item" @click="exec('RESET_LAYOUT')">
|
||||||
|
一键整理布局
|
||||||
|
<span class="desc">Shift + L</span>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -107,6 +130,10 @@ export default {
|
|||||||
this.$bus.$on("expand_btn_click", this.hide);
|
this.$bus.$on("expand_btn_click", this.hide);
|
||||||
this.$bus.$on("svg_mousedown", this.onMousedown);
|
this.$bus.$on("svg_mousedown", this.onMousedown);
|
||||||
this.$bus.$on("mouseup", this.onMouseup);
|
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() {
|
beforeDestroy() {
|
||||||
this.$bus.$off("node_contextmenu", this.show);
|
this.$bus.$off("node_contextmenu", this.show);
|
||||||
@ -115,6 +142,10 @@ export default {
|
|||||||
this.$bus.$off("expand_btn_click", this.hide);
|
this.$bus.$off("expand_btn_click", this.hide);
|
||||||
this.$bus.$on("svg_mousedown", this.onMousedown);
|
this.$bus.$on("svg_mousedown", this.onMousedown);
|
||||||
this.$bus.$on("mouseup", this.onMouseup);
|
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: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
@ -215,6 +246,33 @@ export default {
|
|||||||
}
|
}
|
||||||
this.hide();
|
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");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -222,7 +280,7 @@ export default {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contextmenuContainer {
|
.contextmenuContainer {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 161px;
|
width: 200px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 4px 12px 0 hsla(0, 0%, 69%, 0.5);
|
box-shadow: 0 4px 12px 0 hsla(0, 0%, 69%, 0.5);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@ -236,8 +294,10 @@ export default {
|
|||||||
.item {
|
.item {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
padding-left: 16px;
|
padding: 0 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
&.danger {
|
&.danger {
|
||||||
color: #f56c6c;
|
color: #f56c6c;
|
||||||
@ -250,11 +310,16 @@ export default {
|
|||||||
&.disabled {
|
&.disabled {
|
||||||
color: grey;
|
color: grey;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<Theme :mindMap="mindMap"></Theme>
|
<Theme :mindMap="mindMap"></Theme>
|
||||||
<Structure :mindMap="mindMap"></Structure>
|
<Structure :mindMap="mindMap"></Structure>
|
||||||
<ShortcutKey></ShortcutKey>
|
<ShortcutKey></ShortcutKey>
|
||||||
<Contextmenu :mindMap="mindMap"></Contextmenu>
|
<Contextmenu v-if="mindMap" :mindMap="mindMap"></Contextmenu>
|
||||||
<NodeNoteContentShow></NodeNoteContentShow>
|
<NodeNoteContentShow></NodeNoteContentShow>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user