Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::getElementsSubset()

Returns a configured subset of the elements supported by this plugin.

Return value

string[] An array of supported elements.

Overrides CKEditor5PluginElementsSubsetInterface::getElementsSubset

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