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

CommentFileSizeAuthor
#19 3388978-16-languague_plugin_elements.patch424 bytesanwoon

Comments

Charles Belov created an issue. See original summary.

charles belov’s picture

Title: Instructions for error upon adding the language plug-in are hard to implement » Eliminate or improve error upon adding the language plug-in
Issue summary: View changes
charles belov’s picture

charles belov’s picture

Issue summary: View changes

I removed the patch steps from the list, as they are not necessary to reproduce the issue.

wim leers’s picture

Category: Bug report » Task
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Usability
Related issues: +#3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path

FYI: 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:

Better yet, just tell them to add <span lang dir> to Source Editing once #3388698: Adding the language plug-in does not add the correct span tag attributes is fixed.

But the message literally says:

[…] Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.

… 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?

[…] Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it: add to the list of "Manually editable HTML tags".

Would that help?

charles belov’s picture

Thank 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.

charles belov’s picture

Title: Eliminate or improve error upon adding the language plug-in » Improve warning and error upon adding the language plug-in
Issue summary: View changes

Wim 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.

wim leers’s picture

Title: Improve warning and error upon adding the language plug-in » Improve warning and error upon adding the Language plugin
Status: Postponed (maintainer needs more info) » Needs work
Issue tags: +String change in 10.2.0

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.

That'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? 😊

charles belov’s picture

Issue summary: View changes

Removed 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.

charles belov’s picture

Issue summary: View changes
charles belov’s picture

Could you roll a patch or create a merge request with your proposed text?

I'm actually not a developer, I'm quality assurance, and also don't have the bandwidth.

tbcs’s picture

Assigned: Unassigned » tbcs

I'll take this.

charles belov’s picture

Title: Improve warning and error upon adding the Language plugin » Spurious warning upon adding the Language plugin
Issue summary: View changes

Updated the issue description on December 28, 2023, to reflect changed behavior in Drupal 10.2.

charles belov’s picture

Issue summary: View changes
charles belov’s picture

Title: Spurious warning upon adding the Language plugin » Improve warning upon adding the Language plugin
Issue summary: View changes

Changing 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.

tbcs’s picture

The 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?

ckeditor5_language:
  ckeditor5:
    plugins: [language.TextPartLanguage]
  drupal:
    label: Language
    library: ckeditor5/internal.ckeditor5.language
    admin_library: ckeditor5/internal.admin.language
    class: Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language
    toolbar_items:
      textPartLanguage:
        label: Language
    elements:
      - <span>
      - <span lang dir>

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

megakeegman’s picture

Just 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

anwoon’s picture

StatusFileSize
new424 bytes