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

[$250] [Image] Implement the ability to copy images to the clipboard #4629

Closed
roryabraham opened this issue Aug 12, 2021 · 131 comments
Closed

[$250] [Image] Implement the ability to copy images to the clipboard #4629

roryabraham opened this issue Aug 12, 2021 · 131 comments
Assignees
Labels
Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors NewFeature Something to build that is a new item.

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Aug 12, 2021

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Coming from #3313

Action Performed:

Right-click or long-press on an image in a chat.

Expected Result:

  1. A context menu appears, displaying a single option: Copy image to clipboard
  2. 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:

  1. The normal context menu appears.
  2. Clicking on Copy to clipboard copies 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
@roryabraham
Copy link
Contributor Author

Okay, there was a fair deal of discussion over in #3313 and other issues, but the task at hand here is to:

  1. (internal) Create an Expensify/ fork of https://github.com/react-native-clipboard/clipboard
  2. Create a separate fork of https://github.com/react-native-clipboard/clipboard for local testing.
  3. Provide a complete implementation of this issue in your separate fork.
  4. Point this project and your fork for local testing.
  5. 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.
  6. Once that's working, submit a PR from your fork of react-native-clipboard to the Expensify/react-native-clipboard fork.
  7. Also submit a PR from your fork of react-native-clipboard to the upstream project.
  8. Create a PR in this repo with your implementation from step 5 above, but point the project at the Expensify/react-native-clipboard fork instead of your personal one. (should be on HOLD until the PR from step 6 is merged.
  9. 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

@roryabraham
Copy link
Contributor Author

roryabraham commented Aug 16, 2021

No Upwork job created for this yet.

@MelvinBot MelvinBot removed the Overdue label Aug 16, 2021
@puneetlath

This comment has been minimized.

@MelvinBot MelvinBot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 16, 2021
@Drewfergusson
Copy link
Contributor

@puneetlath things have gotten quite a bit busier for me lately so I'm going to have to pass.

@MelvinBot
Copy link

@puneetlath, @roryabraham Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@roryabraham
Copy link
Contributor Author

No new proposals here

@MelvinBot MelvinBot removed the Overdue label Aug 20, 2021
@MelvinBot
Copy link

@puneetlath, @roryabraham Whoops! This issue is 2 days overdue. Let's get this updated quick!

@MelvinBot
Copy link

@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.

@puneetlath

This comment was marked as outdated.

@MelvinBot MelvinBot removed the Overdue label Aug 23, 2021
@MTN718
Copy link
Contributor

MTN718 commented Aug 24, 2021

Proposal

Currently used setString function for copy to clipboard for attachement
image

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

image

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
    image

  • Convert it to html tag from string
    image

  • Attached Working Video

Screen.Recording.2021-08-24.at.5.42.13.PM.mov

Please review and give me feedback @roryabraham , @puneetlath

@roryabraham
Copy link
Contributor Author

roryabraham commented Aug 24, 2021

@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:

  1. 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:
  2. 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?

@anboia
Copy link

anboia commented Aug 24, 2021

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:

@roryabraham
Copy link
Contributor Author

@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. 🤑

@MTN718
Copy link
Contributor

MTN718 commented Aug 24, 2021

Found solution for web version.

Screen.Recording.2021-08-25.at.3.53.29.AM.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.

Screen.Recording.2021-08-25.at.5.23.05.AM.mov

@MTN718
Copy link
Contributor

MTN718 commented Aug 24, 2021

@roryabraham one question, currently how to open context menu in the ios? long press on image is working?

@MTN718
Copy link
Contributor

MTN718 commented Aug 24, 2021

It's mobile web version

Screen.Recording.2021-08-25.at.4.04.24.AM.mov

@trjExpensify trjExpensify changed the title [HOLD #12603][Image] Implement the ability to copy images to the clipboard [Image] Implement the ability to copy images to the clipboard Apr 12, 2024
@Beamanator
Copy link
Contributor

Hmm I've been treating this as a monthly priority :/ I did figure out that on an android device, you can go to chrome, search for an image, press & hold, and copy to the clipboard -> so shouldn't we make sure this is possible on our android app too? 👍

@trjExpensify
Copy link
Contributor

That would make sense to me.

@Beamanator
Copy link
Contributor

Cool so how about we open this back up for proposals! 🚀

@trjExpensify trjExpensify added Weekly KSv2 External Added to denote the issue can be worked on by a contributor and removed Monthly KSv2 Planning Changes still in the thought process labels Apr 24, 2024
@melvin-bot melvin-bot bot changed the title [Image] Implement the ability to copy images to the clipboard [$250] [Image] Implement the ability to copy images to the clipboard Apr 24, 2024
Copy link

melvin-bot bot commented Apr 24, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01b3973ec74ce159e9

@trjExpensify
Copy link
Contributor

Done!

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 24, 2024
Copy link

melvin-bot bot commented Apr 24, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (External)

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Apr 24, 2024
@trjExpensify
Copy link
Contributor

Awaiting proposals.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Apr 27, 2024
@trjExpensify
Copy link
Contributor

@roryabraham are you going to close this in favour of #41239 or something? 😕

@Beamanator
Copy link
Contributor

I'm fine with moving this to that new issue as long as we align on the desired outcome 👍

Copy link

melvin-bot bot commented May 1, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label May 2, 2024
Copy link

melvin-bot bot commented May 3, 2024

@Beamanator, @trjExpensify, @c3024 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@Beamanator
Copy link
Contributor

There's a decent amount of activity in #41239 so I'm going to close this one for that one

@melvin-bot melvin-bot bot removed the Overdue label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors NewFeature Something to build that is a new item.
Projects
No open projects
Archived in project
Development

No branches or pull requests