Trilium Frontend API
    Preparing search index...

    Class PluginCollection<TContext>

    Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.

    Type Parameters

    • TContext extends object

    Hierarchy (View Summary)

    Implements

    Index
    • Creates an instance of the plugin collection class. Allows loading and initializing plugins and their dependencies. Allows providing a list of already loaded plugins. These plugins will not be destroyed along with this collection.

      Type Parameters

      • TContext extends object

      Parameters

      • context: TContext
      • OptionalavailablePlugins: Iterable<PluginConstructor<TContext>>

        Plugins (constructors) which the collection will be able to use when module:core/plugincollection~PluginCollection#init is used with the plugin names (strings, instead of constructors). Usually, the editor will pass its built-in plugins to the collection so they can later be used in config.plugins or config.removePlugins by names.

      • OptionalcontextPlugins: Iterable<PluginEntry<TContext>>

        A list of already initialized plugins represented by a [ PluginConstructor, pluginInstance ] pair.

      Returns PluginCollection<TContext>

    • Destroys all loaded plugins.

      Returns Promise<unknown>

    • Checks if a plugin is loaded.

      // Check if the 'Clipboard' plugin was loaded.
      if ( editor.plugins.has( 'ClipboardPipeline' ) ) {
      // Now use the clipboard plugin instance:
      const clipboard = editor.plugins.get( 'ClipboardPipeline' );

      // ...
      }

      Parameters

      • key: string | PluginConstructor<TContext>

        The plugin constructor or module:core/plugin~PluginStaticMembers#pluginName name.

      Returns boolean

    • Initializes a set of plugins and adds them to the collection.

      Parameters

      • plugins: readonly (string | PluginConstructor<TContext>)[]

        An array of module:core/plugin~PluginInterface plugin constructors or module:core/plugin~PluginStaticMembers#pluginName plugin names.

      • OptionalpluginsToRemove: readonly (string | PluginConstructor<TContext>)[]

        Names of the plugins or plugin constructors that should not be loaded (despite being specified in the plugins array).

      • OptionalpluginsSubstitutions: readonly PluginConstructor<TContext>[]

        An array of module:core/plugin~PluginInterface plugin constructors that will be used to replace plugins of the same names that were passed in plugins or that are in their dependency tree. A useful option for replacing built-in plugins while creating tests (for mocking their APIs). Plugins that will be replaced must follow these rules:

        • The new plugin must be a class.
        • The new plugin must be named.
        • Both plugins must not depend on other plugins.

      Returns Promise<LoadedPlugins>

      A promise which gets resolved once all plugins are loaded and available in the collection.