diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 0050ff1c..d658fc83 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -217,5 +217,7 @@ export const defaultOpt = { defaultGeneralizationText: '概要', // 粘贴文本的方式创建新节点时,控制是否按换行自动分割节点,即如果存在换行,那么会根据换行创建多个节点,否则只会创建一个节点 // 可以传递一个函数,返回promise,resolve代表根据换行分割,reject代表忽略换行 - handleIsSplitByWrapOnPasteCreateNewNode: null + handleIsSplitByWrapOnPasteCreateNewNode: null, + // 多少时间内只允许添加一次历史记录,避免添加没有必要的中间状态,单位:ms + addHistoryTime: 100 } diff --git a/simple-mind-map/src/core/command/Command.js b/simple-mind-map/src/core/command/Command.js index 8b59b98d..d1638dee 100644 --- a/simple-mind-map/src/core/command/Command.js +++ b/simple-mind-map/src/core/command/Command.js @@ -1,4 +1,4 @@ -import { copyRenderTree, simpleDeepClone, nextTick } from '../../utils' +import { copyRenderTree, simpleDeepClone, throttle } from '../../utils' // 命令类 class Command { @@ -11,7 +11,11 @@ class Command { this.activeHistoryIndex = 0 // 注册快捷键 this.registerShortcutKeys() - this.addHistory = nextTick(this.addHistory, this) + this.addHistory = throttle( + this.addHistory, + this.mindMap.opt.addHistoryTime, + this + ) } // 清空历史数据