[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();
```
- 前言
- 快速开始(quick_start)
- 下载(download)
- 配置(configuration)
- 格式(formats)
- API
- 内容(contents)
- 格式化(formatting)
- 选区(selection)
- 编辑器(editor)
- 事件(events)
- 模型(model)
- 扩展(extension)
- 增量(Delta)
- 模块(modules)
- 工具栏(toolbar)
- 键盘(keyboard)
- 历史记录(history)
- 粘贴板(clipboard)
- 语法高亮(syntax)
- 主题(themes)
- 更多教程
- 为什么选择Quill?
- 如何定制Quill?
- 设计Delta格式(未翻译)
- 构建一个自定义模块
- 将Quill加入你的编译管线(未翻译)
- Cloning Medium with Parchment
- 和其它富文本编辑器的对比(未翻译)
- Designing the Delta Format
- 扩展模块
- vue-quill-editor
- quill-image-extend-module
- quill-image-resize-module
- quill-image-drop-module
- quill-better-table
- quilljs-table
- 更多模块