Problem/Motivation
When I try to add the language drop-down to the CKEditor toolbar, I get an error message. However, I have no idea what to do after reading the error message. A more informative error message would be helpful.
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.2.0 (or whatever the latest version offered is) as the default
5. Click Advanced options
6. In the field Add patches on the chosen project, paste https://git.drupalcode.org/project/drupal/-/merge_requests/4656.patch
7. Click Launch sandbox
8. Wait to be redirected to the test instance
9. Enter the admin user name and password
10. Click Extend
11. Under Multilingual, check Content Translation and Language
12. Click Install
13. Wait until the process is done
14. Click Configuration, then Languages
15. Click Add language
16. In the Language name drop-down, choose Custom Language
17. Type tl (that is, lower-case L) for the Language Code and Filipino for the Language Name.
18. Click Add Custom Language
19. Click Configuration, then Text formats and editors
20. On the row for basic HTML, click Configure
21. Drag the Language button into the active toolbar
Expected Result: Warning message
The Language plugin needs you to add <span> to CKEditor 5 plugin settings, Source editing, Manually editable HTML tags, for it to be able to create the following attributes: <span lang dir>. Alternatively, you can add a plug-in that creates <span> if one exists.
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.
Proposed resolution
Change warning message to point to just say to add <span> to CKEditor 5 plugin settings, Source editing, Manually editable HTML tags, as that is the easiest solution.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3388978-16-languague_plugin_elements.patch | 424 bytes | anwoon |
Comments
Comment #2
charles belovComment #3
charles belovComment #4
charles belovI removed the patch steps from the list, as they are not necessary to reproduce the issue.
Comment #5
wim leersFYI: this approach was implemented after very careful consideration in #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path.
You suggest:
But the message literally says:
… which is what you're asking for! (⚠️ With one important exception: you were trying to add
<span lang dir>, you should have only added<span>, per the message!)I suspect you just find the current message not precise enough? I can see that!
Would this be better?
Would that help?
Comment #6
charles belovThank you for demystifying this and confirming your instructions worked.
I'd really prefer Drupal to just tell them to manually add the tag and not send people on a hunt to find a plug-in which may or may not exist when I can solve it with a click on the Source Editing tab and type 6 characters.
So:
The Language plugin needs another plugin to create , for it to be able to create the following attributes: . Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.
would be replaced with:
The Language plugin cannot create with the current configuration. Within Source Editing, add "
<span>" to the list of manually editable tags.or at most:
The Language plugin cannot create with the current configuration. Within Source Editing, add "
<span>" to the list of manually editable tags. Alternatively, you can enable a plugin that supports creating this tag, if one exists.Comment #7
charles belovWim Leers, thank you again for the education. After reading #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path, I've revised the original issue description and title.
Comment #8
wim leersThat's not recommended from a CKEditor 5 POV. But … you're right that this is the only pragmatic choice!
So let's change this!
Could you roll a patch or create a merge request with your proposed text? 😊
Comment #9
charles belovRemoved the alternative, longer comment. If we don't want site builders enabling the Language plug-in just to get the span tag, we probably also don't want site builders enabling some other random plug-in that editors don't need just to get the span tag.
So, only the simple message is appropriate.
Comment #10
charles belovComment #11
charles belovI'm actually not a developer, I'm quality assurance, and also don't have the bandwidth.
Comment #12
tbcs commentedI'll take this.
Comment #13
charles belovUpdated the issue description on December 28, 2023, to reflect changed behavior in Drupal 10.2.
Comment #14
charles belovComment #15
charles belovChanging the description and title back, as I misunderstood the issue with 10.2.0, with an update to the proposed message based on my current understanding.
Comment #16
tbcs commentedThe fundamental issue behind this is that the ckeditor5_language plugin requires that you are able to *edit* span tags, but does not guarantee that you can create them. Only the "Source Editing" plugin allows this. It's not always desirable to allow users to edit the source even when they can set language tags.
Is it reasonable to update ckeditor5.ckeditor5.yml to read like this?
Changes would also have to be made to the relevant tests, notably Drupal\Tests\ckeditor5\FunctionalJavascript\AdminUITest and Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test
See also https://www.drupal.org/node/3283526#comment-15391076
Comment #17
megakeegman commentedJust want to note here that today I tried turning off manually edit source HTML option because of a bug where I get an error that suggests there is an option that is already covered by a plugin, but lists no tags in the error. I think this is related to this issue https://www.drupal.org/project/drupal/issues/3410100 which does have a patch. I didn't apply that patch because I was okay with taking away the option for people to manually edit source, which I did. That is when I ran into the error described in this issue. And I want to express how unfortunate it feels to see the recommendation here is to re-enable the option to manually edit source HTML, which is broken. At least there is a patch, but thought it was worth mentioning that there are issues right behind the fix that has been recommended throughout this thread.
Comment #19
anwoon commented