function SourceEditing::getElementsSubset
Same name in other branches
- 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/SourceEditing.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\SourceEditing::getElementsSubset()
- 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/SourceEditing.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\SourceEditing::getElementsSubset()
Overrides CKEditor5PluginElementsSubsetInterface::getElementsSubset
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ SourceEditing.php, line 70
Class
- SourceEditing
- CKEditor 5 Source Editing plugin configuration.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function getElementsSubset() : array {
// Drupal needs to know which plugin can create a particular <tag>, and not
// just a particular attribute on a tag: <tag attr>.
// SourceEditing enables every tag a plugin lists, even if it's only there
// to add support for an attribute. So, compute a list of only the tags.
// F.e.: <foo attr>, <bar>, <baz bar> would result in <foo>, <bar>, <baz>.
$r = HTMLRestrictions::fromString(implode(' ', $this->configuration['allowed_tags']));
$plain_tags = $r->extractPlainTagsSubset()
->toCKEditor5ElementsArray();
// Return the union of the "tags only" list and the original configuration,
// but omit duplicates (the entries that were already "tags only").
// F.e.: merging the tags only list of <foo>, <bar>, <baz> with the original
// list of <foo attr>, <bar>, <baz bar> would result in <bar> having a
// duplicate.
$subset = array_unique(array_merge($plain_tags, $this->configuration['allowed_tags']));
return $subset;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.