3 namespace Drupal\editor\Plugin;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Core\Plugin\PluginFormInterface;
7 use Drupal\editor\Entity\Editor;
10 * Defines an interface for configurable text editors.
12 * Modules implementing this interface may want to extend the EditorBase class,
13 * which provides default implementations of each method where appropriate.
15 * If the editor's behavior depends on extensive options and/or external data,
16 * then the implementing module can choose to provide a separate, global
17 * configuration page rather than per-text-format settings. In that case, this
18 * form should provide a link to the separate settings page.
20 * @see \Drupal\editor\Annotation\Editor
21 * @see \Drupal\editor\Plugin\EditorBase
22 * @see \Drupal\editor\Plugin\EditorManager
25 interface EditorPluginInterface extends PluginInspectionInterface, PluginFormInterface {
28 * Returns the default settings for this configurable text editor.
31 * An array of settings as they would be stored by a configured text editor
32 * entity (\Drupal\editor\Entity\Editor).
34 public function getDefaultSettings();
37 * Returns JavaScript settings to be attached.
39 * Most text editors use JavaScript to provide a WYSIWYG or toolbar on the
40 * client-side interface. This method can be used to convert internal settings
41 * of the text editor into JavaScript variables that will be accessible when
42 * the text editor is loaded.
44 * @param \Drupal\editor\Entity\Editor $editor
45 * A configured text editor object.
48 * An array of settings that will be added to the page for use by this text
49 * editor's JavaScript integration.
51 * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
52 * @see EditorManager::getAttachments()
54 public function getJSSettings(Editor $editor);
57 * Returns libraries to be attached.
59 * Because this is a method, plugins can dynamically choose to attach a
60 * different library for different configurations, instead of being forced to
61 * always use the same method.
63 * @param \Drupal\editor\Entity\Editor $editor
64 * A configured text editor object.
67 * An array of libraries that will be added to the page for use by this text
70 * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
71 * @see EditorManager::getAttachments()
73 public function getLibraries(Editor $editor);