Browse Source

Update plugin docs

new-plugin-system
Artur Arseniev 4 months ago
parent
commit
8c45b867cc
  1. 16
      docs/modules/Plugins.md

16
docs/modules/Plugins.md

@ -112,20 +112,20 @@ This is useful when:
const editor = grapesjs.init({
// ...
plugins: [
// Load plugin with id...
{ id: 'my-plugin', plugin: usePlugin(myPlugin, { opt1: 'A' }) }
// Load plugin on init...
{ id: 'my-plugin-1', plugin: usePlugin(myPlugin, { opt1: 'A' }) }
],
});
// ... or add it dynamically
const plugin = editor.Plugins.add({
id: 'my-plugin',
id: 'my-plugin-2',
plugin: usePlugin(myPlugin, { opt1: 'A' }),
});
const hasPlugin = !!editor.Plugins.get('my-plugin');
const hasPlugin = !!editor.Plugins.get('my-plugin-2');
editor.Plugins.getAll();
editor.Plugins.remove('my-plugin');
editor.Plugins.remove('my-plugin-2');
```
GrapesJS stores active plugins inside `editor.Plugins` module, so the plugin can be identified and removed later.
@ -139,12 +139,6 @@ editor.Plugins.add({
});
```
If you don't need the descriptor form, plain plugin functions still work as before.
```ts
editor.Plugins.add(myPlugin);
```
When possible, GrapesJS also tracks editor-level entities added during plugin execution and removes them automatically when the plugin is removed. This currently applies to runtime/editor configuration features such as blocks, component types, keymaps, etc.
The automatic cleanup is intentionally limited to editor-level registrations. It does not remove project data such as pages, components already added to the canvas, or any other persisted content.

Loading…
Cancel
Save