- Issue created by @wim leers
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
FYI: thanks to ๐ฑ [meta] Test against CKEditor 5 nightly Active , we already know that we'll need to change the
drupalImage
plugin, because on September 1, tests still passed โ , but on September 18, they failed โ .Expected failures:
CKEditor5Test::testEditorFileReferenceIntegration()
CKEditor5Test::testAttributeEncoding()
ImageTest::testAlignment()
ImageTest::testWidth()
ImageUrlTest::testAlignment()
ImageUrlTest::testWidth()
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Issue summary updated to make this a 2-step process instead of a 5-step process. Will make future updates simpler ๐
- last update
about 1 year ago 30,347 pass, 6 fail - @wim-leers opened merge request.
- last update
about 1 year ago 30,347 pass, 6 fail - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,347 pass, 3 fail - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Yay, both
::testAlignment()
cases now pass ๐Everything else seems centered on the presence of this new
style="aspect-ratio:WIDTH/HEIGHT"
in the<img>
markup.Seems doable!
- Status changed to Needs review
about 1 year ago 12:13pm 12 October 2023 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
โ ๏ธ upstream
<img height
was implemented in an incompatible way๐คฉ 1. Drop a lot of overrides from
drupalImage
!We actually implemented a lot of overrides to get
width
andheight
working reliably.Looks like we can just
rm -rf
that: https://git.drupalcode.org/project/drupal/-/merge_requests/4989/diffs?co... โ 131 lines gone ๐ฅณ๐คทโโ๏ธ 2. Presence of
style="aspect-ratio:3456/2160"
https://ckeditor.com/docs/ckeditor5/latest/updating/guides/update-to-40.... says:
The
aspect-ratio
attribute has been added to the imageโs properties to handle situations when the file is resized or scaled with a tweaked aspect ratio.That sounds like it'd be
<img aspect-ratio>
โฆ but it's actually not an attribute, but a
CSS property. ๐ฌ IOW: a value of thestyle
attribute:<img style="aspect-ratio:โฆ">
.The use of the
style
attribute means that this will not work in Drupal, since Drupal's measures to protect content creators from XSS injection will strip any and allstyle
attributes:// Apply XSS filters when editing content if necessary. Some types of text // editors cannot guarantee that the end user won't become a victim of XSS. if (!empty($element['value']['#value'])) { $original = $element['value']['#value']; $format = FilterFormat::load($element['format']['format']['#value']); // Ensure XSS-safety for the current text format/editor. $filtered = editor_filter_xss($original, $format); if ($filtered !== FALSE) { $element['value']['#value'] = $filtered; }
โ
\Drupal\editor\Element::preRenderTextFormat()
editor_filter_xss()
is smart enough to only run it for text formats that do have XSS filtering, which is why it will not do anything forfull_html
for example.Now, this is not even a big deal, because we simply do not need that information! Drupal uniquely never allowed resizing without respecting the aspect ratio.
Unfortunately,
attachDowncastConverter
'ssetRatioForInlineImage
parameter only applies to inline images, and nothing else in the relevant commit appears us to override this behavior. Still, we can work around this.๐ฑ 3. Reliance on
style="aspect-ratio:3456/2160;width:419px;"
for actually resizingOh noes โฆ resizing that 3456x2160 image only seems to work in CKEditor 5 itself? It does not work in the final rendered result?
Turns out that
width
andheight
are always the original width and height, and not the resized ones! ๐ซฃFine, this makes sense for certain HTML-centric approaches. But we'll at least need our downcast to behave differently, because otherwise a lot of contrib/custom modules will break.
So we'll have to restore our own downcast and adjust it.
However โฆ it appears that the
Original
button then will not work at all.This too seems surmountable:
setImageNaturalSizeAttributes()
's logic should be tweaked. AFAICT just removing a singleif
-statement would be enough:this.editor.model.change( writer => { const img = new global.window.Image(); this._domEmitter.listenTo( img, 'load', () => { โกโกโกโกโกif ( !imageElement.getAttribute( 'width' ) && !imageElement.getAttribute( 'height' ) ) {โกโกโกโกโก // We use writer.batch to be able to undo (in a single step) width and height setting // along with any change that triggered this action (e.g. image resize or image style change). this.editor.model.enqueueChange( writer.batch, writer => { writer.setAttribute( 'width', img.naturalWidth, imageElement ); writer.setAttribute( 'height', img.naturalHeight, imageElement ); } ); โกโกโกโกโก}โกโกโกโกโก this._domEmitter.stopListening( img, 'load' ); } ); img.src = src; } );
๐ That would always get the loaded image width/height as the correct one. The browser will load the image anyway, so there's no extra cost.
Conclusion
It is possible in theory to do all this overriding on our end, but AFAICT a
40.0.1
release from the CKEditor 5 team with:- a tweaked
setImageNaturalSizeAttributes()
- always make
resizedHeight
available
I will discuss this in the meeting I have with them in ~30 mins. ๐
- a tweaked
- last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,356 pass, 2 fail - Status changed to Postponed
about 1 year ago 2:08pm 12 October 2023 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Discussed in detail with @witeksocha. He recalls there was a reason to remove
resizedHeight
, but alas it was not documented. He also recalls there was a good reason to not always set the natural width & height.He'll talk to the engineer who led this upstream change and will get back to me early next week ๐
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
New config option:
From the release notes:
list: Allow restricting list item content to a single text block by disabling the
list.multiBlock
configuration option.๐ Now available in Drupal.
- last update
about 1 year ago Custom Commands Failed - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
They're working on this upstream at https://github.com/ckeditor/ckeditor5/issues/15185.
- Status changed to Needs work
about 1 year ago 11:09am 25 October 2023 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
No comments were posted there, but it looks like 2 days ago @niegowski linked a PR (https://github.com/ckeditor/ckeditor5/pull/15222) that provides the necessary example here.
- Assigned to wim leers
- last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
I was able to port https://github.com/ckeditor/ckeditor5/pull/15222 by mostly copy/pasting and it works ๐๐ฅณ
However, it looks like it does not support %-based
width
values.Let's find out what other tests failโฆ
- Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - Open on Drupal.org โEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Okay, I've got all tests passing now, except for one:
testWidth with data set "Image resize with percent unit (only allowed in HTML 4)"
โฆ for both locally hosted (aka uploaded) images and remotely hosted images.
That makes sense: we previously already had to write custom logic (see #3249592: [drupalImage] upcast assumes HTML5: px unit, but HTML4 allowed % unit โ ) to keep these working, and the code I've copy/pasted from upstream does not handle this.
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Also, we absolutely need to make sure that that continues to work correctly, because until ~6 months ago, image resizing in CKEditor 5 was using
%
, notpx
: ๐ CKEditor 5 resizes images with % width instead of px width (the CKEditor 4 default): breaks image captions *and* is a regression Fixed . - last update
about 1 year ago 30,400 pass, 4 fail - last update
about 1 year ago 30,438 pass - last update
about 1 year ago Custom Commands Failed - Issue was unassigned.
- Status changed to Needs review
about 1 year ago 8:25am 27 October 2023 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Just pushed the missing update path test coverage.
This is now ready for review ๐
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Clarify the issue summary.
- last update
about 1 year ago 30,439 pass - Status changed to RTBC
about 1 year ago 2:22pm 28 October 2023 - ๐บ๐ธUnited States smustgrave
Since the main feature for core seems to be list
Disabled Allow the user to create paragraphs in list items (or other block elements)
Created a page placing<ul><li>a</li><li><p>paragraph 1</p><p>paragraph 2</p></li></ul>
P tags got turned to liEnabled Allow the user to create paragraphs in list items (or other block elements)
Create a page placing<ul><li>a</li><li><p>paragraph 1</p><p>paragraph 2</p></li></ul>
P tags remained the same. - last update
about 1 year ago 30,465 pass - last update
about 1 year ago 30,482 pass - Status changed to Needs work
about 1 year ago 5:13pm 1 November 2023 - Status changed to Needs review
about 1 year ago 11:04am 2 November 2023 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
The irony โ @catch just talked to me about this ~1.5 week ago and I still forgot ๐ ๐ Matched the pattern that was used in โจ Ability to configure additional languages (e.g. "bash" or "SQL") for CKEditor 5 CodeBlock plugin Fixed .
- Status changed to RTBC
about 1 year ago 2:21pm 2 November 2023 - ๐บ๐ธUnited States smustgrave
Didn't think of that post_update vs presave so that's on me.
But looks to have been addressed and tests are green.
- ๐ฌ๐งUnited Kingdom catch
@Wim does that mean we're locked on CKEditor 39 on 10.1.x for the forseeable future or would it be possible (and if so, desirable) to backport just the update without the configuration changes - not sure how much it is API change vs. new feature.
- last update
about 1 year ago 30,486 pass - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
It is possible to backport without the
ckeditor5_list
plugin config changes, and instead just hardcode the default behavior in HEAD (multiBlock: true
.I did not propose that because I was under the impression that the policy is to never update JS packages unless for very strong reasons. We did have such very strong reasons for CKEditor 38.1.0 ( https://www.drupal.org/project/drupal/issues/3340578#fixed-10.1.1 ๐ฑ [meta] [upstream] Prioritized CKEditor 5 upstream blockers Active ) and 39.0.0 ( https://www.drupal.org/project/drupal/issues/3340578#fixed-10.1.3 ๐ฑ [meta] [upstream] Prioritized CKEditor 5 upstream blockers Active ), because each of them fixed data loss issues or upgrade-blocking-missing-functionality problems.
For this one, the impact is far less severe. And the potential risk of unknown/unadvertised breaking changes does not seem to outweigh the presence of
<img height>
๐If you want to see this backported nonetheless, I'd be happy to work on a
10.1.x
-specific MR ๐ - ๐ฌ๐งUnited Kingdom catch
I don't strongly want to backport it, I just wondered whether it's better to leave 10.1 on 39 or 40. If there's no strong reason to update let's not, given we only have about 1 normal patch release of 10.1 left anyway.
- Status changed to Needs work
about 1 year ago 9:58am 3 November 2023 - Status changed to RTBC
about 1 year ago 10:47am 3 November 2023 - Status changed to Fixed
about 1 year ago 2:08pm 3 November 2023 - ๐ฌ๐งUnited Kingdom catch
Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!
- Status changed to RTBC
about 1 year ago 2:40pm 3 November 2023 - Status changed to Fixed
about 1 year ago 2:48pm 3 November 2023 Automatically closed - issue fixed for 2 weeks with no activity.