Demo:支持从右键菜单删除节点的超链接,备注

This commit is contained in:
wanglin2 2023-08-12 22:45:41 +08:00
parent bf2f9b2697
commit 2c56cd453c
5 changed files with 29 additions and 9 deletions

View File

@ -1087,7 +1087,8 @@ class Render {
} }
// 设置节点图片 // 设置节点图片
setNodeImage(node, { url, title, width, height, custom = false }) { setNodeImage(node, data) {
const { url, title, width, height, custom = false } = data || { url: '', title: '', width: 0, height: 0, custom: false }
this.setNodeDataRender(node, { this.setNodeDataRender(node, {
image: url, image: url,
imageTitle: title || '', imageTitle: title || '',

View File

@ -77,7 +77,10 @@ export default {
level5: 'Level5', level5: 'Level5',
level6: 'Level6', level6: 'Level6',
zenMode: 'Zen mode', zenMode: 'Zen mode',
fitCanvas: 'Fit canvas' fitCanvas: 'Fit canvas',
removeImage: 'Remove image',
removeHyperlink: 'Remove hyperlink',
removeNote: 'Remove note'
}, },
count: { count: {
words: 'Words', words: 'Words',

View File

@ -77,7 +77,10 @@ export default {
level5: '五级主题', level5: '五级主题',
level6: '六级主题', level6: '六级主题',
zenMode: '禅模式', zenMode: '禅模式',
fitCanvas: '适应画布' fitCanvas: '适应画布',
removeImage: '移除图片',
removeHyperlink: '移除超链接',
removeNote: '移除备注'
}, },
count: { count: {
words: '字数', words: '字数',

View File

@ -70,6 +70,12 @@
{{ $t('contextmenu.pasteNode') }} {{ $t('contextmenu.pasteNode') }}
<span class="desc">Ctrl + V</span> <span class="desc">Ctrl + V</span>
</div> </div>
<div class="item" @click="exec('REMOVE_HYPERLINK')" v-if="hasHyperlink">
{{ $t('contextmenu.removeHyperlink') }}
</div>
<div class="item" @click="exec('REMOVE_NOTE')" v-if="hasNote">
{{ $t('contextmenu.removeNote') }}
</div>
</template> </template>
<template v-if="type === 'svg'"> <template v-if="type === 'svg'">
<div class="item" @click="exec('RETURN_CENTER')"> <div class="item" @click="exec('RETURN_CENTER')">
@ -180,6 +186,12 @@ export default {
}, },
isGeneralization() { isGeneralization() {
return this.node.isGeneralization return this.node.isGeneralization
},
hasHyperlink() {
return !!this.node.getData('hyperlink')
},
hasNote() {
return !!this.node.getData('note')
} }
}, },
created() { created() {
@ -302,6 +314,12 @@ export default {
case 'FIT_CANVAS': case 'FIT_CANVAS':
this.mindMap.view.fit() this.mindMap.view.fit()
break break
case 'REMOVE_HYPERLINK':
this.node.setHyperlink('', '')
break
case 'REMOVE_NOTE':
this.node.setNote('')
break
default: default:
this.$bus.$emit('execCommand', key, ...args) this.$bus.$emit('execCommand', key, ...args)
break break

View File

@ -105,12 +105,7 @@ export default {
if (!this.img && !this.imgUrl) { if (!this.img && !this.imgUrl) {
this.cancel() this.cancel()
this.activeNodes.forEach(node => { this.activeNodes.forEach(node => {
node.setImage({ node.setImage(null)
url: '',
title: '',
width: 0,
height: 0
})
}) })
return return
} }