543a112dfb6300c652015fbf77cd0034b1773ae4
[yaffs-website] / web / core / modules / ckeditor / src / CKEditorPluginInterface.php
1 <?php
2
3 namespace Drupal\ckeditor;
4
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\editor\Entity\Editor;
7
8 /**
9  * Defines an interface for (loading of) CKEditor plugins.
10  *
11  * This is the most basic CKEditor plugin interface; it provides the bare
12  * minimum information. Solely implementing this interface is not sufficient to
13  * be able to enable the plugin though — a CKEditor plugin can either be enabled
14  * automatically when a button it provides is present in the toolbar, or when
15  * some programmatically defined condition is true. In the former case,
16  * implement the CKEditorPluginButtonsInterface interface, in the latter case,
17  * implement the CKEditorPluginContextualInterface interface. It is also
18  * possible to implement both, for advanced use cases.
19  *
20  * Finally, if your plugin must be configurable, you can also implement the
21  * CKEditorPluginConfigurableInterface interface.
22  *
23  * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface
24  * @see \Drupal\ckeditor\CKEditorPluginContextualInterface
25  * @see \Drupal\ckeditor\CKEditorPluginConfigurableInterface
26  * @see \Drupal\ckeditor\CKEditorPluginCssInterface
27  * @see \Drupal\ckeditor\CKEditorPluginBase
28  * @see \Drupal\ckeditor\CKEditorPluginManager
29  * @see \Drupal\ckeditor\Annotation\CKEditorPlugin
30  * @see plugin_api
31  */
32 interface CKEditorPluginInterface extends PluginInspectionInterface {
33
34   /**
35    * Indicates if this plugin is part of the optimized CKEditor build.
36    *
37    * Plugins marked as internal are implicitly loaded as part of CKEditor.
38    *
39    * @return bool
40    */
41   public function isInternal();
42
43   /**
44    * Returns a list of plugins this plugin requires.
45    *
46    * @param \Drupal\editor\Entity\Editor $editor
47    *   A configured text editor object.
48    * @return array
49    *   An unindexed array of plugin names this plugin requires. Each plugin is
50    *   is identified by its annotated ID.
51    */
52   public function getDependencies(Editor $editor);
53
54   /**
55    * Returns a list of libraries this plugin requires.
56    *
57    * These libraries will be attached to the text_format element on which the
58    * editor is being loaded.
59    *
60    * @param \Drupal\editor\Entity\Editor $editor
61    *   A configured text editor object.
62    * @return array
63    *   An array of libraries suitable for usage in a render API #attached
64    *   property.
65    */
66   public function getLibraries(Editor $editor);
67
68   /**
69    * Returns the Drupal root-relative file path to the plugin JavaScript file.
70    *
71    * Note: this does not use a Drupal library because this uses CKEditor's API,
72    * see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.resourceManager.html#addExternal.
73    *
74    * @return string|false
75    *   The Drupal root-relative path to the file, FALSE if an internal plugin.
76    */
77   public function getFile();
78
79   /**
80    * Returns the additions to CKEDITOR.config for a specific CKEditor instance.
81    *
82    * The editor's settings can be retrieved via $editor->getSettings(), but be
83    * aware that it may not yet contain plugin-specific settings, because the
84    * user may not yet have configured the form.
85    * If there are plugin-specific settings (verify with isset()), they can be
86    * found at
87    * @code
88    * $settings = $editor->getSettings();
89    * $plugin_specific_settings = $settings['plugins'][$plugin_id];
90    * @endcode
91    *
92    * @param \Drupal\editor\Entity\Editor $editor
93    *   A configured text editor object.
94    * @return array
95    *   A keyed array, whose keys will end up as keys under CKEDITOR.config.
96    */
97   public function getConfig(Editor $editor);
98
99 }