function HTMLRestrictions::toFilterHtmlAllowedTagsString

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

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 1252

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

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