function CKEditor5::getJSSettings

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getJSSettings()
  2. 11.x core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getJSSettings()

Overrides EditorPluginInterface::getJSSettings

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.