mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 02:59:01 +08:00
Updated registerPlugin and README with handlePlugins argument.
This commit is contained in:
parent
90f0498265
commit
f9d29865b7
@ -85,7 +85,7 @@ export default {
|
||||
| `setContent` | `content, emitUpdate, parseOptions` | Replace the current content. You can pass an HTML string or a JSON document. `emitUpdate` defaults to `false`. `parseOptions` defaults to those provided in constructor. |
|
||||
| `clearContent` | `emitUpdate` | Clears the current content. `emitUpdate` defaults to `false`. |
|
||||
| `setOptions` | `options` | Overwrites the current editor properties. |
|
||||
| `registerPlugin` | `plugin` | Register a Prosemirror plugin. |
|
||||
| `registerPlugin` | `plugin`, `handlePlugins` | Register a Prosemirror plugin. You can pass a function `handlePlugins` with parameters `(plugin, oldPlugins)` to define an order in which `newPlugins` will be called. `handlePlugins` defaults to pushing `plugin` to front of `oldPlugins`. |
|
||||
| `getJSON` | – | Get the current content as JSON. |
|
||||
| `getHTML` | – | Get the current content as HTML. |
|
||||
| `focus` | – | Focus the editor. |
|
||||
|
@ -487,14 +487,10 @@ export default class Editor extends Emitter {
|
||||
}), {})
|
||||
}
|
||||
|
||||
registerPlugin(plugin = null) {
|
||||
if (!plugin) {
|
||||
return
|
||||
}
|
||||
|
||||
this.plugins.push(plugin);
|
||||
this.state.plugins.splice(this.plugins.length, 0, plugin);
|
||||
const newState = this.state.reconfigure({plugins: this.state.plugins});
|
||||
registerPlugin(plugin = null, handlePlugins) {
|
||||
const plugins = typeof handlePlugins === 'function'
|
||||
? handlePlugins(plugin, this.state.plugins) : [...plugin, this.state.plugins]
|
||||
const newState = this.state.reconfigure({ plugins })
|
||||
this.view.updateState(newState)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user