3 namespace Drupal\ckeditor;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\editor\Entity\Editor;
9 * Defines an interface for (loading of) CKEditor plugins.
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.
20 * Finally, if your plugin must be configurable, you can also implement the
21 * CKEditorPluginConfigurableInterface interface.
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
32 interface CKEditorPluginInterface extends PluginInspectionInterface {
35 * Indicates if this plugin is part of the optimized CKEditor build.
37 * Plugins marked as internal are implicitly loaded as part of CKEditor.
41 public function isInternal();
44 * Returns a list of plugins this plugin requires.
46 * @param \Drupal\editor\Entity\Editor $editor
47 * A configured text editor object.
49 * An unindexed array of plugin names this plugin requires. Each plugin is
50 * is identified by its annotated ID.
52 public function getDependencies(Editor $editor);
55 * Returns a list of libraries this plugin requires.
57 * These libraries will be attached to the text_format element on which the
58 * editor is being loaded.
60 * @param \Drupal\editor\Entity\Editor $editor
61 * A configured text editor object.
63 * An array of libraries suitable for usage in a render API #attached
66 public function getLibraries(Editor $editor);
69 * Returns the Drupal root-relative file path to the plugin JavaScript file.
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.
74 * @return string|false
75 * The Drupal root-relative path to the file, FALSE if an internal plugin.
77 public function getFile();
80 * Returns the additions to CKEDITOR.config for a specific CKEditor instance.
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
88 * $settings = $editor->getSettings();
89 * $plugin_specific_settings = $settings['plugins'][$plugin_id];
92 * @param \Drupal\editor\Entity\Editor $editor
93 * A configured text editor object.
95 * A keyed array, whose keys will end up as keys under CKEDITOR.config.
97 public function getConfig(Editor $editor);