# 模块
<!--
Modules allow Quill's behavior and functionality to be customized.
Several officially supported modules are available to pick and choose from,
some with additional configuration options and APIs.
Refer to their respective 文档 pages for more details.
-->
通过模块可以自定义Quill的行为和功能。官方提供了几个可选模块,其中一些支持附加的设置选项和API。具体详情可参考各自的文档。
<!--
To enable a module, simply include it in Quill's configuration.
-->
只需要在Quill的配置中包含对应模块即可启用。
```javascript
var quill = new Quill('#editor', {
modules: {
'history': { // Enable with custom configurations
'delay': 2500,
'userOnly': true
},
'syntax': true // Enable with default configuration
}
});
```
<!--
The [Clipboard](/docs/modules/clipboard/), [Keyboard](/docs/modules/keyboard/), and [History](/docs/modules/history/)
modules are required by Quill and
do not need to be included explictly,
but may be configured like any other module.
-->
Quill已经内置了[Clipboard](modules/粘贴板clipboard.md)、[Keyboard](modules/键盘keyboard.md)和[History](modules/历史记录history.md)
模块,不需要再显示的包含,但需要像其他模块一样设置。
## 继承
<!--
Modules may also be extended and re-registered, replacing the original module. Even required modules may be re-registered and replaced.
-->
模块可以被继承和重写来替换原来的模块,甚至内置模块也可以被重写和替换。
```javascript
var Clipboard = Quill.import('modules/clipboard');
var Delta = Quill.import('delta');
class PlainClipboard extends Clipboard {
convert(html = null) {
if (typeof html === 'string') {
this.container.innerHTML = html;
}
let text = this.container.innerText;
this.container.innerHTML = '';
return new Delta().insert(text);
}
}
Quill.register('modules/clipboard', PlainClipboard, true);
// Will be created with instance of PlainClipboard
var quill = new Quill('#editor');
```
<!--
*Note: This particular example was selected to show what is possible.
It is often easier to just use an API or configuration the existing module exposes.
In this example, the existing Clipboard's [addMatcher](/docs/modules/clipboard/#addmatcher)
API is suitable for most paste customization scenarios.*
-->
*注意:选择这个示例只是为了展示其用法,使用现有模块的API和配置通常更简单。
在这个示例里面,Clipboard的[addMatcher](modules/粘贴板clipboard.md)接口就能满足大部分自定义粘贴应用场景。*
- 前言
- 快速开始(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
- 更多模块