public function CKEditor::getJSSettings

Implements \Drupal\editor\Plugin\EditPluginInterface::getJSSettings().

Overrides EditorPluginInterface::getJSSettings

File

drupal/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php, line 113
Contains \Drupal\ckeditor\Plugin\Editor\CKEditor.

Class

CKEditor
Defines a CKEditor-based text editor for Drupal.

Namespace

Drupal\ckeditor\Plugin\Editor

Code

public function getJSSettings(EditorEntity $editor) {
  $language_interface = language(Language::TYPE_INTERFACE);
  $settings = array();
  $manager = drupal_container()
    ->get('plugin.manager.ckeditor.plugin');

  // Get the settings for all enabled plugins, even the internal ones.
  $enabled_plugins = array_keys($manager
    ->getEnabledPlugins($editor, TRUE));
  foreach ($enabled_plugins as $plugin_id) {
    $plugin = $manager
      ->createInstance($plugin_id);
    $settings += $plugin
      ->getConfig($editor);
  }

  // Next, set the most fundamental CKEditor settings.
  $external_plugins = $manager
    ->getEnabledPlugins($editor);
  $settings += array(
    'toolbar' => $this
      ->buildToolbarJSSetting($editor),
    'contentsCss' => $this
      ->buildContentsCssJSSetting($editor),
    'extraPlugins' => implode(',', array_keys($external_plugins)),
    'language' => $language_interface->langcode,
    // Configure CKEditor to not load styles.js. The StylesCombo plugin will
    // set stylesSet according to the user's settings, if the "Styles" button
    // is enabled. We cannot get rid of this until CKEditor will stop loading
    // styles.js by default.
    // See http://dev.ckeditor.com/ticket/9992#comment:9.
    'stylesSet' => FALSE,
  );

  // Finally, set Drupal-specific CKEditor settings.
  $settings += array(
    'drupalExternalPlugins' => array_map('file_create_url', $external_plugins),
  );
  return $settings;
}