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,