- Notifications
You must be signed in to change notification settings - Fork1.1k
Fixes copy/paste of images from browsers like Google Chrome#1000
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Closed
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Nitrodist commentedDec 1, 2022
Oh hello, creator of Trix while at Basecamp, et al.! Thank you for the PR. |
Member
jeremy commentedSep 12, 2023
Ported to ES6 in#1081. |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
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.
Uh oh!
There was an error while loading.Please reload this page.
The Bug
Assume two users, A and B, are collaborating.
User A uses their Google Chrome browser to copy an image (right clicks on an image > Copy Image) and pastes it into Trix. The source of the image is a private application that only A has access to (i.e. the image path is protected by authentication).
User A can see their image is successfully rendered in Trix, and happily saves their changes.
User B logs in to contribute to the content. They fire up Trix.
The image pasted by User A cannot be displayed (since User B does not have access to the path).
Why is this a bug?
When User A pasted into Trix, the clipboard data contains both the image URL/markup + actual file.
Seehttps://input-inspector.javan.us/profiles/r1s8c7DqbOQXXjz76mj0 for an example.
So, there are two items in the clipboard, however, Trix doesn't treat the paste as a file, but rather markup. This is because of existing code that tries to work around a Microsoft Office quirk, that includes an image of the copied text when content is copied from Word etc.
The Proposed Fix
Without inspecting the content to deal with the MS Word issue (we could search for
MsoNormal), we simply invoke the existing logic if there are 3 (or more) types, i.e.text/html,text/plainand a file. If there are only two types, i.e.text/htmland file, we should be good (hopefully!).