Problem/Motivation
At now Drupal Media entities can be inserted into CKEditor, using Media Library widget, only as block element. So there are no ways to insert inline image (eg small icon image into text), or document (inline link to download file inside text paragraph).
Proposed resolution
Add "Inline" variant to widget align property, and convert CKEditor widget from block to inline, if selected.
Instead of manual control via the align properties as initially proposed, the current approach in the MR is doing the using the same approach as ckeditor5's image plugin is build upon, see the definition of the inline image and it's counterpart, the block image.
So as the image plugin in ckeditor core, there will be a new model for media which is embedded inline and media which is embedded as block content, which model is used is depending on the parent element of the media. So for example a <div>
parent will result in a block model, a <p>
parent will cause the editor to use the inline model.
On the rendering side, this needs dedicated templates to ensure that media embedded inline is also being rendered using markup that is based on phrasing content and can be contained inside flow content.
To use these templates view mode, there is also a new view mode ckeditor_inline
which enables advanced control over what is rendered in case of media embedded media.
Remaining tasks
Discuss the UX, finish the patch.
User interface changes
Added "Inline" option to media align property.
API changes
- Clientside: New element inside the drupalMedia ckeditor plugin
- Serverside: New event MediaBuildEmbedEvent that allows altering the media build before it is rendered and embedded. The currently existing
'#embed'
key in the build is not providing enough context to make advanced changes in the build.
Data model changes
None.
Release notes snippet
TBD