Your own plugin

A minimal API 1 command with managed resources.

1.0.0-beta.6 · Local build · desktop

Plugin descriptor

Provide a unique id, plugin version and apiVersion: 1. setup receives the managed public context. Register commands/events/UI through that context rather than touching the editor engine or internal DOM. Duplicate IDs or unavailable plugins are rejected.

Synchronous setup

Install resources synchronously and return cleanup for external work that you own. The host also revokes managed subscriptions, commands, forms and status when a plugin is removed or the editor is destroyed. Failed setup releases already installed resources.

Document operations

Use the checked public operations and revision-bearing ranges. Avoid silently applying an asynchronous result to a newer document. Plain text replacement is not HTML import; transformations preserve marks and a single undo operation.

Integration

usePlugin returns a disposer. executePluginCommand invokes your registered command. removePlugin provides an alternate cleanup path. Test installation, command behavior, removal and destroy. Plugin contract, methods.

import { PLUGIN_API_VERSION } from '@vitext-ru/editor';
const remove = editor.usePlugin({
  id: 'my-format', version: '1.0.0', apiVersion: PLUGIN_API_VERSION,
  setup(api) {
    api.registerCommand('bold', () => api.execute('bold'));
    api.on('change', event => console.log(event.revision));
    return () => { /* освободите собственные таймеры */ };
  }
});
editor.executePluginCommand('my-format', 'bold');
remove();

Search documentation

No results. Try different words.

All documentation