interface EditorPluginInterface

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.

Hierarchy

Expanded class hierarchy of EditorPluginInterface

All classes that implement EditorPluginInterface

1 file declares its use of EditorPluginInterface
EditorBase.php in drupal/core/modules/editor/lib/Drupal/editor/Plugin/EditorBase.php
Contains \Drupal\editor\Plugin\EditorBase.

File

drupal/core/modules/editor/lib/Drupal/editor/Plugin/EditorPluginInterface.php, line 20
Contains \Drupal\editor\Plugin\EditPluginInterface.

Namespace

Drupal\editor\Plugin
View source
interface EditorPluginInterface extends PluginInspectionInterface {

  /**
   * Returns the default settings for this configurable text editor.
   *
   * @return array
   *   An array of settings as they would be stored by a configured text editor
   *   entity (\Drupal\editor\Plugin\Core\Entity\Editor).
   */
  function getDefaultSettings();

  /**
   * Returns a settings form to configure this text editor.
   *
   * 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.
   *
   * @param array $form
   *   An empty form array to be populated with a configuration form, if any.
   * @param array $form_state
   *   The state of the entire filter administration form.
   * @param \Drupal\editor\Plugin\Core\Entity\Editor $editor
   *   A configured text editor object.
   *
   * @return array
   *   A render array for the settings form.
   */
  function settingsForm(array $form, array &$form_state, Editor $editor);

  /**
   * Validates the settings form for an editor.
   *
   * The contents of the editor settings are located in
   * $form_state['values']['editor']['settings']. Calls to form_error() should
   * reflect this location in the settings form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param array $form_state
   *   A reference to a keyed array containing the current state of the form.
   */
  function settingsFormValidate(array $form, array &$form_state);

  /**
   * Modifies any values in the form state to prepare them for saving.
   *
   * Values in $form_state['values']['editor']['settings'] are saved by Editor
   * module in editor_form_filter_admin_format_submit().
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param array $form_state
   *   A reference to a keyed array containing the current state of the form.
   */
  function settingsFormSubmit(array $form, array &$form_state);

  /**
   * 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.
   *
   * @param \Drupal\editor\Plugin\Core\Entity\Editor $editor
   *   A configured text editor object.
   *
   * @return array
   *   An array of settings that will be added to the page for use by this text
   *   editor's JavaScript integration.
   *
   * @see drupal_process_attached()
   * @see EditorManager::getAttachments()
   */
  function getJSSettings(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.
   *
   * @param \Drupal\editor\Plugin\Core\Entity\Editor $editor
   *   A configured text editor object.
   *
   * @return array
   *   An array of libraries that will be added to the page for use by this
   *   text editor.
   *
   * @see drupal_process_attached()
   * @see EditorManager::getAttachments()
   */
  function getLibraries(Editor $editor);

}

Members

Namesort descending Modifiers Type Description Overrides
EditorPluginInterface::getDefaultSettings function Returns the default settings for this configurable text editor. 1
EditorPluginInterface::getJSSettings function Returns JavaScript settings to be attached. 2
EditorPluginInterface::getLibraries function Returns libraries to be attached. 2
EditorPluginInterface::settingsForm function Returns a settings form to configure this text editor. 1
EditorPluginInterface::settingsFormSubmit function Modifies any values in the form state to prepare them for saving. 1
EditorPluginInterface::settingsFormValidate function Validates the settings form for an editor. 1
PluginInspectionInterface::getPluginDefinition public function Returns the definition of the plugin implementation. 1
PluginInspectionInterface::getPluginId public function Returns the plugin_id of the plugin instance. 1