From f33c886d6adba03753e84770b34d36e90800873b 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: Wed, 23 Oct 2024 09:26:25 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=A4=84?= =?UTF-8?q?=E4=BA=8E=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E4=B8=AD=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=E6=97=B6?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=9C=AA=E4=BF=9D=E5=AD=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 9 +++++---- simple-mind-map/src/core/command/Command.js | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 81bd8eb0..946fc500 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -479,15 +479,16 @@ class MindMap { } const isReadonly = mode === CONSTANTS.MODE.READONLY if (isReadonly === this.opt.readonly) return - this.opt.readonly = isReadonly - if (this.opt.readonly) { - // 取消当前激活的元素 - this.execCommand('CLEAR_ACTIVE_NODE') + if (isReadonly) { // 如果处于编辑态,要隐藏所有的编辑框 if (this.renderer.textEdit.isShowTextEdit()) { this.renderer.textEdit.hideEditTextBox() + this.command.originAddHistory() } + // 取消当前激活的元素 + this.execCommand('CLEAR_ACTIVE_NODE') } + this.opt.readonly = isReadonly this.emit('mode_change', mode) } diff --git a/simple-mind-map/src/core/command/Command.js b/simple-mind-map/src/core/command/Command.js index 6f6c1619..3e640a71 100644 --- a/simple-mind-map/src/core/command/Command.js +++ b/simple-mind-map/src/core/command/Command.js @@ -18,6 +18,7 @@ class Command { this.activeHistoryIndex = 0 // 注册快捷键 this.registerShortcutKeys() + this.originAddHistory = this.addHistory.bind(this) this.addHistory = throttle( this.addHistory, this.mindMap.opt.addHistoryTime,