Problem/Motivation
I attempted to add the language drop down to the CK editor 5 UI. I got a message telling me that it didn't work and what I needed to do the fix the issue. The fix attempt that I tried did not work. It turns out that adding Language to CKEditor does not correctly handle adding the span tag and required attributes.
Steps to reproduce
Steps:
1. Go to https://simplytest.me/
2. In the field Evaluate Drupal Projects, type Drupal
3. Choose Drupal core
4. Accept 10.1.4 (or whatever the latest version offered is) as the default
5. Click Launch sandbox
6. Wait to be redirected to the test instance
7. Enter the admin user name and password
8. Click Configuration, then Text formats and editors
9. On the row for basic HTML, click Configure
10. Scroll down to the bottom and examine Limit allowed HTML tags and correct faulty HTML field.
Actual and expected results: Field contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>
11. Drag the Language button into the active toolbar
Expected result: No warning message.
Actual result: Warning message
The Language plugin needs another plugin to create <span>, for it to be able to create the following attributes: <span lang dir>. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.
12. Under CKEditor5 plugin settings, click Language
13. (Workaround results are different if I skip this step) In the drop-down, choose All 107 languages (or however many there are)
14. Click Save Configuration
Expected result: No error message.
Actual result: Error message
The Language plugin needs another plugin to create <span>, for it to be able to create the following attributes: <span lang dir>. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.
15. Scroll down to the bottom and examine Limit allowed HTML tags and correct faulty HTML field.
Expected result: Field contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align> <span lang dir>
Actual result: Field contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align> <span dir>
Attempted workaround:
16. Under CKEditor5 plugin settings, click Source editing
17. Change
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
to read
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <span lang dir>
27. Click Save Configuration
Workaround results if I did step 13, that is I chose 107 languages:
Expected results:
- Error message disappears.
- Source editing setting continues to read:
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <span lang dir> - HTML filter reads:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align> <span lang dir>
Actual results:
- Error message remains.
- Source editing setting reads:
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> - HTML filter reads:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align> <span dir>
And no further workaround appears to be available to me, so I stop.
Workaround results if I skipped step 13, that is, I defaulted to UN languages only:
Result: Drupal returns to /admin/config/content/formats and shows a message that Basic was updated.
Continuing with the skipped step 13 behavior only:
27. On the row for basic HTML, click Configure
28. Scroll down to the WYSIWYG
Actual and expected results: the WYSIWYG toolbar contains a language drop down.
28a. (added after issue close) Now do the skipped step 13 by choosing 107 languages.
29. Click on the source editing tab
Actual and expected results: the manual edit field contains:
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <span lang dir>
28. Scroll down to the bottom and examine Limit allowed HTML tags and correct faulty HTML field.
Expected result: HTML filter contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <span lang dir> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align>
Actual result: HTML filter contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <span dir> <strong> <em> <code> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align>
29. In the admin toolbar, click Content then Add Content then Basic Page.
30. In the title field, type Test Page.
31. In the body field, type:
Hello in Burmese is "မင်္ဂလာ."
32. Select the word မင်္ဂလာ.
33. Choose Burmese from the language drop-down in the WYSIWYG toolbar.
34. Click the Save button.
35. Right click the word "မင်္ဂလာ"
36. Choose Inspect element
Actual and expected results: <span lang="my" dir="ltr" xml:lang="my">မင်္ဂလာ</span>
Proposed resolution
When the user drags the Language drop-down into the WYSIWYG toolbar, the program automatically adds <span lang dir> to the HTML filter.
Comments
Comment #2
charles belovComment #3
charles belovComment #4
cilefen commentedIs this about a patch from #3273986: Third option for the CKEditor 5 "Language" button: `site_configured` (in addition to `un` and `all`) not working? If I understand this correctly you should be reporting this problem there.
Comment #5
charles belov@cilefen Thank you for guiding me to be rigorous. I discovered this issue while attempting to test the patch, but the patch is not the cause. I have removed the patch from the steps, in order to avoid confusion, as I can reproduce the issue from installing Drupal 10.1.4 alone.
Comment #6
charles belovComment #7
charles belovI'm rewriting this and changing the title as I apparently completely misunderstood what was supposed to happen. I've rewritten the steps to include examining the filter settings for allowed HTML. I now realize that the filter field is supposed to be updated to reflect the changes that I make to the toolbar, which completely changes my expectation for the expected results.
This might need to be split up into two issues. The issue fails the same way whether or not I do step 13, but the attempted workaround only works if I skip step 13.
Comment #8
charles belovI have simplified the steps to only display the existing core issue I am encountering and removed any steps related to #3273986: Third option for the CKEditor 5 "Language" button: `site_configured` (in addition to `un` and `all`).
Marking this as related to #3273986 because the workaround fails for me both with the 107 languages choice and the site configuration languages choice added by that issue. However, this current issue is not a child of that issue because the failure already happens in core with the 107 languages choice, without applying the patch for that issue.
I will add my steps that I originally posted for the current issue to #3273986, since the original steps used the patch for that issue.
Comment #9
charles belovComment #10
charles belovComment #11
wim leersThis bug report conflates one mistake/usability problem by including an uncommitted core patch.
#3388978 is far clearer.
Let's continue this at #3388978-5: Improve warning upon adding the Language plugin, where I provided a detailed response.
Comment #12
charles belovJust for the record, added a missing step at 28a, otherwise what follows doesn't make sense.