You are here

public function HTMLRestrictions::toFilterHtmlAllowedTagsString in Drupal 10

Transforms into the Drupal HTML filter's "allowed_html" representation.

Return value

string A string representing the list of allowed elements, structured in the manner expected by the "Limit allowed HTML tags and correct faulty HTML" filter plugin.

See also

\Drupal\filter\Plugin\Filter\FilterHtml

File

core/modules/ckeditor5/src/HTMLRestrictions.php, line 1078

Class

HTMLRestrictions
Represents a set of HTML restrictions.

Namespace

Drupal\ckeditor5

Code

public function toFilterHtmlAllowedTagsString() : string {

  // Resolve wildcard tags, because Drupal's filter_html filter plugin does
  // not support those.
  $concrete = self::resolveWildcards($this);

  // The filter_html plugin does not allow configuring additional globally
  // allowed or disallowed attributes. It uses a hardcoded list.
  $concrete = new HTMLRestrictions(array_diff_key($concrete
    ->getAllowedElements(FALSE), [
    '*' => NULL,
  ]));
  return implode(' ', $concrete
    ->toCKEditor5ElementsArray());
}