💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 模块 <!-- 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)接口就能满足大部分自定义粘贴应用场景。*