Skip to content

Plugin

The Plugin interface is used to manage a collection of plugins.

Note

The constructor is not directly accessible. Instead, you can access its methods via the Editor.plugin object.

Example:

js
Editor.plugin.add('logger', (editor) => {
  console.log('Logger plugin initialized');
  return () => console.log('Logger plugin unloaded');
});

Instance methods

add()

Registers a plugin using a name as the key.

  • Parameters:

    name

    A string that specifies the name of the plugin to add.

    plugin

    A function for initializing the plugin. This function must match the InitializePlugin type.

  • Return value:

    None.

Example:

js
Editor.plugin.add('myPlugin', (editor) => {
  console.log('myPlugin initialized.');
});

loadAll()

Loads all registered plugins.

  • Parameters:

    editor

    An Editor object where plugins should be loaded.

  • Return value:

    A map containing the names of plugins and their corresponding UnmountPlugin functions that will be used to clean up the plugin.

Example:

js
// Load plugins
const unmountMap = Editor.plugin.loadAll(editor);

// Unmount all loaded plugins
unmountMap.forEach((unmount) => unmount());

Released under the MIT License.