From b950c2bfe956ad0568bed4ca94bd4726816ae930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Mon, 18 Dec 2023 09:12:04 +0800 Subject: [PATCH] =?UTF-8?q?textEdit=E7=B1=BB=E5=A2=9E=E5=8A=A0isShowTextEd?= =?UTF-8?q?it=E6=96=B9=E6=B3=95=E5=88=A4=E6=96=AD=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=A4=84=E5=9C=A8=E8=8A=82=E7=82=B9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/command/KeyCommand.js | 9 +++------ simple-mind-map/src/core/render/Render.js | 3 --- simple-mind-map/src/core/render/TextEdit.js | 8 ++++++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/simple-mind-map/src/core/command/KeyCommand.js b/simple-mind-map/src/core/command/KeyCommand.js index 331c4a2d..32ec181a 100644 --- a/simple-mind-map/src/core/command/KeyCommand.js +++ b/simple-mind-map/src/core/command/KeyCommand.js @@ -44,13 +44,10 @@ export default class KeyCommand { this.isInSvg = true }) this.mindMap.on('svg_mouseleave', () => { - if (this.mindMap.richText && this.mindMap.richText.showTextEdit) { - return - } + if (this.mindMap.renderer.textEdit.isShowTextEdit()) return if ( - this.mindMap.renderer.textEdit.showTextEdit || - (this.mindMap.associativeLine && - this.mindMap.associativeLine.showTextEdit) + this.mindMap.associativeLine && + this.mindMap.associativeLine.showTextEdit ) { return } diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 5fafa7b1..54aa33bb 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -276,9 +276,6 @@ class Render { }) // 插入同级节点 this.mindMap.keyCommand.addShortcut('Enter', () => { - if (this.textEdit.showTextEdit) { - return - } this.mindMap.execCommand('INSERT_NODE') }) // 插入父节点 diff --git a/simple-mind-map/src/core/render/TextEdit.js b/simple-mind-map/src/core/render/TextEdit.js index 9641716c..7fc1b1dd 100644 --- a/simple-mind-map/src/core/render/TextEdit.js +++ b/simple-mind-map/src/core/render/TextEdit.js @@ -126,6 +126,14 @@ export default class TextEdit { }) } + // 获取当前文本编辑框是否处于显示状态,也就是是否处在文本编辑状态 + isShowTextEdit() { + if (this.mindMap.richText) { + return this.mindMap.richText.showTextEdit + } + return this.showTextEdit + } + // 显示文本编辑框 // isInserting:是否是刚创建的节点 // isFromKeyDown:是否是在按键事件进入的编辑