[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
- 更多模塊