From 20a8934da9de799e969de7162a87c880482c7396 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Fri, 4 Aug 2023 16:19:08 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=A4=A7?= =?UTF-8?q?=E7=BA=B2=E9=87=8C=E7=82=B9=E5=87=BB=E6=96=87=E5=AD=97=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=E8=BE=93=E5=85=A5=E6=A1=86=E7=84=A6=E7=82=B9?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/TextEdit.js | 14 +++++++++++++- web/src/pages/Edit/components/Outline.vue | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/core/render/TextEdit.js b/simple-mind-map/src/core/render/TextEdit.js index 20eee8eb..7fbf7698 100644 --- a/simple-mind-map/src/core/render/TextEdit.js +++ b/simple-mind-map/src/core/render/TextEdit.js @@ -12,6 +12,8 @@ export default class TextEdit { this.textEditNode = null // 隐藏的文本输入框 this.hiddenInputEl = null + // 节点激活时默认聚焦到隐藏输入框 + this.enableFocus = true // 文本编辑框是否显示 this.showTextEdit = false // 如果编辑过程中缩放画布了,那么缓存当前编辑的内容 @@ -97,7 +99,17 @@ export default class TextEdit { // 让隐藏的文本输入框聚焦 focusHiddenInput() { - if (this.hiddenInputEl) this.hiddenInputEl.focus() + if (this.hiddenInputEl && this.enableFocus) this.hiddenInputEl.focus() + } + + // 关闭默认聚焦 + stopFocusOnNodeActive() { + this.enableFocus = false + } + + // 开启默认聚焦 + openFocusOnNodeActive() { + this.enableFocus = true } // 注册临时快捷键 diff --git a/web/src/pages/Edit/components/Outline.vue b/web/src/pages/Edit/components/Outline.vue index c89d02e7..173f4095 100644 --- a/web/src/pages/Edit/components/Outline.vue +++ b/web/src/pages/Edit/components/Outline.vue @@ -117,7 +117,10 @@ export default { this.notHandleDataChange = true let targetNode = node.data._node if (targetNode && targetNode.nodeData.data.isActive) return - this.mindMap.execCommand('GO_TARGET_NODE', node.data.data.uid) + this.mindMap.renderer.textEdit.stopFocusOnNodeActive() + this.mindMap.execCommand('GO_TARGET_NODE', node.data.data.uid, () => { + this.mindMap.renderer.textEdit.openFocusOnNodeActive() + }) }, } }