function _ckeditor5_theme_css
Same name in other branches
- 10 core/modules/ckeditor5/ckeditor5.module \_ckeditor5_theme_css()
- 11.x core/modules/ckeditor5/ckeditor5.module \_ckeditor5_theme_css()
Retrieves the default theme's CKEditor 5 stylesheets.
Themes may specify CSS files for use within CKEditor 5 by including a "ckeditor5-stylesheets" key in their .info.yml file.
ckeditor5-stylesheets:
- css/ckeditor.css
Return value
string[] A list of paths to CSS files.
2 calls to _ckeditor5_theme_css()
- CKEditor5StylesheetsTest::testExternalStylesheets in core/
modules/ ckeditor5/ tests/ src/ Kernel/ CKEditor5StylesheetsTest.php - Tests loading of theme's CKEditor 5 stylesheets defined in the .info file.
- ckeditor5_library_info_alter in core/
modules/ ckeditor5/ ckeditor5.module - Implements hook_library_info_alter().
File
-
core/
modules/ ckeditor5/ ckeditor5.module, line 633
Code
function _ckeditor5_theme_css($theme = NULL) : array {
$css = [];
if (!isset($theme)) {
$theme = \Drupal::config('system.theme')->get('default');
}
if (isset($theme) && ($theme_path = \Drupal::service('extension.list.theme')->getPath($theme))) {
$info = \Drupal::service('extension.list.theme')->getExtensionInfo($theme);
if (isset($info['ckeditor5-stylesheets']) && $info['ckeditor5-stylesheets'] !== FALSE) {
$css = $info['ckeditor5-stylesheets'];
foreach ($css as $key => $url) {
// CSS url is external or relative to Drupal root.
if (UrlHelper::isExternal($url) || $url[0] === '/') {
$css[$key] = $url;
}
else {
$css[$key] = '/' . $theme_path . '/' . $url;
}
}
}
if (isset($info['base theme'])) {
$css = array_merge(_ckeditor5_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.