Problem/Motivation
Ckeditor 4 supports them, and they're already available in CKEditor 5, so lets support them.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | interdiff_26-28.txt | 623 bytes | bnjmnm |
| #28 | 3230230--28.patch | 8.99 KB | bnjmnm |
| #26 | interdiff.txt | 2.02 KB | bnjmnm |
| #26 | 3230230-26.patch | 9.11 KB | bnjmnm |
| #23 | 3230230-24.patch | 10.25 KB | bnjmnm |
Issue fork drupal-3230230
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:
Issue fork ckeditor5-3230230
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:
Comments
Comment #2
wim leersAdded this to the roadmap's section at #3201824-33: Roadmap to core :)
Comment #3
johnwebdev commentedThis patch enables table captions.
Comment #4
lauriiiThank you for the patch @johnwebdev!
I tested the patch manually and I noticed that adding a caption generates a
<figure>element withdata-captionattribute. This is not consistent with CKEditor 4, which would simply use<caption>element inside the<table>. I think we want the CKEditor 4 behavior here so moving back to needs work.Comment #5
wim leersDoes the CKE5
table.TableCaptionplugin support the configuration described in #4? We'll have to find out, and if not, we'll raise that in the upcoming meeting with the CKEditor 5 developers this Thursday :)Comment #6
lauriiiIt seems like the caption is added to
dataCaptionattribute by the image plugin. When image plugin is disabled, the caption is added tofigcaptionand the<table>is wrapped with<figure>, which is still not what we'd expect.I don't think their documentation include how we could make the caption downcast to the desired markup. However, that's something we should be able to do regardless of that.
Comment #7
wim leersJust asked the CKEditor team:
Agreed with #6 as the solution, but I'd rather first understand why they went this way.
Comment #8
wim leers@Anna_CKSource responded!
We'll need to investigate this.
Comment #10
wim leersThanks, Anna! :)
Comment #12
wim leersAnalysis
@Anna_CKSource provided two discussion links:
Further in that same issue, Maciej asks at https://github.com/ckeditor/ckeditor5/issues/3194#issuecomment-397242600
— which is basically what we are asking here.
Tomasz responded there:
This is again not really an answer why they chose this approach. His link to https://html.spec.whatwg.org/multipage/tables.html#table-descriptions-te... is super valuable though: it shows there are 3 distinct WHATWG-approved techniques:
table > caption→ the current approach used in Drupal 8|9, because this is what CKEditor 4 usedtable > caption > detailsfigure > table + figcaption→ the approach used in CKEditor 5Conclusion
My conclusion from this is that the CKEditor 5 development team understandably chose the approach that is generically applicable for all the markup they need to generate.
But Drupal has a different set of requirements:
The only
<figure>markup that Drupal currently generates, is for captioned images. Drupal stores<img src=… data-caption=…>and transforms this to<figure><img src=…><figcaption>…</figcaption></figure>via the caption filter. Why? Because this makes it easy for different channels/consumers of this data to present the data in a different way; they won't have to parse the full final HTML markup. Drupal prefers structured content, that is more canonical/less coupled to one channel/easier to transform.Therefore it would IMHO still be preferable that Drupal overrides the
ckeditor5-table'stable.TableCaption's default downcast (both "data" and "editing" downcast).Comment #13
wim leersDiscussed during today's CKEditor 5 meeting.
@Reinmar confirms the above. He recommends to:
downcastoverride, to avoid Drupal having to repeat the same table construction logicUpstream, the upcasting from
<table><caption></table>will be taken care of upstream; they will need that for their customers upgrading from CKEditor 4 anyway.Comment #14
wim leersWe should have test coverage to ensure that a pasted
<figure><table><figcaption></figure>while not using does not allow the<figure>to continue to exist; it should be downcast to<table><caption></table>.IOW: document the expected behavior through test coverage.
Comment #16
wim leersPer today's CKEditor 5 + Drupal meeting, both the upcast (actually, this is already working!) and downcast will be handled upstream, in https://github.com/ckeditor/ckeditor5/issues/10892.
Comment #17
wim leersComment #18
wim leers#3269064: Update to CKEditor 5 v33.0.0 landed, this is now unblocked!
See #3269064-6: Update to CKEditor 5 v33.0.0 for details/next steps.
Comment #19
wim leersEven though we updated to CKEditor 5 v33.0.0, the DLL build doesn't contain it yet. They acknowledged this is a problem that they will fix. So this is again blocked on upstream: https://github.com/ckeditor/ckeditor5/issues/11516.
Thanks @bnjmnm for creating that issue upstream!
Comment #20
wim leersThere should be a new CKEditor 5 release tomorrow. That means we should already start writing a test.
Comment #21
bnjmnmComment #22
lauriiiIt seems like
<table>element is now always wrapped with a<figure>. Bumping this to major based on that, even though this probably should be a critical since this is tagged as a stable blocker.Comment #23
bnjmnmTests are expanded and confirm
<figure>(i believe that's fine provided it's only in the editor?)<figure>, caption is in the expected structure and matches CKEditor 4<caption>. The tests are failing because of this.SO my next step is to see why the downcast markup that has caption within table is not translating to the rendered markup.
Comment #24
wim leersYAY!
Those first two bullets are indeed as expected 👍
Third bullet: do you mean when viewing a saved node inside CKEditor (i.e. editor downcast) or outside CKEditor (i.e. as visitor)?
Comment #25
wim leersThis doesn't need to be an "admin" user — a "content creator" is just fine!
This permission is not needed.
This is the only place
$this->adminUseris used — hence it does not need to be an object property.Übernit: s/Confirm/Confirms/
Übernit: this and other methods could have the
voidreturn type.Comment #26
bnjmnmAddresses #25 and the test failures I mentioned in #23 (just forgot to explicitly add
<caption>)Comment #27
wim leersThis should still be removed. 🤓
👍
Comment #28
bnjmnm🤦
Here it is!
Comment #30
wim leersLooks great, thanks! 👍
Unrelated functional JS test failures for Layout Builder and Media → re-testing.
Comment #35
lauriiiCommitted 613b862 and pushed to 10.0.x. Also cherry-picked to 9.4.x and 9.3.x. Thanks!
Committed from 40000ft above the Labrador Sea on the way to DrupalCon Portland ✈️
Comment #36
wim leers🦅😄