Some combination of media bundles and view modes in Embed Media plugin make CKEditor disappear

Created on 17 January 2024, 8 months ago

Problem/Motivation

Since #3097416: When embedding media, don't let authors choose view modes that are not enabled for that media type β†’ , view modes are filtered before being passed to the drupalElementStyles plugin.
This happens in \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media::configureViewModes() which filters out view modes that are not enabled for at least one Media Type.
As all view modes are available to choose in the media_embed Filter plugin, we can easily have some combinations that leads to only have disabled view modes available. In this case, ckeditor5 fails to load and gives us a nice "TypeError: a is undefined" unhelpful error.

Steps to reproduce

  1. install Umami
  2. edit Basic HTML text format
  3. in ckeditor5's Media plugin settings, enable "Allow the user to override the default view mode"
  4. in Embed Media filter's settings select only "Full content" and "Square" view modes and set "Full content" as default
  5. try to create a Basic page

Proposed resolution

Option 1

Improve Embed Media settings form to only allow to select enabled view modes for selected bundles.
Pros: more polished options for site builders
Cons: complex UI to be designed, dependencies management to add in case some selected view mode is deleted

Option 2

Revert #3097416: When embedding media, don't let authors choose view modes that are not enabled for that media type β†’ and allow users to select view modes that are not configured for the given bundle.
Pros: allows to rely on the view modes fallback mechanism
Cons: can confuse users if the selected view mode doesn't have any rendering

Bonus option

Only add a setting to disable the filtering and let the site builder take responsibility.
Pros: easy to implement, current behavior by default, allow option 2 pros
Cons: can still confuse users but it's site builder's responsibility

πŸ› Bug report
Status

Active

Version

10.2 ✨

Component
MediaΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡«πŸ‡·France DuaelFr Montpellier, France

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

Merge Requests

Comments & Activities

  • Issue created by @DuaelFr
  • Merge request !6214Issue #3415328: bonus option β†’ (Open) created by DuaelFr
  • πŸ‡«πŸ‡·France DuaelFr Montpellier, France

    Quick and dirty patch & MR for the bonus option as I need it right now ;)

  • Pipeline finished with Failed
    8 months ago
    Total: 590s
    #78781
  • Pipeline finished with Canceled
    2 months ago
    Total: 251s
    #218935
  • Pipeline finished with Failed
    2 months ago
    Total: 596s
    #218942
Production build 0.71.5 2024