Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Allow pasting an image with data URL scheme in src, if strict CSP rules are defined #8707
Allow pasting an image with data URL scheme in src, if strict CSP rules are defined #8707
Changes from 2 commits
8737a48
a0af560
8c6c7a1
9079fcd
ac23816
402e793
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Minor breaking change –> should be added to the merge commit message.
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.
Added.
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.
There is no longer a minor breaking change in this PR, because the original
fetchLocalImage()
public helper is unchanged.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'm not sure if we should not use a default value for
qualityArgument
- it's 0.92 for jpeg. What do you think @Reinmar ?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 have no idea what it affects. I don't know the context of this code. Could you try to explain the context and pros/cons of both approaches?
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 current implementation is just fetching the image from
data:
URL so its quality remains the same as the pasted image, but in this PR we are usingCanvas
to draw the image and thentoBlob
is used to generate jpeg (or other image formats). While converting to jpeg, the image data is compressed. By default,toBlob
is using 0.92 compression ratio so it affects the size of the generated blob but also the quality of the image. The question is whether we should let the browser to use the default quality or we should try to keep the best quality possible (the hardcoded1
in the code above).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.
Still, pros/cons of both options are not 100% clear for me. E.g. I can only guess that using
1
will increase network traffic. Am I right?Also, if we'll use
0.92
will it work execatly like it worked before? Or will like... compress again something that was already compressed adding another level of data loss to what's already a compressed thing?Again, this requires analysis from you guys and explaining to me what does it actually do. Consider me dumb as a chair's leg for the purpose of this review ;)
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.
This line triggers an alert with
[object Event]
in it, maybe we could replace this line withimage.addEventListener( 'error', () => reject() );
to ignore those errors?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, good hint 👍🏻