if ($editor->
isNew()) { $subset =
[];
} else { throw new \
LogicException(sprintf('The "%s" CKEditor 5 plugin implements ::getElementsSubset() and did not return a subset, the following tags are absent from the plugin definition: "%s".',
$id,
implode(' ',
$not_in_max_supported->
toCKEditor5ElementsArray())));
} } // Also detect what is technically a valid subset, but has lost the
// ability to create tags that are still in the subset. This points to
// a bug in the plugin's ::getElementsSubset() logic.
$defined_creatable = HTMLRestrictions::
fromString(implode($definition->
getCreatableElements()));
$subset_creatable_actual = HTMLRestrictions::
fromString(implode(array_filter($subset,
[CKEditor5PluginDefinition::
class, 'isCreatableElement'
])));
$subset_creatable_needed =
$subset_restrictions->
extractPlainTagsSubset() ->
intersect($defined_creatable);
$missing_creatable_for_subset =
$subset_creatable_needed->
diff($subset_creatable_actual);
if (!
$missing_creatable_for_subset->
allowsNothing()) { throw new \
LogicException(sprintf('The "%s" CKEditor 5 plugin implements ::getElementsSubset() and did return a subset ("%s") but the following tags can no longer be created: "%s".',
$id,
implode($subset_restrictions->
toCKEditor5ElementsArray()),
implode($missing_creatable_for_subset->
toCKEditor5ElementsArray())));
} $defined_elements =
$subset;
} }