interface EditorPluginInterface implements PluginInspectionInterface, PluginFormInterface (View source)

Defines an interface for configurable text editors.

Modules implementing this interface may want to extend the EditorBase class, which provides default implementations of each method where appropriate.

If the editor's behavior depends on extensive options and/or external data, then the implementing module can choose to provide a separate, global configuration page rather than per-text-format settings. In that case, this form should provide a link to the separate settings page.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

array
buildConfigurationForm(array $form, FormStateInterface $form_state)

Form constructor.

validateConfigurationForm(array $form, FormStateInterface $form_state)

Form validation handler.

submitConfigurationForm(array $form, FormStateInterface $form_state)

Form submission handler.

array
getDefaultSettings()

Returns the default settings for this configurable text editor.

array
getJSSettings(Editor $editor)

Returns JavaScript settings to be attached.

array
getLibraries(Editor $editor)

Returns libraries to be attached.

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

array buildConfigurationForm(array $form, FormStateInterface $form_state)

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and

array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form

An associative array containing the initial structure of the plugin form.

FormStateInterface $form_state

The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return Value

array

The form structure.

validateConfigurationForm(array $form, FormStateInterface $form_state)

Form validation handler.

Parameters

array $form

An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

FormStateInterface $form_state

The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

submitConfigurationForm(array $form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form

An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

FormStateInterface $form_state

The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

array getDefaultSettings()

Returns the default settings for this configurable text editor.

Return Value

array

An array of settings as they would be stored by a configured text editor entity (\Drupal\editor\Entity\Editor).

array getJSSettings(Editor $editor)

Returns JavaScript settings to be attached.

Most text editors use JavaScript to provide a WYSIWYG or toolbar on the client-side interface. This method can be used to convert internal settings of the text editor into JavaScript variables that will be accessible when the text editor is loaded.

Parameters

Editor $editor

A configured text editor object.

Return Value

array

An array of settings that will be added to the page for use by this text editor's JavaScript integration.

See also

AttachmentsResponseProcessorInterface::processAttachments
EditorManager::getAttachments

array getLibraries(Editor $editor)

Returns libraries to be attached.

Because this is a method, plugins can dynamically choose to attach a different library for different configurations, instead of being forced to always use the same method.

Parameters

Editor $editor

A configured text editor object.

Return Value

array

An array of libraries that will be added to the page for use by this text editor.

See also

AttachmentsResponseProcessorInterface::processAttachments
EditorManager::getAttachments