docs: update plugin markdown
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
# Custom Plugin
|
||||
|
||||
::: tip
|
||||
1. Currently, only methods can be added and modified to the editor instance, and more functions will be extended in the future
|
||||
2. Official maintenance plugin: https://github.com/Hufe921/canvas-editor-plugin
|
||||
Official plugin: https://github.com/Hufe921/canvas-editor-plugin
|
||||
:::
|
||||
|
||||
## Write a Plugin
|
||||
@@ -14,6 +13,8 @@ export function myPlugin(editor: Editor, options?: Option) {
|
||||
|
||||
// 2. add,see more:src/plugins/markdown
|
||||
editor.command.addFunction = () => {}
|
||||
|
||||
// 3. listener, eventbus, shortcut, contextmenu, override...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# Official plugin
|
||||
|
||||
::: tip
|
||||
Official plugin: https://github.com/Hufe921/canvas-editor-plugin
|
||||
:::
|
||||
|
||||
## Barcode1d
|
||||
|
||||
```javascript
|
||||
import Editor from "@hufe921/canvas-editor"
|
||||
import barcode1DPlugin from "@hufe921/canvas-editor-plugin-barcode1d"
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(barcode1DPlugin)
|
||||
|
||||
instance.executeInsertBarcode1D(
|
||||
content: string,
|
||||
width: number,
|
||||
height: number,
|
||||
options?: JsBarcode.Options
|
||||
)
|
||||
```
|
||||
|
||||
## Barcode2d
|
||||
|
||||
```javascript
|
||||
import Editor from "@hufe921/canvas-editor"
|
||||
import barcode2DPlugin from "@hufe921/canvas-editor-plugin-barcode2d"
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(barcode2DPlugin, options?: IBarcode2DOption)
|
||||
|
||||
instance.executeInsertBarcode2D(
|
||||
content: string,
|
||||
width: number,
|
||||
height: number,
|
||||
hints?: Map<EncodeHintType, any>
|
||||
)
|
||||
```
|
||||
|
||||
## Code block
|
||||
|
||||
```javascript
|
||||
import Editor from "@hufe921/canvas-editor"
|
||||
import codeblockPlugin from "@hufe921/canvas-editor-plugin-codeblock"
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(codeblockPlugin)
|
||||
|
||||
instance.executeInsertCodeblock(content: string)
|
||||
```
|
||||
|
||||
## Word
|
||||
|
||||
```javascript
|
||||
import Editor from '@hufe921/canvas-editor'
|
||||
import docxPlugin from '@hufe921/canvas-editor-plugin-docx'
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(docxPlugin)
|
||||
|
||||
command.executeImportDocx({
|
||||
arrayBuffer: buffer
|
||||
})
|
||||
|
||||
instance.executeExportDocx({
|
||||
fileName: string
|
||||
})
|
||||
```
|
||||
|
||||
## Excel
|
||||
|
||||
```javascript
|
||||
import Editor from '@hufe921/canvas-editor'
|
||||
import excelPlugin from '@hufe921/canvas-editor-plugin-excel'
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(excelPlugin)
|
||||
|
||||
command.executeImportExcel({
|
||||
arrayBuffer: buffer
|
||||
})
|
||||
```
|
||||
|
||||
## Floating toolbar
|
||||
|
||||
```javascript
|
||||
import Editor from '@hufe921/canvas-editor'
|
||||
import floatingToolbarPlugin from '@hufe921/canvas-editor-plugin-floating-toolbar'
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(floatingToolbarPlugin)
|
||||
```
|
||||
|
||||
## Diagram
|
||||
|
||||
```javascript
|
||||
import Editor from '@hufe921/canvas-editor'
|
||||
import diagramPlugin from '@hufe921/canvas-editor-plugin-diagram'
|
||||
|
||||
const instance = new Editor()
|
||||
instance.use(diagramPlugin)
|
||||
|
||||
command.executeLoadDiagram({
|
||||
lang?: Lang
|
||||
data?: string
|
||||
onDestroy?: (message?: any) => void
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user