function CKEditor::buildContentsCssJSSetting

Same name in other branches
  1. 8.9.x 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()

1 call to CKEditor::buildContentsCssJSSetting()
CKEditor::getJSSettings in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
Returns JavaScript settings to be attached.

File

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

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.