mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Demo:支持双击节点备注图标进入备注编辑
This commit is contained in:
@@ -614,7 +614,8 @@ export default {
|
||||
'node_attachmentClick',
|
||||
'node_attachmentContextmenu',
|
||||
'demonstrate_jump',
|
||||
'exit_demonstrate'
|
||||
'exit_demonstrate',
|
||||
'node_note_dblclick'
|
||||
].forEach(event => {
|
||||
this.mindMap.on(event, (...args) => {
|
||||
this.$bus.$emit(event, ...args)
|
||||
|
||||
@@ -42,7 +42,8 @@ export default {
|
||||
note: '',
|
||||
activeNodes: [],
|
||||
editor: null,
|
||||
isMobile: isMobile()
|
||||
isMobile: isMobile(),
|
||||
appointNode: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -63,6 +64,10 @@ export default {
|
||||
methods: {
|
||||
handleNodeActive(...args) {
|
||||
this.activeNodes = [...args[1]]
|
||||
this.updateNoteInfo()
|
||||
},
|
||||
|
||||
updateNoteInfo() {
|
||||
if (this.activeNodes.length > 0) {
|
||||
let firstNode = this.activeNodes[0]
|
||||
this.note = firstNode.getData('note') || ''
|
||||
@@ -71,19 +76,18 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
handleShowNodeNote() {
|
||||
handleShowNodeNote(node) {
|
||||
this.$bus.$emit('startTextEdit')
|
||||
if (node) {
|
||||
this.appointNode = node
|
||||
this.note = node.getData('note') || ''
|
||||
}
|
||||
this.dialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.initEditor()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* @Author: 王林25
|
||||
* @Date: 2022-05-09 11:37:05
|
||||
* @Desc: 初始化编辑器
|
||||
*/
|
||||
initEditor() {
|
||||
if (!this.editor) {
|
||||
this.editor = new Editor({
|
||||
@@ -96,25 +100,24 @@ export default {
|
||||
this.editor.setMarkdown(this.note)
|
||||
},
|
||||
|
||||
/**
|
||||
* @Author: 王林
|
||||
* @Date: 2021-06-22 22:08:11
|
||||
* @Desc: 取消
|
||||
*/
|
||||
cancel() {
|
||||
this.dialogVisible = false
|
||||
if (this.appointNode) {
|
||||
this.appointNode = null
|
||||
this.updateNoteInfo()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @Author: 王林
|
||||
* @Date: 2021-06-06 22:28:20
|
||||
* @Desc: 确定
|
||||
*/
|
||||
confirm() {
|
||||
this.note = this.editor.getMarkdown()
|
||||
this.activeNodes.forEach(node => {
|
||||
node.setNote(this.note)
|
||||
})
|
||||
if (this.appointNode) {
|
||||
this.appointNode.setNote(this.note)
|
||||
} else {
|
||||
this.activeNodes.forEach(node => {
|
||||
node.setNote(this.note)
|
||||
})
|
||||
}
|
||||
|
||||
this.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,12 +234,14 @@ export default {
|
||||
window.addEventListener('resize', this.computeToolbarShowThrottle)
|
||||
this.$bus.$on('lang_change', this.computeToolbarShowThrottle)
|
||||
window.addEventListener('beforeunload', this.onUnload)
|
||||
this.$bus.$on('node_note_dblclick', this.onNodeNoteDblclick)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$bus.$off('write_local_file', this.onWriteLocalFile)
|
||||
window.removeEventListener('resize', this.computeToolbarShowThrottle)
|
||||
this.$bus.$off('lang_change', this.computeToolbarShowThrottle)
|
||||
window.removeEventListener('beforeunload', this.onUnload)
|
||||
this.$bus.$off('node_note_dblclick', this.onNodeNoteDblclick)
|
||||
},
|
||||
methods: {
|
||||
// 计算工具按钮如何显示
|
||||
@@ -501,6 +503,11 @@ export default {
|
||||
}
|
||||
this.$message.warning(this.$t('toolbar.notSupportTip'))
|
||||
}
|
||||
},
|
||||
|
||||
onNodeNoteDblclick(node, e) {
|
||||
e.stopPropagation()
|
||||
this.$bus.$emit('showNodeNote', node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user