Problem/Motivation
If a CKEditor plugin integrates with Media to provide a custom attribute, it can no longer cause a preview re-render for the drupal-media element. In CKEditor 4 this was possible by altering the editor_media_dialog form and a little magic.
In CKEditor5 you must implement your own toolbar button or dropdown. Re-rendering of the preview is explicitly registered in https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/modules/cked...
The converter is locally scoped and the plugin does not allow adding additional attributes to listen for refresh.
Steps to reproduce
Write a CKEditor5 plugin to manipulate drupal-media, see it never refresh
Proposed resolution
Provide an API for adding additional attributes OR export the converter for other plugins to use.\
laurii pointed to https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ima..., the problem for contrib is the quirky import (relative paths)
however, using the exported converter in a build could lead to an outdated copy, if drupal fixes it. it'd be better as a runtime dependency, which is hard. so using properties on the plugin which other plugins register may be best (copying notes from Slack with laurii)
Remaining tasks
Decide on approach, and do it
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3300246-13-9.x.patch | 79.3 KB | wim leers |
| #11 | 3300246-11-95x.patch | 79.22 KB | Ankit.Gupta |
| #8 | 3300246-94x.patch | 79.31 KB | mglaman |
| #8 | 3300246-95x.patch | 79.31 KB | mglaman |
Issue fork drupal-3300246
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3300246-allow-other-ckeditor5
changes, plain diff MR !2559
Comments
Comment #2
mglamanComment #3
mglamanComment #4
mglamanI quick tried this locally:
Modify DrupalMediaEditing to add
My plugin in its init then has to do:
It has to re-apply the converter listeners for the new attribute since everything is running in `init`. That's one reason why exporting `converter` would be better. My plugin has DrupalMediaEditing as a dependency, so init is messy.
The weird part is that everything breaks when I use:
The media element never renders, only when I keep
Comment #5
mglamanIt didn't work because I failed to build the proper event name 😅. Opening an MR based on the following:
and
This allowed our plugin, in its constructor, to add another attribute:
Comment #7
lauriiiThe MR looks all good for me. The plugin is still marked as @private which I think is what we still expect. We can potentially officially declare this as an API later on.
Would be useful to have a 9.5.x and 9.4.x versions of the patch.
Comment #8
mglamanPatches for 9.5.x and 9.4.x, if needed.
Comment #9
lauriiiComment #10
wim leersFor the reroll needed since #9.
Comment #11
Ankit.Gupta commentedReroll the patch #8 with Drupal 10.0.x
Comment #12
wim leersLooks like #8 did not work because the CKEditor 5 version in those 2 branches was slightly different than the one in
10.0.xat that point in time.Let's get this back on track.
First, the MR should work against
10.0.xagain — it's >1.5 month out of date. CKEditor 5 has been updated since.The result is 77d2321866df0c3539d0b6bd8c4244a910de9bc7, let's see how that works out 🤓
Comment #13
wim leersComment #14
wim leersI failed to follow through here — the MR is green and the rerolled patch for
9.xis green too.I didn't do anything besides rebasing and rerolling, so restoring the RTBC from #7.
Comment #19
lauriiiCommitted the MR 3a4d030 and pushed to 10.1.x and cherry-picked to 10.0.x. Thanks!
Committed #13 ebeffc8 and pushed to 9.5.x and cherry-picked to 9.4.x. Thanks!