[$250] [Image] Implement the ability to copy images to the clipboard
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Coming from https://github.com/Expensify/App/issues/3313
Action Performed:
Right-click or long-press on an image in a chat.
Expected Result:
- A context menu appears, displaying a single option:
Copy image to clipboard - Clicking on this option should copy the image to the clipboard, where it can be pasted somewhere else.
Note: the solution implemented must be an offline-first solution. Meaning the user should be able to copy the image to their clipboard, whether or not they have internet connection.
Actual Result:
- The normal context menu appears.
- Clicking on
Copy to clipboardcopies the HTML image tag to the clipboard, not the binary image itself.
Workaround:
Screenshot the image? Also you can click on it and download it.
Platform:
- Web
- iOS
- Android
- Desktop App
- Mobile Web
Version Number: 1.0.85-3
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
Upwork job: https://www.upwork.com/jobs/~012fd9a807faaf42aa View all open jobs on Upwork
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01b3973ec74ce159e9
- Upwork Job ID: 1782953316490067968
- Last Price Increase: 2024-05-01
Okay, there was a fair deal of discussion over in https://github.com/Expensify/App/issues/3313 and other issues, but the task at hand here is to:
- (internal) Create an
Expensify/fork of https://github.com/react-native-clipboard/clipboard - Create a separate fork of https://github.com/react-native-clipboard/clipboard for local testing.
- Provide a complete implementation of this issue in your separate fork.
- Point this project and your fork for local testing.
- Add a new context menu type for images, display it when images are right-clicked or long-pressed. This PR might serve as a useful guide.
- Once that's working, submit a PR from your fork of
react-native-clipboardto theExpensify/react-native-clipboardfork. - Also submit a PR from your fork of
react-native-clipboardto the upstream project. - Create a PR in this repo with your implementation from step
5above, but point the project at theExpensify/react-native-clipboardfork instead of your personal one. (should be on HOLD until the PR from step6is merged. - Lastly, if/when your PR from step 7 is merged by the project maintainers, create another PR to point this repo at the upstream repo: https://github.com/react-native-clipboard/clipboard
No Upwork job created for this yet.
Upwork job created here: https://www.upwork.com/jobs/~011432fcc2168828e1
@Drewfergusson would you be interested in this? Given you implemented the first part.
@puneetlath things have gotten quite a bit busier for me lately so I'm going to have to pass.
@puneetlath, @roryabraham Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
No new proposals here
@puneetlath, @roryabraham Whoops! This issue is 2 days overdue. Let's get this updated quick!
@puneetlath, @roryabraham it looks like no one is assigned to work on this job. Please double the price or add a comment stating why the job isn't being doubled.
Updated price to $2000.
Proposal
Currently used setString function for copy to clipboard for attachement

And when paste, it is not parsing content correctly in handlePaste for textinput

embeddedImages length always showing 0
Reason: setString to clipboard making extra span tag image element converted to string
To fix issue
-
Get image element text from clipboard

-
Convert it to html tag from string

-
Attached Working Video
https://user-images.githubusercontent.com/12084368/130595083-442b227f-a1e7-4a9e-b71e-7b7304144234.mov
Please review and give me feedback @roryabraham , @puneetlath
@MTN718
Reason: setString to clipboard making extra span tag image element converted to string
Sorry, I'm having difficulty understanding this. Can you help me understand this better?
Other than that, there are two main concerns I have with your proposal:
- Keep in mind that this is a react-native codebase, so we need a solution that works not only on web, but also on iOS and Android. Ideally, we would create a solution that works for both iOS/Android and react-native-web, so that we don't need two separate implementations. See the following resources:
- Expensify/App Philosophy, particularly section 5 titled "Cross Platform 99.9999%"
- https://github.com/react-native-clipboard/clipboard/issues/6
- https://github.com/Expensify/App/issues/4629#issuecomment-897981246
- Also, can you verify with your existing solution that the image binary is copied to the clipboard such that it can be pasted into another program, such as Notes, Google Docs, or Microsoft Word?
Proposal
Use native share workflow for mobile (with react-native-share ), and keep web/desktop version with the "Copy to Clipboard" Context menu.
Explanation: UX is increased, by having more options: with just one step users can copy the content, or send it to other apps like WhatsApp, Slack, Note (or any other workflow they prefer)
Solution
Create a <Sharable/> component, similar to <PressableWithSecondaryInteraction/>, that instead of showing the context menu, it would show the native ios/android share menu. This is the same behavior that slack takes when long-pressing a link for example:
This is how it would look like in android and ios:
@anboia That is an interesting alternate solution, I love it!
That said, I think it should really be a separate context menu option. I recommend that you create a separate issue in this repo to propose adding a share option to the context menu using the native share menu, and we can discuss over there. Plus, if we decide to move forward with this new feature, there's an additional bonus we pay to contributors if you open an issue and also implement the solution. 🤑
Found solution for web version.
https://user-images.githubusercontent.com/12084368/130682096-fcb1d3a1-afe9-4ef2-b59d-6857e41fceb1.mov
Read image blob data from url and make clipboard item and write to clipboard Used clipboard.write instead of setString One Notice: Image url should be png file. clipboard support only image/png type. can't save jpg file to clipboard So we should be discuss about convert image jpg to png from server or frontend.
https://user-images.githubusercontent.com/12084368/130692002-4fb74592-6db5-4fb4-903a-ba8a691d325d.mov
@roryabraham one question, currently how to open context menu in the ios? long press on image is working?
It's mobile web version
https://user-images.githubusercontent.com/12084368/130682485-44ac9a44-5f73-403d-b8f7-f53d76b67f74.mov
@roryabraham one question, currently how to open context menu in the ios? long press on image is working?
Yeah, longPress should open the context menu.
One Notice: Image url should be png file. clipboard support only image/png type. can't save jpg file to clipboard So we should be discuss about convert image jpg to png from server or frontend.
Really? I've never encountered this issue
@roryabraham I think we already have an open issue #1294 for share menus.
@parasharrajat https://github.com/Expensify/App/issues/1294 is slightly different – I believe that's about adding New Expensify as an option in native share menus, not about exposing native share menus from within New Expensify