1 ckeditor.api.php hook_ckeditor_settings_alter(array &$settings, $format)

Modify the raw CKEditor 4 settings passed to the editor.

This hook can be useful if you have created a CKEditor plugin that needs additional settings passed to it from Backdrop. In particular, because CKEditor loads JavaScript files directly, use of Backdrop.t() in these plugins will not work. You may use this hook to provide translated strings for your plugin.

Parameters

array $settings: The array of settings that will be passed to CKEditor.

$format: The filter format object containing this editor's settings.

Related topics

File

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

Code

function hook_ckeditor_settings_alter(array &$settings, $format) {
  foreach ($format->editor_settings['toolbar'] as $row) {
    foreach ($row as $button_group) {
      // If a particular button is enabled, then add extra settings.
      if (array_key_exists('MyPlugin', $button_group)) {
        // Pull settings from the format and pass to the JavaScript settings.
        $settings['backdrop']['myplugin_settings'] = $format->editor_settings['myplugin_settings'];
        // Translate a string for use by CKEditor.
        $settings['backdrop']['myplugin_help'] = t('A translated string example that will be used by CKEditor.');
      }
    }
  }
}