You are here

function hook_ckeditor_css_alter in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/ckeditor.api.php \hook_ckeditor_css_alter()

Modify the list of CSS files that will be added to a CKEditor instance.

Modules may use this hook to provide their own custom CSS file without providing a CKEditor plugin. This list of CSS files is only used in the iframe versions of CKEditor.

Front-end themes (and base themes) can easily specify CSS files to be used in iframe instances of CKEditor through an entry in their .info.yml file:

ckeditor_stylesheets:
-css / ckeditor - iframe . css;

Parameters

array &$css: An array of CSS files, passed by reference. This is a flat list of file paths which can be either relative to the Drupal root or external URLs.

$editor: The text editor object as returned by editor_load(), for which these files are being loaded. Based on this information, it is possible to load the corresponding text format object.

See also

_ckeditor_theme_css()

Related topics

2 functions implement hook_ckeditor_css_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ckeditor_ckeditor_css_alter in core/modules/ckeditor/ckeditor.module
Implements hook_ckeditor_css_alter().
ckeditor_test_ckeditor_css_alter in core/modules/ckeditor/tests/modules/ckeditor_test.module
Implements hook_ckeditor_css_alter().
1 invocation of hook_ckeditor_css_alter()
CKEditor::buildContentsCssJSSetting in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
Builds the "contentsCss" configuration part of the CKEditor JS settings.

File

core/modules/ckeditor/ckeditor.api.php, line 55
Documentation for CKEditor module APIs.

Code

function hook_ckeditor_css_alter(array &$css, Editor $editor) {
  $css[] = drupal_get_path('module', 'mymodule') . '/css/mymodule-ckeditor.css';
}