function _ckeditor_theme_css

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/ckeditor.module \_ckeditor_theme_css()

Retrieves the default theme's CKEditor stylesheets.

Themes may specify iframe-specific CSS files for use with CKEditor by including a "ckeditor_stylesheets" key in their .info.yml file.

ckeditor_stylesheets:
-css / ckeditor - iframe . css;
2 calls to _ckeditor_theme_css()
CKEditor::buildContentsCssJSSetting in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
Builds the "contentsCss" configuration part of the CKEditor JS settings.
CKEditorLoadingTest::testExternalStylesheets in core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
Tests loading of theme's CKEditor stylesheets defined in the .info file.

File

core/modules/ckeditor/ckeditor.module, line 82

Code

function _ckeditor_theme_css($theme = NULL) {
    $css = [];
    if (!isset($theme)) {
        $theme = \Drupal::config('system.theme')->get('default');
    }
    if (isset($theme) && ($theme_path = drupal_get_path('theme', $theme))) {
        $info = \Drupal::service('extension.list.theme')->getExtensionInfo($theme);
        if (isset($info['ckeditor_stylesheets'])) {
            $css = $info['ckeditor_stylesheets'];
            foreach ($css as $key => $url) {
                if (UrlHelper::isExternal($url)) {
                    $css[$key] = $url;
                }
                else {
                    $css[$key] = $theme_path . '/' . $url;
                }
            }
        }
        if (isset($info['base theme'])) {
            $css = array_merge(_ckeditor_theme_css($info['base theme']), $css);
        }
    }
    return $css;
}

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