Problem/Motivation
By default, CKEditor 5 provides buttons in the drupalMedia toolbar (when editing an embedded item) that allow for the following plugins to transform the media embed:
- Caption
- Link
- View mode
- Alignment
Additionally, a plugin for mediaimagetextalternative adds the ability to set alternative text for media types with an image file field.
The default installation of media and media library creates five commonly used media types:
- Audio
- Document
- Image
- Remote video
- Video
Of these media types, caption, with its figure/figcaption pattern, really only makes sense for Image, Remote Video, and Video—media that would typically have an optional caption. Audio might have a caption, but it would be rare. I cannot think of a use case or semantic approach for captioning documents when embedded.
Similarly, adding a link to media could in some cases be destructive to how the media functions. Editors that can embed a document (which would typically have a download link defined in the view mode. Links would also break the typical function for rendered media types such as video, audio, or embeds such as social media, charts, or maps.
Site builders should be able to configure media embeds to exclude plugin buttons that create incorrect HTML or a confusing editor experience.
Steps to reproduce
- Enable Media and Media Library
- Configure the Basic HTML text format to use CKEditor 5 will the following common settings:
- Add Drupal Media to the active toolbar.
- Enable "Allow the user to override the default view mode".
- Enable the filter for "Embed media".
- Enable the filter for "Align images" (it's a bit odd that this filter is not titled "Align media").
- Enable the filter for "Caption images" (it's a bit odd that this filter is not titled "Caption media").
- In the embed media filter settings, select at least two view modes under "View modes selectable in the 'Edit media' dialog".
- In a "Basic page" or similar content type, use the Drupal Media button in the CKEditor 5 toolbar to embed media other than an image.
- After embedding the media, click the media item to show the CKEditor balloon toolbar for the media entity
At this point, you'll see all the extraneous settings that may not make sense outside of the context of an image media entity.
Proposed resolution
A possible resolution would be to add per toolbar button/plugin settings to the media configuration or the embed media filter settings. For example:
Merge request link
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet