You are here

public function Alignment::getElementsSubset in Drupal 10

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php, line 111

Class

Alignment
CKEditor 5 Alignment plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function getElementsSubset() : array {
  $enabled_alignments = $this->configuration['enabled_alignments'];
  $plugin_definition = $this
    ->getPluginDefinition();
  $all_elements = $plugin_definition
    ->getElements();
  $subset = HTMLRestrictions::fromString(implode($all_elements));
  foreach ($plugin_definition
    ->getCKEditor5Config()['alignment']['options'] as $configured_alignment) {
    if (!in_array($configured_alignment['name'], $enabled_alignments, TRUE)) {
      $element_string = '<$text-container class=' . '"' . $configured_alignment["className"] . '"' . '>';
      $subset = $subset
        ->diff(HTMLRestrictions::fromString($element_string));
    }
  }
  return $subset
    ->toCKEditor5ElementsArray();
}