1 ckeditor5.module _ckeditor5_theme_css($theme = NULL)

Retrieves the default theme's CKEditor stylesheets defined in the .info file.

Themes may specify specific CSS files that will be applied to all pages that contain a CKEditor instance (even on administrative pages), by adding a "ckeditor5_stylesheets" key in the theme .info file.

ckeditor5_stylesheets[] = css/ckeditor5-styles.css

Note that unlike CKEditor 4 that used an iframe, CKEditor 5 includes the editor directly on the page. Styles added by this file may affect other parts of the page. To limit the effect of the CSS to just the CKEditor instance, all CSS selectors within this file should be prefixed with ".ck-content". For example:

.ck-content blockquote {
  border-left: 5px solid #ccc;
}

Parameters

string $theme: The theme name from which the "ckeditor5_stylesheets" property should be read in the .info files. This theme and all its parent themes will be checked. Defaults to the current front-end theme.

Return value

array: An array of all CSS to be added by the theme to the page.

File

core/modules/ckeditor5/ckeditor5.module, line 1368
Provides integration with the CKEditor WYSIWYG editor.

Code

function _ckeditor5_theme_css($theme = NULL) {
  $css = array();
  if (!isset($theme)) {
    $theme = config_get('system.core', 'theme_default');
  }
  if ($theme_path = backdrop_get_path('theme', $theme)) {
    $info = system_get_info('theme', $theme);
    if (isset($info['ckeditor5_stylesheets'])) {
      $css = $info['ckeditor5_stylesheets'];
      foreach ($css as $key => $path) {
        $css[$key] = $theme_path . '/' . $path;
      }
    }
    if (isset($info['base theme'])) {
      $css = array_merge($css, _ckeditor5_theme_css($info['base theme']));
    }
  }
  return $css;
}