-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't attach the image resizer to images inside the HTML embed preview #8444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the trick with matches
as we have to somehow detect this case on the view level.
However, I'm worried that this fix will cover only one case of html embed and could fail in other cases:
- custom image plugin
- upcoming inline image
- dunno if media embed could have img inside?
ps.: I feel that I've might miss something so please double check what I've wrote if that makes sense.
@@ -56,6 +56,11 @@ export default class ImageResizeHandles extends Plugin { | |||
editingView.addObserver( ImageLoadObserver ); | |||
|
|||
this.listenTo( editingView.document, 'imageLoaded', ( evt, domEvent ) => { | |||
// The resizer must not be attached to images inside HTML embed preview. | |||
if ( domEvent.target.matches( 'div.raw-html-embed__preview img' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix will work for html embed preview, but only for that.
On the horizon there's an inline image feature so the check should be specific for the CKEditor's image plugin.
In other words it should check if the target image is the one that we need to attach to not if it is invalid one.
TL;DR: the check should be something like figure.image img
(to check).
The inline image would be just an img
without a figure, hence the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea to check more than just one unsupported case (the HTML embed image previews) by reversing the logic and allow only known (supported) images to be resized 👍🏻
The media embed can theoretically have an image inside, because it creates an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM 👍
Suggested merge commit message (convention)
Fix (image): Don't attach the image resizer to images inside the HTML embed preview. Closes #8433.