interface CKEditor5PluginManagerInterface implements DiscoveryInterface (View source)

Provides the interface for a plugin manager of CKEditor 5 plugins.

Methods

mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

array
getDefinitions()

Gets the definition of all plugins for this type.

bool
hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

getPlugin(string $plugin_id, EditorInterface|null $editor)

Returns a CKEditor 5 plugin with configuration from the editor.

array
getToolbarItems()

Gets a list of all toolbar items.

array
getAdminLibraries()

Gets a list of all admin library names.

array
getEnabledLibraries(EditorInterface $editor)

Gets a list of libraries required for the editor.

array
getEnabledDefinitions(EditorInterface $editor)

Filter list of definitions by enabled plugins only.

string|null
findPluginSupportingElement(string $tag)

Searches for CKEditor 5 plugin that supports a given tag.

array
getCKEditor5PluginConfig(EditorInterface $editor)

Gets the configuration for the CKEditor 5 plugins enabled in this editor.

array
getProvidedElements(array $plugin_ids = [], EditorInterface $editor = NULL, bool $retain_wildcard = FALSE)

Create a list of elements with attributes declared for the CKEditor5 build.

Details

mixed getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

Parameters

string $plugin_id

A plugin id.

bool $exception_on_invalid

(optional) If TRUE, an invalid plugin ID will throw an exception.

Return Value

mixed

A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is FALSE.

Exceptions

PluginNotFoundException

array getDefinitions()

Gets the definition of all plugins for this type.

Return Value

array

An array of plugin definitions (empty array if no definitions were found). Keys are plugin IDs.

See also

FilteredPluginManagerInterface::getFilteredDefinitions

bool hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

Parameters

string $plugin_id

A plugin ID.

Return Value

bool

TRUE if the definition exists, FALSE otherwise.

CKEditor5PluginInterface getPlugin(string $plugin_id, EditorInterface|null $editor)

Returns a CKEditor 5 plugin with configuration from the editor.

Parameters

string $plugin_id

The plugin ID.

EditorInterface|null $editor

The editor to load configuration from.

Return Value

CKEditor5PluginInterface

The CKEditor 5 plugin instance.

array getToolbarItems()

Gets a list of all toolbar items.

Return Value

array

List of all toolbar items provided by plugins.

array getAdminLibraries()

Gets a list of all admin library names.

Return Value

array

List of all admin libraries provided by plugins.

array getEnabledLibraries(EditorInterface $editor)

Gets a list of libraries required for the editor.

This list is filtered by enabled plugins because it is needed at runtime.

Parameters

EditorInterface $editor

A configured text editor object.

Return Value

array

The list of enabled libraries.

array getEnabledDefinitions(EditorInterface $editor)

Filter list of definitions by enabled plugins only.

Parameters

EditorInterface $editor

A configured text editor object.

Return Value

array

Enabled plugin definitions.

string|null findPluginSupportingElement(string $tag)

Searches for CKEditor 5 plugin that supports a given tag.

Parameters

string $tag

The HTML tag to be searched for within plugin definitions.

Return Value

string|null

The ID of the plugin that supports the given tag.

array getCKEditor5PluginConfig(EditorInterface $editor)

Gets the configuration for the CKEditor 5 plugins enabled in this editor.

Parameters

EditorInterface $editor

A configured text editor object.

Return Value

array

An array with two key-value pairs:

  1. 'plugins' lists all plugins to load
  2. 'config' lists the configuration for all these plugins.

See also

https://ckeditor.com/docs/ckeditor5/latest/api/module_editor-classic_classiceditor-ClassicEditor.html
CKEditor5::getJSSettings

array getProvidedElements(array $plugin_ids = [], EditorInterface $editor = NULL, bool $retain_wildcard = FALSE)

Create a list of elements with attributes declared for the CKEditor5 build.

Parameters

array $plugin_ids

An array of plugin IDs.

EditorInterface $editor

A configured text editor object.

bool $retain_wildcard

If TRUE, the returned array will include config for wildcard elements such as <$block>.

Return Value

array

A nested array with a structure as described in \Drupal\filter\Plugin\FilterInterface::getHTMLRestrictions().

Exceptions

LogicException

See also

FilterInterface::getHTMLRestrictions