You are here

public function CKEditor5::getJSSettings in Drupal 10

File

core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php, line 942

Class

CKEditor5
Defines a CKEditor 5-based text editor for Drupal.

Namespace

Drupal\ckeditor5\Plugin\Editor

Code

public function getJSSettings(Editor $editor) {
  $toolbar_items = $editor
    ->getSettings()['toolbar']['items'];
  $plugin_config = $this->ckeditor5PluginManager
    ->getCKEditor5PluginConfig($editor);
  $settings = [
    'toolbar' => [
      'items' => $toolbar_items,
      'shouldNotGroupWhenFull' => in_array('-', $toolbar_items, TRUE),
    ],
  ] + $plugin_config;
  if ($this->moduleHandler
    ->moduleExists('locale')) {
    $language_interface = $this->languageManager
      ->getCurrentLanguage();
    $settings['language']['ui'] = _ckeditor5_get_langcode_mapping($language_interface
      ->getId());
  }
  return $settings;
}