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.
When the user sets a default view mode as a view mode that is not allowed for a certain bundle (media type), it applies that view mode to the element anyway. In my screenshot below, I configured my document media type so that "tiny" view mode is not allowed. However as you can see in the source code, it has "tiny" on the element. (Below screenshot is CKEditor 5 but same thing happens for CKEditor 4)

Looking at \Drupal\media\Plugin\Filter\MediaEmbed::process(), I don't think it's taking into account that the view mode may not exist for the bundle (MediaType). So that'd be another bug in the media module, not in the CKEditor 5 module.
— from #3276670-5: Some configurations of allowed view modes cause CKE to fail to initialize
Steps to reproduce
1. Go to /admin/structure/media/manage/document/display (or whatever media type)
2. In Custom display settings, do not check whatever view mode you want to test with.
3. Go to your editor configuration and under embed media, set the Default view mode to that view mode from #2.
4. Go to your editor and insert a document and check the source code of that element and you should see the view mode that should not be allowed.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2022-04-22 at 11.23.03 AM.png | 104 KB | hooroomoo |
Comments
Comment #2
hooroomooComment #3
wim leers👍 Great write-up! 👏