by-onlineeditor/docs/guide/plugin-custom.md

26 lines
547 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 自定义插件
::: tip
官方维护插件仓库https://github.com/Hufe921/canvas-editor-plugin
:::
## 开发插件
```javascript
export function myPlugin(editor: Editor, options?: Option) {
// 1. 修改方法详见src/plugins/copy
editor.command.updateFunction = () => {}
// 2. 增加方法详见src/plugins/markdown
editor.command.addFunction = () => {}
// 3. 事件监听、快捷键、右键菜单、重写方法等组合处理
}
```
## 使用插件
```javascript
instance.use(myPlugin, options?: Option)
```