修复超链接、备注、标签等文字编辑时返回键和回车键与思维导图快捷键冲突的问题
This commit is contained in:
parent
f6ac2c80ed
commit
c15b9be7ef
12
README.md
12
README.md
@ -250,7 +250,7 @@ const mindMap = new MindMap({
|
|||||||
`data`:思维导图结构数据
|
`data`:思维导图结构数据
|
||||||
|
|
||||||
|
|
||||||
#### export(type, isDownload)
|
#### export(type, isDownload, fileName)
|
||||||
|
|
||||||
导出
|
导出
|
||||||
|
|
||||||
@ -258,6 +258,8 @@ const mindMap = new MindMap({
|
|||||||
|
|
||||||
`isDownload`:是否需要直接触发下载,布尔值,默认为`false`
|
`isDownload`:是否需要直接触发下载,布尔值,默认为`false`
|
||||||
|
|
||||||
|
`fileName`:(v0.1.6+)导出文件的名称,默认为`思维导图`
|
||||||
|
|
||||||
#### toPos(x, y)
|
#### toPos(x, y)
|
||||||
|
|
||||||
v0.1.5+
|
v0.1.5+
|
||||||
@ -286,6 +288,14 @@ v0.1.5+
|
|||||||
|
|
||||||
### 方法
|
### 方法
|
||||||
|
|
||||||
|
#### startTextEdit()
|
||||||
|
|
||||||
|
(v0.1.6+)若有文字编辑需求可调用该方法,会禁用回车键和删除键相关快捷键防止冲突
|
||||||
|
|
||||||
|
#### endTextEdit()
|
||||||
|
|
||||||
|
(v0.1.6+)结束文字编辑,会恢复回车键和删除键相关快捷键
|
||||||
|
|
||||||
#### addActiveNode(node)
|
#### addActiveNode(node)
|
||||||
|
|
||||||
添加节点到激活列表里
|
添加节点到激活列表里
|
||||||
|
|||||||
@ -22,11 +22,11 @@ class Export {
|
|||||||
* @Date: 2021-07-02 07:44:06
|
* @Date: 2021-07-02 07:44:06
|
||||||
* @Desc: 导出
|
* @Desc: 导出
|
||||||
*/
|
*/
|
||||||
async export(type, isDownload = true) {
|
async export(type, isDownload = true, name = '思维导图') {
|
||||||
if (this[type]) {
|
if (this[type]) {
|
||||||
let result = await this[type]()
|
let result = await this[type]()
|
||||||
if (isDownload) {
|
if (isDownload) {
|
||||||
downloadFile(result, '思维导图.' + type)
|
downloadFile(result, name + '.' + type)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -176,13 +176,13 @@ class Render {
|
|||||||
this.mindMap.execCommand('INSERT_CHILD_NODE')
|
this.mindMap.execCommand('INSERT_CHILD_NODE')
|
||||||
})
|
})
|
||||||
// 插入同级节点
|
// 插入同级节点
|
||||||
let insertNodeWrap = () => {
|
this.insertNodeWrap = () => {
|
||||||
if (this.textEdit.showTextEdit) {
|
if (this.textEdit.showTextEdit) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.mindMap.execCommand('INSERT_NODE')
|
this.mindMap.execCommand('INSERT_NODE')
|
||||||
}
|
}
|
||||||
this.mindMap.keyCommand.addShortcut('Enter', insertNodeWrap)
|
this.mindMap.keyCommand.addShortcut('Enter', this.insertNodeWrap)
|
||||||
// 展开/收起节点
|
// 展开/收起节点
|
||||||
this.mindMap.keyCommand.addShortcut('/', () => {
|
this.mindMap.keyCommand.addShortcut('/', () => {
|
||||||
this.activeNodeList.forEach((node) => {
|
this.activeNodeList.forEach((node) => {
|
||||||
@ -193,18 +193,16 @@ class Render {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
// 删除节点
|
// 删除节点
|
||||||
let removeNodeWrap = () => {
|
this.removeNodeWrap = () => {
|
||||||
this.mindMap.execCommand('REMOVE_NODE')
|
this.mindMap.execCommand('REMOVE_NODE')
|
||||||
}
|
}
|
||||||
this.mindMap.keyCommand.addShortcut('Del|Backspace', removeNodeWrap)
|
this.mindMap.keyCommand.addShortcut('Del|Backspace', this.removeNodeWrap)
|
||||||
// 节点编辑时某些快捷键会存在冲突,需要暂时去除
|
// 节点编辑时某些快捷键会存在冲突,需要暂时去除
|
||||||
this.mindMap.on('before_show_text_edit', () => {
|
this.mindMap.on('before_show_text_edit', () => {
|
||||||
this.mindMap.keyCommand.removeShortcut('Del|Backspace')
|
this.startTextEdit()
|
||||||
this.mindMap.keyCommand.removeShortcut('Enter', insertNodeWrap)
|
|
||||||
})
|
})
|
||||||
this.mindMap.on('hide_text_edit', () => {
|
this.mindMap.on('hide_text_edit', () => {
|
||||||
this.mindMap.keyCommand.addShortcut('Del|Backspace', removeNodeWrap)
|
this.endTextEdit()
|
||||||
this.mindMap.keyCommand.addShortcut('Enter', insertNodeWrap)
|
|
||||||
})
|
})
|
||||||
// 全选
|
// 全选
|
||||||
this.mindMap.keyCommand.addShortcut('Control+a', () => {
|
this.mindMap.keyCommand.addShortcut('Control+a', () => {
|
||||||
@ -212,6 +210,28 @@ class Render {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* javascript comment
|
||||||
|
* @Author: 王林25
|
||||||
|
* @Date: 2022-05-09 10:43:52
|
||||||
|
* @Desc: 开启文字编辑,会禁用回车键和删除键相关快捷键防止冲突
|
||||||
|
*/
|
||||||
|
startTextEdit() {
|
||||||
|
this.mindMap.keyCommand.removeShortcut('Del|Backspace')
|
||||||
|
this.mindMap.keyCommand.removeShortcut('Enter', this.insertNodeWrap)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* javascript comment
|
||||||
|
* @Author: 王林25
|
||||||
|
* @Date: 2022-05-09 10:45:11
|
||||||
|
* @Desc: 结束文字编辑,会恢复回车键和删除键相关快捷键
|
||||||
|
*/
|
||||||
|
endTextEdit() {
|
||||||
|
this.mindMap.keyCommand.addShortcut('Del|Backspace', this.removeNodeWrap)
|
||||||
|
this.mindMap.keyCommand.addShortcut('Enter', this.insertNodeWrap)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* javascript comment
|
* javascript comment
|
||||||
* @Author: 王林25
|
* @Author: 王林25
|
||||||
|
|||||||
@ -58,6 +58,12 @@ export default {
|
|||||||
this.$bus.$on('execCommand', this.execCommand)
|
this.$bus.$on('execCommand', this.execCommand)
|
||||||
this.$bus.$on('export', this.export)
|
this.$bus.$on('export', this.export)
|
||||||
this.$bus.$on('setData', this.setData)
|
this.$bus.$on('setData', this.setData)
|
||||||
|
this.$bus.$on('startTextEdit', () => {
|
||||||
|
this.mindMap.renderer.startTextEdit();
|
||||||
|
});
|
||||||
|
this.$bus.$on('endTextEdit', () => {
|
||||||
|
this.mindMap.renderer.endTextEdit();
|
||||||
|
});
|
||||||
if (this.openTest) {
|
if (this.openTest) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.test()
|
this.test()
|
||||||
|
|||||||
@ -61,7 +61,7 @@ export default {
|
|||||||
* @Desc: 确定
|
* @Desc: 确定
|
||||||
*/
|
*/
|
||||||
confirm() {
|
confirm() {
|
||||||
this.$bus.$emit("export", this.exportType);
|
this.$bus.$emit("export", this.exportType, true, this.fileName);
|
||||||
this.$notify.info({
|
this.$notify.info({
|
||||||
title: '消息',
|
title: '消息',
|
||||||
message: '如果没有触发下载,请检查是否被浏览器拦截了'
|
message: '如果没有触发下载,请检查是否被浏览器拦截了'
|
||||||
|
|||||||
@ -53,6 +53,7 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$bus.$on("showNodeLink", () => {
|
this.$bus.$on("showNodeLink", () => {
|
||||||
|
this.$bus.$emit('startTextEdit');
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -64,6 +65,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
cancel() {
|
cancel() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
this.$bus.$emit('endTextEdit');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -46,6 +46,7 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$bus.$on("showNodeNote", () => {
|
this.$bus.$on("showNodeNote", () => {
|
||||||
|
this.$bus.$emit('startTextEdit');
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -57,6 +58,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
cancel() {
|
cancel() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
this.$bus.$emit('endTextEdit');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$bus.$on("showNodeTag", () => {
|
this.$bus.$on("showNodeTag", () => {
|
||||||
|
this.$bus.$emit('startTextEdit');
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -97,6 +98,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
cancel() {
|
cancel() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
this.$bus.$emit('endTextEdit');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user