Improve warning upon adding the Language plugin

Created on 21 September 2023, about 1 year ago
Updated 9 January 2024, 10 months ago

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

📌 Task
Status

Needs work

Version

11.0 🔥

Component
CKEditor 5 

Last updated 1 day ago

Created by

🇺🇸United States charles belov San Francisco, CA, US

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

  • Issue created by @charles belov
  • 🇺🇸United States charles belov San Francisco, CA, US
  • 🇺🇸United States charles belov San Francisco, CA, US
  • 🇺🇸United States charles belov San Francisco, CA, US

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

  • Status changed to Postponed: needs info about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    FYI: this approach was implemented after very careful consideration in #3273983: Do not assume that plugin supporting also supports in SourceEditingRedundantTags and upgrade path .

    You suggest:

    Better yet, just tell them to add <span lang dir> to Source Editing once 🐛 Following instructions for error upon adding the language plug-in does not remedy the issue Postponed: needs info is fixed.

    But the message literally says:

    […] If none exists, you can configure the Source Editing plugin to support it.

    … which is what you're asking for!

    I suspect you just find the current message not precise enough? I can see that!

    Would this be better?

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

  • 🇺🇸United States charles belov San Francisco, CA, US

    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.

  • 🇺🇸United States charles belov San Francisco, CA, US

    Wim Leers, thank you again for the education. After reading #3273983: Do not assume that plugin supporting also supports in SourceEditingRedundantTags and upgrade path , I've revised the original issue description and title.

  • Status changed to Needs work about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • 🇺🇸United States charles belov San Francisco, CA, US

    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.

  • 🇺🇸United States charles belov San Francisco, CA, US
  • 🇺🇸United States charles belov San Francisco, CA, US

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

    Unfortunately, I am working part-time and don't have a development environment (or the know-how to set one up beyond launching a simplytest.me instance), so I don't have the bandwidth able to accomplish this.

  • Assigned to tbcs
  • 🇺🇸United States tbcs

    I'll take this.

  • 🇺🇸United States charles belov San Francisco, CA, US

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

  • 🇺🇸United States charles belov San Francisco, CA, US
  • 🇺🇸United States charles belov San Francisco, CA, US

    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.

  • 🇺🇸United States tbcs

    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

Production build 0.71.5 2024