function CKEditor5PluginManager::getCKEditor5PluginConfig

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getCKEditor5PluginConfig()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getCKEditor5PluginConfig()

File

core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php, line 316

Class

CKEditor5PluginManager
Provides a CKEditor 5 plugin manager.

Namespace

Drupal\ckeditor5\Plugin

Code

public function getCKEditor5PluginConfig(EditorInterface $editor) : array {
    $definitions = $this->getEnabledDefinitions($editor);
    // Allow plugin to modify config, such as loading dynamic values.
    $config = [];
    foreach ($definitions as $plugin_id => $definition) {
        $plugin = $this->getPlugin($plugin_id, $editor);
        $config[$plugin_id] = $plugin->getDynamicPluginConfig($definition->getCKEditor5Config(), $editor);
    }
    // CKEditor 5 interprets wildcards from a "CKEditor 5 model element"
    // perspective, Drupal interprets wildcards from a "HTML element"
    // perspective. GHS is used to reconcile those two perspectives, to ensure
    // all expected HTML elements truly are supported.
    // The `ckeditor5_wildcardHtmlSupport` is automatically enabled when
    // necessary, and only when necessary.
    // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getEnabledDefinitions()
    if (isset($definitions['ckeditor5_wildcardHtmlSupport'])) {
        $allowed_elements = new HTMLRestrictions($this->getProvidedElements(array_keys($definitions), $editor, FALSE));
        // Compute the net new elements that the wildcard tags resolve into.
        $concrete_allowed_elements = $allowed_elements->getConcreteSubset();
        $net_new_elements = $allowed_elements->diff($concrete_allowed_elements);
        $config['ckeditor5_wildcardHtmlSupport'] = [
            'htmlSupport' => [
                'allow' => $net_new_elements->toGeneralHtmlSupportConfig(),
            ],
        ];
    }
    return [
        'plugins' => $this->mergeDefinitionValues('getCKEditor5Plugins', $definitions),
        'config' => NestedArray::mergeDeepArray($config),
    ];
}

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