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