You are here

public function CKEditor::buildContentsCssJSSetting in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::buildContentsCssJSSetting()
  2. 9 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::buildContentsCssJSSetting()

Builds the "contentsCss" configuration part of the CKEditor JS settings.

Parameters

\Drupal\editor\Entity\Editor $editor: A configured text editor object.

Return value

array An array containing the "contentsCss" configuration.

See also

getJSSettings()

File

core/modules/ckeditor/src/Plugin/Editor/CKEditor.php, line 469

Class

CKEditor
Defines a CKEditor-based text editor for Drupal.

Namespace

Drupal\ckeditor\Plugin\Editor

Code

public function buildContentsCssJSSetting(Editor $editor) {
  $css = [
    $this->moduleList
      ->getPath('ckeditor') . '/css/ckeditor-iframe.css',
    $this->moduleList
      ->getPath('system') . '/css/components/align.module.css',
  ];
  $this->moduleHandler
    ->alter('ckeditor_css', $css, $editor);

  // Get a list of all enabled plugins' iframe instance CSS files.
  $plugins_css = array_reduce($this->ckeditorPluginManager
    ->getCssFiles($editor), function ($result, $item) {
    return array_merge($result, array_values($item));
  }, []);
  $css = array_merge($css, $plugins_css);
  $css = array_merge($css, _ckeditor_theme_css());
  $query_string = $this->state
    ->get('system.css_js_query_string', '0');
  $css = array_map(function ($item) use ($query_string) {
    $query_string_separator = strpos($item, '?') !== FALSE ? '&' : '?';
    return $item . $query_string_separator . $query_string;
  }, $css);
  $css = array_map([
    $this->fileUrlGenerator,
    'generateString',
  ], $css);
  return array_values($css);
}