Allow CKEditor styles for <drupal-media>

Created on 2 March 2020, almost 5 years ago
Updated 8 August 2024, 4 months ago

Problem/Motivation

The DrupalMedia plugin, added in 8.8.0, does not allow for CKEditor styles to applied to <drupal-media> elements.

Steps to reproduce

  1. Install with 'Standard' install profile.
  2. Enable Media and Media Library modules.
  3. Set default view mode for 'Image' media bundle to render an image element with no label.
  4. Add 'Insert from Media Library' and 'Styles' buttons to 'Basic HTML' toolbar.
  5. Add the following dropdown style: 'drupal-media.test-class|Test'.
  6. Save the filter format.
  7. Upload an image to the Media library and insert into a Basic Page node.
  8. Observe the only class on the <drupal-media> element is 'cke_widget_element'.
  9. Select the media element and use the Styles dropdown to add the 'test-class' class.
  10. Observe the only class on the <drupal-media> element remains 'cke_widget_element'.
  11. Switch to CKEditorโ€™s source mode.
  12. Observe no class attributes.
  13. Manually add a 'test-class' class.
  14. Switch out of source mode.
  15. Observe the only class on the <drupal-media> element is 'cke_widget_element'.
  16. Switch back to source mode and observe the class has been removed.

Proposed resolution

Update the DrupalMedia plugin to allow for <drupal-media> elements to be assigned classes by the StylesCombo plugin.

Remaining tasks

  • Write patch
  • Update tests
  • Community review

User interface changes

<drupal-media> elements can now be assigned classes by the StylesCombo plugin.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

โœจ Feature request
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Mediaย  โ†’

Last updated 3 days ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States Chris Burge

Live updates comments and jobs are added and updated live.

Missing content requested by

๐Ÿ‡ฆ๐Ÿ‡บAustralia dpi
11 months ago
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024