You are here

public function Style::getDynamicPluginConfig in Drupal 10

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php, line 166

Class

Style
CKEditor 5 Style plugin configuration.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor) : array {
  $definitions = [];
  foreach ($this->configuration['styles'] as $style) {
    [
      $tag,
      $classes,
    ] = self::getTagAndClasses(HTMLRestrictions::fromString($style['element']));

    // Transform configured styles to the configuration structure expected by
    // the CKEditor 5 Style plugin.
    $definitions[] = [
      'name' => $style['label'],
      'element' => $tag,
      'classes' => $classes,
    ];
  }
  return [
    'style' => [
      'definitions' => $definitions,
    ],
  ];
}