Problem/Motivation
Unfortunately, because #3206522: Add FunctionalJavascript test coverage for media library had not yet been ported, we didn't realize until now that captioning and alignment support are still missing from the DrupalMedia CKEditor 5 plugin… only alt override has been ported so far. Still missing: data-caption.
Fortunately #3201646: Add support for image caption (<img data-caption>) provides a pretty clear example of how to implement captioning — but this is done in an image-specific way so could be a bit more tricky
That will allow us to unskip/get passing, respectively:
\Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testEditableCaption()
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #35 | 3246385-35-d9.patch | 120.02 KB | lauriii |
| #35 | 3246385-35-d10.patch | 119.74 KB | lauriii |
| #34 | 3246385-34-d9.patch | 119.77 KB | lauriii |
| #34 | 3246385-34-d10.patch | 119.49 KB | lauriii |
| #33 | 3246385-33-d9.patch | 119.55 KB | lauriii |
Issue fork drupal-3246385
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:
- 3246385-drupalmedia-support-captions
changes, plain diff MR !1736
Comments
Comment #2
wim leersComment #3
wim leersComment #4
wim leersComment #7
lauriiiMoved alignment to #3260554: [drupalMedia] Support alignment on <drupal-media> because it can be worked separately from captions.
Comment #8
lauriiiThe issue summary also mentions
data-view-mode. I think we should open another new issue for that.Comment #9
wim leers#8: #3245720: [drupalMedia] Support choosing a view mode for <drupal-media> :)
Comment #12
wim leers#3260554: [drupalMedia] Support alignment on <drupal-media> landed. Let's get this in next! :D
Comment #13
nod_Need rebase at least, currently looking at the code
Comment #14
nod_Caught #3263601: Follow-up, fix JS error by fixing form ID selector while reviewing this
Comment #15
nod_At render time this is adding a
figcaptionelement in the frontend without a parentfigureelement. This is not valid HTML5, spec says it'sAt the moment it's only adding a caption below the image, not sure we want to add more settings to set the caption above or below the image.
As for the validity of the HTML generated I'm guessing this is out of scope. Why are media wrapped in anMy mistake, it does it properly.<article>tag and not<figure>, because the purpose of the figure element seems to match the use we have for embedding media in the body of an article.This is not the case inside the CKEditor instance though: we have
Here the wrapping div should be a figure tag no? that's the case for ckeditor image plugin.
Comment #16
lauriiiGood point that we need to change the wrapping
<div>to<figure>on editing view. Somehow missed that as I was working on this 🤦♂️I'm wondering if we should open a follow-up for figuring out how to configure whether the caption preview should render before or after. We might want to do this for both,
<drupal-media>and<img>.Comment #17
nod_The placement of the caption is definitely out of scope for this issue. It's not available in the upstream imagecaption plugin so might make sense to open something upstream first? and see how they do it so we can just copy/paste :D
Comment #18
lauriiiComment #19
nod_Thanks for the explanations lauriii, this looks good to me now.
Comment #20
wim leersManually tested, works perfectly.
Reviewed MR in detail. Three main concerns:
\Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::testEditableCaption()has that this does not yet. Porting it should be pretty easy. And then we can be extra confident.Comment #21
wim leersOnce a follow-up exists for https://git.drupalcode.org/project/drupal/-/merge_requests/1736#note_71991, I think this is RTBC :)
Comment #22
lauriii@Wim Leers I've added similar test coverage that works around the limitations we have on selecting text in CKEditor. Wondering if you think we still need the follow-up after this?
Comment #23
wim leersYes, I agree that's a reasonably equivalent piece of test coverage! Well done! 👏🥳
I just left one tiny remark, but even that is not commit-blocking.
Comment #24
lauriiiOpened follow-up for a bug I discovered with this MR: #3264775: [drupalMedia] Toolbar should be visible when element inside <drupalMedia> is focused.
Comment #25
bnjmnmSwitching to NW due to a failing test that is part of the MR and not one of those randoms we run into at inopportune times.
Comment #26
bnjmnmBTW I'm not getting the test failure locally, sharing the CI output since it took a very time to load and I want to save people that step:
Comment #27
lauriiiThat was indeed failing 9/10 times on DrupalCI... I think I managed to fix that. I ran this 50x on #2488258-195: [ignore] Patch testing issue.
Comment #28
wim leersHoly crap! :O
chromedrivermadness strikes again. 😬#2488258-195: [ignore] Patch testing issue is very convincing.
(And that last commit also addressed the tiny nit I still had: https://www.drupal.org/project/drupal/issues/3246385#mr1736-note72324 👍)
Comment #29
lauriiiComment #30
lauriiiComment #31
nod_D10 reroll, working on 9.4
Comment #32
nod_D9
Comment #33
lauriiiThere was a small problem with the CSS caused by the reroll in #31 which I fixed on MR and here's that again as patches.
Comment #34
lauriiiComment #35
lauriiiComment #39
bnjmnmVery nice to see Media captions! Excellent addition.
Committed to 10.0.x/9.4.x and cherry-picked to 9.3.x as CKEditor 5 is experimental.