Fix:修复在节点编辑状态中通过鼠标滚轮缩放画布再推出节点编辑后快捷键生效的问题
This commit is contained in:
parent
34eece8fcf
commit
0fa731c3a2
@ -30,7 +30,9 @@ export default class TextEdit {
|
|||||||
this.onScale = this.onScale.bind(this)
|
this.onScale = this.onScale.bind(this)
|
||||||
this.onKeydown = this.onKeydown.bind(this)
|
this.onKeydown = this.onKeydown.bind(this)
|
||||||
// 节点双击事件
|
// 节点双击事件
|
||||||
this.mindMap.on('node_dblclick', this.show)
|
this.mindMap.on('node_dblclick', node => {
|
||||||
|
this.show({ node })
|
||||||
|
})
|
||||||
// 点击事件
|
// 点击事件
|
||||||
this.mindMap.on('draw_click', () => {
|
this.mindMap.on('draw_click', () => {
|
||||||
// 隐藏文本编辑框
|
// 隐藏文本编辑框
|
||||||
@ -56,7 +58,9 @@ export default class TextEdit {
|
|||||||
})
|
})
|
||||||
// 鼠标滚动事件
|
// 鼠标滚动事件
|
||||||
this.mindMap.on('mousewheel', () => {
|
this.mindMap.on('mousewheel', () => {
|
||||||
if (this.mindMap.opt.mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.MOVE) {
|
if (
|
||||||
|
this.mindMap.opt.mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.MOVE
|
||||||
|
) {
|
||||||
this.hideEditTextBox()
|
this.hideEditTextBox()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -65,7 +69,9 @@ export default class TextEdit {
|
|||||||
if (this.renderer.activeNodeList.length <= 0) {
|
if (this.renderer.activeNodeList.length <= 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.show(this.renderer.activeNodeList[0])
|
this.show({
|
||||||
|
node: this.renderer.activeNodeList[0]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
this.mindMap.on('scale', this.onScale)
|
this.mindMap.on('scale', this.onScale)
|
||||||
// // 监听按键事件,判断是否自动进入文本编辑模式
|
// // 监听按键事件,判断是否自动进入文本编辑模式
|
||||||
@ -89,7 +95,12 @@ export default class TextEdit {
|
|||||||
const node = activeNodeList[0]
|
const node = activeNodeList[0]
|
||||||
// 当正在输入中文或英文或数字时,如果没有按下组合键,那么自动进入文本编辑模式
|
// 当正在输入中文或英文或数字时,如果没有按下组合键,那么自动进入文本编辑模式
|
||||||
if (node && this.checkIsAutoEnterTextEditKey(e)) {
|
if (node && this.checkIsAutoEnterTextEditKey(e)) {
|
||||||
this.show(node, e, false, true)
|
this.show({
|
||||||
|
node,
|
||||||
|
e,
|
||||||
|
isInserting: false,
|
||||||
|
isFromKeyDown: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,12 +129,17 @@ export default class TextEdit {
|
|||||||
// 显示文本编辑框
|
// 显示文本编辑框
|
||||||
// isInserting:是否是刚创建的节点
|
// isInserting:是否是刚创建的节点
|
||||||
// isFromKeyDown:是否是在按键事件进入的编辑
|
// isFromKeyDown:是否是在按键事件进入的编辑
|
||||||
async show(node, e, isInserting = false, isFromKeyDown = false) {
|
async show({
|
||||||
|
node,
|
||||||
|
isInserting = false,
|
||||||
|
isFromKeyDown = false,
|
||||||
|
isFromScale = false
|
||||||
|
}) {
|
||||||
// 使用了自定义节点内容那么不响应编辑事件
|
// 使用了自定义节点内容那么不响应编辑事件
|
||||||
if (node.isUseCustomNodeContent()) {
|
if (node.isUseCustomNodeContent()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let { beforeTextEdit } = this.mindMap.opt
|
const { beforeTextEdit } = this.mindMap.opt
|
||||||
if (typeof beforeTextEdit === 'function') {
|
if (typeof beforeTextEdit === 'function') {
|
||||||
let isShow = false
|
let isShow = false
|
||||||
try {
|
try {
|
||||||
@ -135,14 +151,21 @@ export default class TextEdit {
|
|||||||
if (!isShow) return
|
if (!isShow) return
|
||||||
}
|
}
|
||||||
this.currentNode = node
|
this.currentNode = node
|
||||||
let { offsetLeft, offsetTop } = checkNodeOuter(this.mindMap, node)
|
const { offsetLeft, offsetTop } = checkNodeOuter(this.mindMap, node)
|
||||||
this.mindMap.view.translateXY(offsetLeft, offsetTop)
|
this.mindMap.view.translateXY(offsetLeft, offsetTop)
|
||||||
let rect = node._textData.node.node.getBoundingClientRect()
|
const rect = node._textData.node.node.getBoundingClientRect()
|
||||||
|
const params = {
|
||||||
|
node,
|
||||||
|
rect,
|
||||||
|
isInserting,
|
||||||
|
isFromKeyDown,
|
||||||
|
isFromScale
|
||||||
|
}
|
||||||
if (this.mindMap.richText) {
|
if (this.mindMap.richText) {
|
||||||
this.mindMap.richText.showEditText(node, rect, isInserting, isFromKeyDown)
|
this.mindMap.richText.showEditText(params)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.showEditTextBox(node, rect, isInserting, isFromKeyDown)
|
this.showEditTextBox(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理画布缩放
|
// 处理画布缩放
|
||||||
@ -156,15 +179,20 @@ export default class TextEdit {
|
|||||||
this.cacheEditingText = this.getEditText()
|
this.cacheEditingText = this.getEditText()
|
||||||
this.showTextEdit = false
|
this.showTextEdit = false
|
||||||
}
|
}
|
||||||
this.show(this.currentNode)
|
this.show({
|
||||||
|
node: this.currentNode,
|
||||||
|
isFromScale: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示文本编辑框
|
// 显示文本编辑框
|
||||||
showEditTextBox(node, rect, isInserting, isFromKeyDown) {
|
showEditTextBox({ node, rect, isInserting, isFromKeyDown, isFromScale }) {
|
||||||
if (this.showTextEdit) return
|
if (this.showTextEdit) return
|
||||||
const { nodeTextEditZIndex, textAutoWrapWidth, selectTextOnEnterEditText } =
|
const { nodeTextEditZIndex, textAutoWrapWidth, selectTextOnEnterEditText } =
|
||||||
this.mindMap.opt
|
this.mindMap.opt
|
||||||
this.mindMap.emit('before_show_text_edit')
|
if (!isFromScale) {
|
||||||
|
this.mindMap.emit('before_show_text_edit')
|
||||||
|
}
|
||||||
this.registerTmpShortcut()
|
this.registerTmpShortcut()
|
||||||
if (!this.textEditNode) {
|
if (!this.textEditNode) {
|
||||||
this.textEditNode = document.createElement('div')
|
this.textEditNode = document.createElement('div')
|
||||||
|
|||||||
@ -153,7 +153,7 @@ class RichText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 显示文本编辑控件
|
// 显示文本编辑控件
|
||||||
showEditText(node, rect, isInserting, isFromKeyDown) {
|
showEditText({ node, rect, isInserting, isFromKeyDown, isFromScale }) {
|
||||||
if (this.showTextEdit) {
|
if (this.showTextEdit) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -167,7 +167,9 @@ class RichText {
|
|||||||
this.node = node
|
this.node = node
|
||||||
this.isInserting = isInserting
|
this.isInserting = isInserting
|
||||||
if (!rect) rect = node._textData.node.node.getBoundingClientRect()
|
if (!rect) rect = node._textData.node.node.getBoundingClientRect()
|
||||||
this.mindMap.emit('before_show_text_edit')
|
if (!isFromScale) {
|
||||||
|
this.mindMap.emit('before_show_text_edit')
|
||||||
|
}
|
||||||
this.mindMap.renderer.textEdit.registerTmpShortcut()
|
this.mindMap.renderer.textEdit.registerTmpShortcut()
|
||||||
// 原始宽高
|
// 原始宽高
|
||||||
let g = node._textData.node
|
let g = node._textData.node
|
||||||
@ -571,7 +573,7 @@ class RichText {
|
|||||||
setNotActiveNodeStyle(node, style) {
|
setNotActiveNodeStyle(node, style) {
|
||||||
const config = this.normalStyleToRichTextStyle(style)
|
const config = this.normalStyleToRichTextStyle(style)
|
||||||
if (Object.keys(config).length > 0) {
|
if (Object.keys(config).length > 0) {
|
||||||
this.showEditText(node)
|
this.showEditText({ node })
|
||||||
this.formatAllText(config)
|
this.formatAllText(config)
|
||||||
this.hideEditText([node])
|
this.hideEditText([node])
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user