Trilium Frontend API
    Preparing search index...

    Interface PluginInterface

    The base interface for CKEditor plugins.

    In its minimal form a plugin can be a simple function that accepts module:core/editor/editor~Editor the editor as a parameter:

    // A simple plugin that enables a data processor.
    function MyPlugin( editor ) {
    editor.data.processor = new MyDataProcessor();
    }

    In most cases however, you will want to inherit from the ~Plugin class which implements the module:utils/observablemixin~Observable and is, therefore, more convenient:

    class MyPlugin extends Plugin {
    init() {
    // `listenTo()` and `editor` are available thanks to `Plugin`.
    // By using `listenTo()` you will ensure that the listener is removed when
    // the plugin is destroyed.
    this.listenTo( this.editor.data, 'ready', () => {
    // Do something when the data is ready.
    } );
    }
    }

    The plugin class can have pluginName and requires static members. See ~PluginStaticMembers for more details.

    The plugin can also implement methods (e.g. ~PluginInterface#init init() or ~PluginInterface#destroy destroy()) which, when present, will be used to properly initialize and destroy the plugin.

    Note: When defined as a plain function, the plugin acts as a constructor and will be called in parallel with other plugins' ~PluginConstructor constructors. This means the code of that plugin will be executed before ~PluginInterface#init init() and ~PluginInterface#afterInit afterInit() methods of other plugins and, for instance, you cannot use it to extend other plugins' {@glink framework/architecture/editing-engine#schema schema} rules as they are defined later on during the init() stage.

    interface PluginInterface {
        afterInit?(): void | Promise<unknown>;
        destroy?(): void | Promise<unknown>;
        init?(): void | Promise<unknown>;
    }

    Implemented by

    Index

    Methods

    • The third (and last) stage of the plugin initialization. See also ~PluginConstructor and ~PluginInterface#init.

      Note: This method is optional. A plugin instance does not need to have it defined.

      Returns void | Promise<unknown>

    • Destroys the plugin.

      Note: This method is optional. A plugin instance does not need to have it defined.

      Returns void | Promise<unknown>

    • The second stage (after plugin constructor) of the plugin initialization. Unlike the plugin constructor this method can be asynchronous.

      A plugin's init() method is called after its ~PluginStaticMembers#requires dependencies are initialized, so in the same order as the constructors of these plugins.

      Note: This method is optional. A plugin instance does not need to have it defined.

      Returns void | Promise<unknown>