Problem/Motivation
Discovered in #3245720: [drupalMedia] Support choosing a view mode for <drupal-media> and split from #3276670: Some configurations of allowed view modes cause CKE to fail to initialize.
The media embed filter settings validation logic is inadequate and needs to be hardened because it currently allows the user to save a configuration of a default view mode being a view mode that is not a selectable view mode. This has a consequence of making CKEditor 5 fail to initialize after saving.
AFAICT \Drupal\media\Form\EditorMediaDialog::buildForm() also only allows selecting the selected view modes, with no fallback behavior to automatically include the default view mode. Which makes no sense. In other words: the validation logic of \Drupal\media\Plugin\Filter\MediaEmbed::settingsForm() is inadequate. Therefore this is a bug in the media module, and deserves a separate issue there.
— from #3276670-5: Some configurations of allowed view modes cause CKE to fail to initialize
A workaround will be added in #3276670: Some configurations of allowed view modes cause CKE to fail to initialize, so the editor does not crash but the validation in the media module should be hardened in this issue to prevent this invalid configuration.
Steps to reproduce
- Go to a text format's configuration form
- Enable the "Embed media" filter
- Select something as the Default view mode
- Do not check that view mode in the "View modes selectable in the 'Edit media' dialog section
- Return to editor (editor should fail to load, you should see error in console)
Proposed resolution
Remaining tasks
- TBD
- Remove the work-around that #3276670: Some configurations of allowed view modes cause CKE to fail to initialize added, as also pointed out in #6.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3277049-8.patch | 5.29 KB | lendude |
Comments
Comment #2
hooroomooComment #3
hooroomooComment #4
hooroomooComment #5
wim leersThanks for the write-up!
Improved markup/clarified a few things.
Comment #6
catchThis issue should also remove the workaround and test coverage added in
core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Media.php
core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
(see https://git.drupalcode.org/project/drupal/-/merge_requests/2161/diffs#di...)
Comment #7
wim leersYep! Documented explicitly now.
Comment #8
lendudeFirst stab at this.
Comment #9
lendudeduh...