Problem/Motivation
#3222797: Upgrade path from CKEditor 4's StylesCombo to CKEditor 5's Style added the @ckeditor5/ckeditor5-style
plugin.
But its plugin definition had its drupal.elements
restricted to just HTML5 elements:
elements:
- <$any-html5-element class>
(And it has corresponding validation logic in StyleSensibleElementConstraintValidator
— see \Drupal\ckeditor5\Plugin\Validation\Constraint\StyleSensibleElementConstraint::$nonHtml5TagMessage
.)
Why?
- Drupal's CKEditor 4 integration (
StylesCombo
) never supported setting styles on e.g.<drupal-media>
— heck, not even on<img>
! - In the CKEditor 5 equivalent (
Style
), images and Drupal media are impossible to support today, because they're implemented as "widgets", and I quote:Widget styling is out of the picture for now.
— source: issue 5700. This is fine because this didn't work in Drupal 8 either — see #2642808: [upstream] CKEditor Style for <img> not working because it is an "image" widget + #3117172: Allow CKEditor styles for <drupal-media>.
For images this is arguably bad, but for Drupal media this is arguably fine: because those allow choosing a view mode already: #3074608: Optionally allow choosing a view mode for embedded media in EditorMediaDialog.
Combine this with the fact that the Drupal ecosystem is moving from "plain images" to "image media"— especially post-migration from Drupal 7 thanks to migration modules like https://www.drupal.org/project/media_migration, the value of making this work for plain images (<img>
) is diminishing. - In the CKEditor 5 equivalent (
Style
), integration with GHS is incomplete, which means that some elements may not be able to useStyle
yet.
Since CKEditor 5's official plugins only support official HTML5 elements, the obvious thing to do is to restrict the allowed HTML elements to configureStyle
for to just … HTML5 elements. Hence the validation logic mentioned above!
Steps to reproduce
N/A
Proposed resolution
Wait for Style
to stabilize further, and in particular for it to gain full GHS support. Then we can consider allowing configuring styles for non-HTML5 tags.
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Release notes snippet
TBD