diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 3e62e34..f324655 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -55,6 +55,13 @@ function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) { if (!$editor->hasAssociatedFilterFormat()) { return; } + + // Add the filter caption CSS if the text format associated with this text + // editor uses the filter_caption filter. This is used by the included + // CKEditor DrupalImageCaption plugin. + if ($editor->getFilterFormat()->filters('filter_caption')->status) { + $css[] = drupal_get_path('module', 'filter') . '/css/filter.caption.css'; + } } /** diff --git a/core/modules/ckeditor/src/CKEditorPluginButtonsInterface.php b/core/modules/ckeditor/src/CKEditorPluginButtonsInterface.php index 494e345..85586f3 100644 --- a/core/modules/ckeditor/src/CKEditorPluginButtonsInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginButtonsInterface.php @@ -23,6 +23,7 @@ * @see \Drupal\ckeditor\CKEditorPluginInterface * @see \Drupal\ckeditor\CKEditorPluginContextualInterface * @see \Drupal\ckeditor\CKEditorPluginConfigurableInterface + * @see \Drupal\ckeditor\CKEditorPluginCssInterface * @see \Drupal\ckeditor\CKEditorPluginBase * @see \Drupal\ckeditor\CKEditorPluginManager * @see \Drupal\ckeditor\Annotation\CKEditorPlugin diff --git a/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php b/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php index a5084fd..f6d46ce 100644 --- a/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php @@ -20,6 +20,7 @@ * @see \Drupal\ckeditor\CKEditorPluginInterface * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface * @see \Drupal\ckeditor\CKEditorPluginContextualInterface + * @see \Drupal\ckeditor\CKEditorPluginCssInterface * @see \Drupal\ckeditor\CKEditorPluginBase * @see \Drupal\ckeditor\CKEditorPluginManager * @see \Drupal\ckeditor\Annotation\CKEditorPlugin diff --git a/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php b/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php index 5bd397f..82354e4 100644 --- a/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php @@ -24,6 +24,7 @@ * @see \Drupal\ckeditor\CKEditorPluginInterface * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface * @see \Drupal\ckeditor\CKEditorPluginConfigurableInterface + * @see \Drupal\ckeditor\CKEditorPluginCssInterface * @see \Drupal\ckeditor\CKEditorPluginBase * @see \Drupal\ckeditor\CKEditorPluginManager * @see \Drupal\ckeditor\Annotation\CKEditorPlugin diff --git a/core/modules/ckeditor/src/CKEditorPluginCssInterface.php b/core/modules/ckeditor/src/CKEditorPluginCssInterface.php index dbcece8..620b54f 100644 --- a/core/modules/ckeditor/src/CKEditorPluginCssInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginCssInterface.php @@ -10,12 +10,11 @@ use Drupal\editor\Entity\Editor; /** - * Defines an interface to allow CKEditor plugins to add additional CSS to iframe - * CKEditor instances. + * Defines an interface for CKEditor plugins with associated CSS. * - * This allows a CKEditor plugin to add additional CSS to iframe CKEditor - * instances without the need to implement hook_ckeditor_css_alter() in order - * to do so. + * This allows a CKEditor plugin to add additional CSS in iframe CKEditor + * instances without the needing to implement hook_ckeditor_css_alter() + * in order to do so. * * @see \Drupal\ckeditor\CKEditorPluginInterface * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface diff --git a/core/modules/ckeditor/src/CKEditorPluginInterface.php b/core/modules/ckeditor/src/CKEditorPluginInterface.php index ef0acd4..3a0a6d8 100644 --- a/core/modules/ckeditor/src/CKEditorPluginInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginInterface.php @@ -28,6 +28,7 @@ * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface * @see \Drupal\ckeditor\CKEditorPluginContextualInterface * @see \Drupal\ckeditor\CKEditorPluginConfigurableInterface + * @see \Drupal\ckeditor\CKEditorPluginCssInterface * @see \Drupal\ckeditor\CKEditorPluginBase * @see \Drupal\ckeditor\CKEditorPluginManager * @see \Drupal\ckeditor\Annotation\CKEditorPlugin diff --git a/core/modules/ckeditor/src/CKEditorPluginManager.php b/core/modules/ckeditor/src/CKEditorPluginManager.php index 5741ed1..7141fd8 100644 --- a/core/modules/ckeditor/src/CKEditorPluginManager.php +++ b/core/modules/ckeditor/src/CKEditorPluginManager.php @@ -186,6 +186,9 @@ public function injectPluginSettingsForm(array &$form, FormStateInterface $form_ /** * Retrieves all additional CKEditor CSS files, keyed by plugin ID. * + * @param \Drupal\editor\Entity\Editor $editor + * A configured text editor object. + * * @return array * All available CKEditor CSS files, with plugin IDs as keys and * CSS file paths relative to the Drupal root (as implemented by @@ -193,11 +196,11 @@ public function injectPluginSettingsForm(array &$form, FormStateInterface $form_ * * @see CKEditorPluginCssInterface::getCssFiles() */ - public function getCssFiles() { - $plugins = array_keys($this->getDefinitions()); + public function getCssFiles(Editor $editor) { + $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor, TRUE)); $css_files = array(); - foreach ($plugins as $plugin_id) { + foreach ($enabled_plugins as $plugin_id) { $plugin = $this->createInstance($plugin_id); if ($plugin instanceof CKEditorPluginCssInterface) { $css_files[$plugin_id] = $plugin->getCssFiles(); diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php index 64d4fd6..4f9b0bb 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php @@ -74,24 +74,12 @@ public function getConfig(Editor $editor) { * {@inheritdoc} */ public function getCssFiles(Editor $editor) { - $css = array(); - - // Add the filter caption CSS if the text format associated with this text - // editor uses the filter_caption filter. This is used by the included - // CKEditor DrupalImageCaption plugin. - $format = $editor->getFilterFormat(); - if ($format->filters('filter_caption')->status) { - $css[] = drupal_get_path('module', 'filter') . '/css/filter.caption.css'; - } - // Add the filter caption CSS if the text format associated with this text // editor uses the filter_align filter. This is used by the included // CKEditor DrupalImageCaption plugin. - if ($format->filters('filter_align')->status) { - $css[] = drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css'; - } - - return $css; + return array( + drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css' + ); } /**