🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] <!-- The History module is responsible for handling undo and redo for Quill. It can be configured with the following options: --> History模块负责处理Quill的撤销和重做,可配置的选项如下: ## 配置 ### delay - 默认值: `1000` <!-- Changes occuring within the `delay` number of milliseconds is merged into a single change. For example, with delay set to `0`, nearly every character is recorded as one change and so undo would undo one character at a time. With delay set to `1000`, undo would undo all changes that occured within the last 1000 milliseconds. --> 把在`delay`毫秒数内的变化合并到单一变化中。举个例子,将延迟设置为0,那么几乎每次输入字符都会被记录成一个变化,然后,撤销动作就会一次撤销一个字符。将延迟设置到`1000`,撤销动作就会撤销在上一个1000毫秒发生的所有变化。 ### maxStack - 默认值: `100` <!-- Maximum size of the history's undo/redo stack. Merged changes with the `delay` option counts as a singular change. --> History模块撤销/重做栈的最大大小。`delay`选项合并的变化计为一个单一变化。 ### userOnly - 默认值: `false` <!-- By default all changes, whether originating from user input or programmatically through the API, are treated the same and change be undone or redone by the history module. If `userOnly` is set to `true`, only user changes will be undone or redone. --> 默认情况下,所有的改变,不管是来自用户的输入还是以编程方式通过API改变,都被处理成一样,通过History模块都可以重做或撤销。如果 `userOnly`被设置成 `true`,只有用户的改变才能被重做或撤销。 ## Example ```javascript var quill = new Quill('#editor', { modules: { history: { delay: 2000, maxStack: 500, userOnly: true } }, theme: 'snow' }); ``` ## API ### clear <!-- Clears the history stack. --> 清空History栈。 **方法** ```js clear() ``` **示例** ```js quill.history.clear(); ``` ### cutoff <span class="experimental">实验</span> <!-- Normally changes made in short succession (configured by `delay`) are merged as a single change, so that triggering an undo will undo multiple changes. Using `cutoff()` will reset the merger window so that a changes before and after `cutoff()` is called will not be merged. --> 正常情况下,在短时间一系列(通过`delay`设置)变化将被合并成一个单一变化,所以,触发撤销将撤销多个改变。使用`cutoff()`将重置合并窗口,在调用`cutoff()`之前或之后的变化不会被合并。 **方法** ```js cutoff() ``` **示例** ```js quill.history.cutoff(); ``` ### undo <!-- Undo last change. --> 撤销上一个改变 **方法** ```js undo() ``` **示例** ```js quill.history.undo(); ``` ### redo <!-- If last change was an undo, redo this undo. Otherwise does nothing. --> 如果上一个变化是撤销,那么重做这个撤销。否则什么也不做。 **方法** ```js redo() ``` **示例** ```js quill.history.redo(); ```