Demo:支持右键删除概要节点

This commit is contained in:
wanglin2 2023-04-19 16:07:52 +08:00
parent e36a408275
commit 6eacfab9c2
5 changed files with 14 additions and 11 deletions

View File

@ -183,11 +183,11 @@ class MindMap {
// 渲染,部分渲染
render(callback, source = '') {
// this.batchExecution.push('render', () => {
this.batchExecution.push('render', () => {
this.initTheme()
this.renderer.reRender = false
this.renderer.render(callback, source)
// })
})
}
// 重新渲染

View File

@ -389,7 +389,7 @@ class Node {
// 右键菜单事件
this.group.on('contextmenu', e => {
// 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件
if (this.mindMap.opt.readonly || this.isGeneralization || e.ctrlKey) {
if (this.mindMap.opt.readonly || e.ctrlKey) {// || this.isGeneralization
return
}
e.stopPropagation()

View File

@ -251,7 +251,6 @@ class Render {
// 渲染
render(callback = () => {}, source) {
// 如果当前还没有渲染完毕,不再触发渲染
console.log('this.isRendering', this.isRendering);
if (this.isRendering) {
// 等待当前渲染完毕后再进行一次渲染
this.hasWaitRendering = true

View File

@ -13,7 +13,7 @@
{{ $t('contextmenu.insertSiblingNode') }}
<span class="desc">Enter</span>
</div>
<div class="item" @click="exec('INSERT_CHILD_NODE')">
<div class="item" @click="exec('INSERT_CHILD_NODE')" :class="{ disabled: isGeneralization }">
{{ $t('contextmenu.insertChildNode') }}
<span class="desc">Tab</span>
</div>
@ -45,11 +45,11 @@
{{ $t('contextmenu.deleteNode') }}
<span class="desc">Delete</span>
</div>
<div class="item" @click="exec('COPY_NODE')">
<div class="item" @click="exec('COPY_NODE')" :class="{ disabled: isGeneralization }">
{{ $t('contextmenu.copyNode') }}
<span class="desc">Ctrl + C</span>
</div>
<div class="item" @click="exec('CUT_NODE')">
<div class="item" @click="exec('CUT_NODE')" :class="{ disabled: isGeneralization }">
{{ $t('contextmenu.cutNode') }}
<span class="desc">Ctrl + X</span>
</div>
@ -140,10 +140,10 @@ export default {
]
},
insertNodeBtnDisabled() {
return !this.node || this.node.isRoot
return !this.node || this.node.isRoot || this.node.isGeneralization
},
upNodeBtnDisabled() {
if (!this.node || this.node.isRoot) {
if (!this.node || this.node.isRoot || this.node.isGeneralization) {
return true
}
let isFirst =
@ -153,7 +153,7 @@ export default {
return isFirst
},
downNodeBtnDisabled() {
if (!this.node || this.node.isRoot) {
if (!this.node || this.node.isRoot || this.node.isGeneralization) {
return true
}
let children = this.node.parent.children
@ -163,6 +163,9 @@ export default {
}) ===
children.length - 1
return isLast
},
isGeneralization() {
return this.node.isGeneralization
}
},
created() {

View File

@ -308,7 +308,8 @@ export default {
'mode_change',
'node_tree_render_end',
'rich_text_selection_change',
'transforming-dom-to-images'
'transforming-dom-to-images',
'generalization_node_contextmenu'
].forEach(event => {
this.mindMap.on(event, (...args) => {
this.$bus.$emit(event, ...args)