Problem/Motivation
When modifying "Manually editable HTML tags", there is an error message said
The following attribute(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: .
The supported attribute's name is missing from the error message.
An expected error message is supported to provide the specific attribute name that is overlapped with plugins. Such as,
The following attribute(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Alignment (
<p class="text-align-center">).
Steps to reproduce
- Login in as an admin user.
- Create a text format using CKEditor 5 with Source editing plugin and Text alignment plugin.
- In the 'Manually editable HTML tags' text box, add the following tags and attributes.
<p class="text-align-center"> - Save the text format without any changes.
- The error occured.
Proposed resolution
I believe this bug is caused by Drupal\ckeditor5\HTMLRestrictions::applyOperation() function.
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/ckedi...
As the function description suggested, it is supposed to support wildcard within an element name. Therefore, the wildcard $text-container should be resolved into a concrete tag, so that the Alignment plugin should be chosen in the error message, for example. But actually the result is opposite.
Actually this function doesn't resolve the wildcard tag for some plugins, such as the Alignment plugin.
At line 1143, the comment inside the function resolveWildcards() suggest that,
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/ckedi...
// Do not resolve to all tags supported by the wildcard tag, but only
// those which are explicitly supported. Because wildcard tags only
// allow declaring support for additional attributes and attribute
// values on already supported tags.
But the problem is that, the Alignment plugin only has a wildcard tag of '$text-container' , nothing else. So this logic won't work for this plugin or any other plugin which only has wildcard tags.
So if the logic is changed to
// Do not resolve to all tags supported by the wildcard tag, but only
// those which are explicitly supported by this set of restrictions
// or specified in the $supported_wildcard_tags array.
// Because wildcard tags only
// allow declaring support for additional attributes and attribute
// values on already supported tags.
if (isset($r->elements[$wildcard_tag]) || isset($supported_wildcard_tags[$wildcard_tag])) {
$naively_resolved_wildcard_elements[$wildcard_tag] = $tag_config;
}
It will work for all plugins.
Remaining tasks
PHPUnit test to reproduce this issue.Merge requests to fix this issue.
User interface changes
Before:

After:

API changes
TBD
Data model changes
TBD
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | 3445375-ckeditor-5-supported-attributes-11.3.6.patch | 10.36 KB | chamilsanjeewa |
| #34 | 3445375-ckeditor-5-supported-attributes.patch | 11.09 KB | robloach |
| #25 | Before.png | 225.24 KB | mingsong |
| #25 | After.png | 238.4 KB | mingsong |
Issue fork drupal-3445375
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mingsongComment #3
mingsongComment #4
mingsongComment #5
mingsongComment #6
mingsongComment #7
mingsongComment #9
mingsongThe test to reproduce this issue.
https://git.drupalcode.org/project/drupal/-/merge_requests/7924.patch
Comment #11
mingsongComment #12
mingsongIt seems that something related to
<$text-containerat line 455 in ckeditor5.ckeditor5.yml file.https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/ckedi...
The $text-container variable seems wan't replaced with the actual tag name, which is
<p>tag in this case.Comment #13
mingsongComment #14
mingsongComment #15
mingsongComment #16
mingsongComment #17
mingsongAnother example is
which trigger another error message:
In which, the plugin name is missing from the message.
Comment #18
mingsongI believe this bug is caused by Drupal\ckeditor5\HTMLRestrictions::applyOperation() function.
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/ckedi...
As the function description suggested, it is supposed to support wildcard within an element name. Therefore, the wildcard $text-container should be resolved into a concrete tag, so that the Alignment plugin should be chosen in the error message, for example. But actually the result is opposite.
Actually this function doesn't resolve the wildcard tag for some plugins, such as the Alignment plugin.
At line 1143, the comment inside the function resolveWildcards() suggest that,
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/ckedi...
But the problem is that, the Alignment plugin only has a wildcard tag of '$text-container' , nothing else. So this logic won't work for this plugin or any other plugin which only has wildcard tags.
So if the logic is changed to
It will work for all plugins.
Comment #19
mingsong10.2 branch is ready for review.
Comment #20
mingsongMerge requests are ready for review.
Comment #21
mingsongComment #22
lmoeniI ran into this problem recently in 10.1/10.2 while editing my text format. I tested the 10.2 patch with 10.2.6 and it works perfectly.
Thanks!
Comment #23
thatguy commentedTested the MR 7924, works well and fixes the issue
Comment #24
smustgrave commentedCan the issue summary be completed please.
Proposed solution needs to be filled in
if a UI issue before/after screenshots should be included
Thanks!
Comment #25
mingsongComment #26
mingsongThanks @Stephen.
The summary has been updated as required.
Comment #28
smustgrave commentedThanks for updating issue summary, updates look good.
Left some comments on the MR but a lot of the comment updates, period additions, etc seem to be out of scope of this issue. Code sniffer wasn't failing before without these changes
Test coverage is great.
Comment #29
mingsongThanks @Stehpen for the review.
I correct those out of scope comments.
Regarding other changes, I believe they are necessary as they are part of the fix for this bug.
It is ready for review again.
Comment #30
smustgrave commentedOnly posted a few threads but believe there are still a dozen or so out of scope changes adding comments, punctuation, etc. Would say that could be a follow up issues (maybe novice maybe not).
Comment #31
mingsongWithout those changes, those PHPUnit tests would fail.
Comment #32
quietone commentedFixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
Comment #33
redneko commentedHi, I am experiencing this issue. It would be great if it could be made release ready.
Until I applied this as a patch it was impossible for me to complete some of my work, because without the information missing from the error message I couldn't progress
Comment #34
robloachAttached is the patch against Drupal 10.4.x, with the non-consequential parts removed to avoid the conflicts.
Comment #36
chamilsanjeewa commentedThe attached patch targets Drupal 11.3.6. Unchanged context has been stripped out to prevent apply conflicts.
Comment #38
s_leu commentedI re-rolled the MR on the latest changes in main and also pushed a new branch for back-porting or patching this into 11.4.x.
Also tried to address some more feedback and reduce the changes to only the required ones.