Version 1
[yaffs-website] / web / core / modules / editor / src / Plugin / EditorPluginInterface.php
1 <?php
2
3 namespace Drupal\editor\Plugin;
4
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Core\Plugin\PluginFormInterface;
7 use Drupal\editor\Entity\Editor;
8
9 /**
10  * Defines an interface for configurable text editors.
11  *
12  * Modules implementing this interface may want to extend the EditorBase class,
13  * which provides default implementations of each method where appropriate.
14  *
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.
19  *
20  * @see \Drupal\editor\Annotation\Editor
21  * @see \Drupal\editor\Plugin\EditorBase
22  * @see \Drupal\editor\Plugin\EditorManager
23  * @see plugin_api
24  */
25 interface EditorPluginInterface extends PluginInspectionInterface, PluginFormInterface {
26
27   /**
28    * Returns the default settings for this configurable text editor.
29    *
30    * @return array
31    *   An array of settings as they would be stored by a configured text editor
32    *   entity (\Drupal\editor\Entity\Editor).
33    */
34   public function getDefaultSettings();
35
36   /**
37    * Returns JavaScript settings to be attached.
38    *
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.
43    *
44    * @param \Drupal\editor\Entity\Editor $editor
45    *   A configured text editor object.
46    *
47    * @return array
48    *   An array of settings that will be added to the page for use by this text
49    *   editor's JavaScript integration.
50    *
51    * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
52    * @see EditorManager::getAttachments()
53    */
54   public function getJSSettings(Editor $editor);
55
56   /**
57    * Returns libraries to be attached.
58    *
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.
62    *
63    * @param \Drupal\editor\Entity\Editor $editor
64    *   A configured text editor object.
65    *
66    * @return array
67    *   An array of libraries that will be added to the page for use by this text
68    *   editor.
69    *
70    * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
71    * @see EditorManager::getAttachments()
72    */
73   public function getLibraries(Editor $editor);
74
75 }