OutOfBoundsException when configuring Style plugin for CKEditor

Created on 10 September 2022, almost 3 years ago
Updated 3 July 2024, about 1 year ago

Problem/Motivation

Steps to reproduce:

  1. Open configuration page for some text format, i.e. Full HTML
  2. Drag and drop Style button to active toolbar
  3. Select Style tab under CKEditor5 plugin settings
  4. Put sample value "h1.title|Title" from the textarea description
  5. Sumbit the form

The following error message appears.

OutOfBoundsException: in Drupal\ckeditor5\Plugin\Validation\Constraint\StyleSensibleElementConstraintValidator->findStyleConflictingPluginLabel() (line 179 of core/modules/ckeditor5/src/Plugin/Validation/Constraint/StyleSensibleElementConstraintValidator.php).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
CKEditor 5 

Last updated about 20 hours ago

Created by

🇷🇺Russia Chi

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I just had this error on a fresh Drupal install.

    Drupal 10.1.2 with gintheme + ckeditor5 module enabled.

    I create a new editor and add the Style plugin.

    Input the style a.button|Button and click outside the form element - so the input value is actually submitted.

    Click save.

    Boom. Broken :(

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

    #10: please provide detailed steps to reproduce. Is this just a fresh install of Drupal core + gin, nothing else? No custom CKEditor 5 plugin?

  • Status changed to Active over 1 year ago
  • Yes, fresh install of Drupal.

    I've just retried and reproduce the issue.

    It happens when you create a new text editor and you add all plugins.

    Please find attached a screencapture with the first part where I install a fresh D10, I add a new CKE5 editor successfully - although there is always a bug on the first try - but then I add a new CKE5 editor with all options and it breaks.

    I think these are the steps:

    1. Fresh D10 install
    2. Install with the standard profile `drush si standard -y`
    3. Enable CKE5 `drush en ckeditor5`
    4. Go to `/admin/config/content/formats/add`
    5. Select CKE5 plugin
    6. Add all buttons to the editor
    7. Add at least one style (ex: `a.button|Button`)
    8. Save the form
    9. Boom, broken

    PS: video is too big for d.o so I've sent it on Slack here: https://drupal.slack.com/archives/C01GWN3QYJD/p1709737334307729?thread_t...

  • 🇵🇱Poland salmonek

    The issue occurs when all plugins are enabled.
    The Validator that throws an Exception is loading all enabled and disabled plugins separately for some validation:
    $disabled_plugin_elements = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($enableable_disabled_plugins), $text_editor, FALSE));
    The problem is that getProvidedElements() returns all plugins in case first parameter is empty. I'll prepare a patch shortly.

  • 🇵🇱Poland salmonek

    Here is the patch against 10.2.2
    matthieuscarset, I can send you patch for 10.1.2 on Slack in case this won't work

    BTW: Wim when I'm posting a patch with name format {issue_number}-{comment-number} do I have to put {comment-number} manually and hope that nobody else will post or can the name be somehow generated automatically?

  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • The Needs Review Queue Bot tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • 🇳🇿New Zealand quietone

    I reproduced the error on a fresh install of 11.x.

Production build 0.71.5 2024