public function CKEditor::getJSSettings in Drupal 10
Same name and namespace in other branches
- 8 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::getJSSettings()
- 9 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::getJSSettings()
File
- core/modules/ckeditor/src/Plugin/Editor/CKEditor.php, line 313
Class
- CKEditor
- Defines a CKEditor-based text editor for Drupal.
Namespace
Drupal\ckeditor\Plugin\Editor
Code
public function getJSSettings(Editor $editor) {
$settings = [];
$enabled_plugins = array_keys($this->ckeditorPluginManager
->getEnabledPluginFiles($editor, TRUE));
foreach ($enabled_plugins as $plugin_id) {
$plugin = $this->ckeditorPluginManager
->createInstance($plugin_id);
$settings += $plugin
->getConfig($editor);
}
$display_langcode = 'en';
if ($this->moduleHandler
->moduleExists('locale')) {
$ckeditor_langcodes = $this
->getLangcodes();
$language_interface = $this->languageManager
->getCurrentLanguage();
if (isset($ckeditor_langcodes[$language_interface
->getId()])) {
$display_langcode = $ckeditor_langcodes[$language_interface
->getId()];
}
}
$external_plugin_files = $this->ckeditorPluginManager
->getEnabledPluginFiles($editor);
$settings += [
'toolbar' => $this
->buildToolbarJSSetting($editor),
'contentsCss' => $this
->buildContentsCssJSSetting($editor),
'extraPlugins' => implode(',', array_keys($external_plugin_files)),
'language' => $display_langcode,
'stylesSet' => FALSE,
];
$settings += [
'drupalExternalPlugins' => array_map([
$this->fileUrlGenerator,
'generateString',
], $external_plugin_files),
];
if ($this->moduleHandler
->moduleExists('locale')) {
locale_js_translate(array_values($external_plugin_files));
}
ksort($settings);
return $settings;
}