Skip to content
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

Fixes copy/paste of images from browsers like Google Chrome #1000

Closed

Conversation

Rohland
Copy link

@Rohland Rohland commented Oct 20, 2022

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.

See https://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/plain and a file. If there are only two types, i.e. text/html and file, we should be good (hopefully!).

@Rohland Rohland changed the title Fix image copy/paste from browsers like Google Chrome Fixes copy/paste of images from browsers like Google Chrome Oct 20, 2022
@Nitrodist
Copy link

Oh hello, creator of Trix while at Basecamp, et al.! Thank you for the PR.

@jeremy
Copy link
Member

jeremy commented Sep 12, 2023

Ported to ES6 in #1081.

@jeremy jeremy closed this Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants