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:
- Enable core ckeditor5 module
- Set Patternkit to use CKEditor5 (on /admin/config/user-interface/patternkit/json)
- 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
Comments
Comment #2
sluceroI 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:
drupal/patternkit:9.1.0-beta6) and CKEditor (drupal/ckeditor)Comment #3
sluceroIn 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.
Comment #4
sluceroComment #5
krisahil commented@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.
Comment #7
sluceroWhile 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:
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.
Comment #9
sluceroI've merged in this patch for the Beta 7 release, and I've documented follow-up work in #3357146: Failure when WYSIWYG and Toolbar Selection are Misconfigured.