Error: Class "Drupal\ckeditor5\Plugin\Editor\CKEditor5" not found

Created on 25 April 2023, about 1 year ago
Updated 28 April 2023, about 1 year ago

Problem/Motivation

After updating to 9.1.0-beta7, I got an error on a Drupal 9.5.8 site. I upgraded from 9.1.0-beta6 to 9.1.0-beta7. The site was using CKEditor 4, and CKEditor 5 core module was disabled.

After updating the module code and running database updates and flushing caches, I used Layout Builder to edit a block whose schema contains a wysiwyg-enabled text field. There was an error in the browser console, and the Drupal logs showed this error:

Error: Class "Drupal\ckeditor5\Plugin\Editor\CKEditor5" not found in Drupal\patternkit\Plugin\PatternLibrary\PatternLibraryJSON->schemaEditor() (line 159 of /var/www/web/modules/contrib/patternkit/src/JSONSchemaEditorTrait.php) #0

To fix this, I did the following:

  1. Enable core ckeditor5 module
  2. Set Patternkit to use CKEditor5 (on /admin/config/user-interface/patternkit/json)
  3. Edit the text format (also set on that page), to upgrade it from CKEditor to CKEditor 5

Steps to reproduce

See above.

Proposed resolution

Ideas:

  • Patternkit should not assume that ckeditor5 is enabled (I think this is only relevant on Drupal 9, not 10).
  • On /admin/config/user-interface/patternkit/json, do not allow the CKEditor 5 option if ckeditor5 isn't enabled.
  • If CKEditor 5 is selected for Patternkit, then the module should validate that the selected text format (in config "CKEditor toolbar") is actually set to use CKEditor 5.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

9.1

Component

Schema Editor

Created by

πŸ‡ΊπŸ‡ΈUnited States krisahil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @krisahil
  • πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas

    I was able to reproduce this locally, but I had to explicitly go to the Patternkit settings and select CKEditor5 for the editor.

    However, I wasn't able to reproduce the scenario where the setting changed automatically and broke the WYSIWYG on existing pattern blocks. These are the steps I used to attempt to reproduce that:

    1. Install new Drupal 9.5.8 site using standard profile with Patternkit Beta 6
    2. Enable Layout Builder, Patternkit, Patternkit Example, and CKEditor modules
    3. Change Basic HTML and Full HTML formats to use CKEditor instead of CKEditor5
    4. Uninstall CKEditor5 module
    5. Edit Patternkit JSON Settings to use CKEditor and Full HTML format
    6. Enable Layout Builder and Overrides on Basic Page content type
    7. Create and publish example Basic Page Node
    8. Edit the layout on the example page, and place a new "[Patternkit] Example" block with content in the WYSIWYG field
    9. Save the layout and confirm expected rendering
    10. Update Patternkit module to 9.1.x dev release
    11. Clear caches and run database updates (None found)
    12. Edit layout on example page
    13. Edit example block
    14. Expected to see error, but the form rendered with no issues.
  • πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas

    In an effort to mitigate misconfigurations that would break the editorial experience with the wrong editor selected, I'm attaching a patch for testing that limits the available CKEditor options on the configuration form to only those with the necessary module enabled. It also adds validation to confirm the editor selected for the selected toolbar matches what was selected on the form.

  • πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas
  • πŸ‡ΊπŸ‡ΈUnited States krisahil

    @slucero, I'm now unable to reproduce the problem, following the steps I originally reported. :-/
    Like you said, I had to explicitly go to the Patternkit settings and select CKEditor5 for the editor, then I got the error about the missing class.

    I tested the patch in #4, and it works great!
    - On Patternkit settings page, I could only select CKEditor 5 is ckeditor5 module was installed.
    - If I did select CKEditor 5 but kept a CKEditor 4-only toolbar, the settings didn't save due to the validation error.

    Sorry for the incorrect steps to reproduce. I'm not sure what happened there.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    326 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    326 pass
  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas

    While we can't reproduce this issue automatically, I'm going to roll in the current version of the patch for the Beta 7 release to help mitigate issues from misconfiguration of the Patternkit editor and filter format editors which can lead to a WSOD.

    This patch will introduce the following changes:

    • Patternkit's WYSIWYG editor options for CKEditor and CKEditor5 will only be available if the related module is enabled
    • Form validation has been added to prevent saving a toolbar selection that doesn't use the selected editor

    This change does not prevent failure at runtime if the configuration is already in place and invalid by some other means. I will create a follow-up issue momentarily to address that.

    • slucero β†’ authored 80b805d5 on 9.1.x
      Issue #3356415 by slucero, krisahil, minsharm: Error: Class "Drupal\...
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas

    I've merged in this patch for the Beta 7 release, and I've documented follow-up work in πŸ› Failure when WYSIWYG and Toolbar Selection are Misconfigured Needs review .

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024