-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Pay Aug 18 if no regressions] Copy to clipboard - Unable to copy images or links #3313
Comments
Triggered auto assignment to @TomatoToaster ( |
Cool I think this makes sense to be done externally. |
Triggered auto assignment to @puneetlath ( |
Looks like this is fixed for links, but still needs to be addressed for images. Created an Upwork job for it. |
Sorry, but I don't see it's fixed for any type. |
For Images, we have to use the native Modules for Mobile devices but previously we left that part intentionally. So are we ready to go that path @roryabraham? For links, I suggest a different context menu than the current one. It would have two items |
I think that's not what the issue meant. Try |
For all attachments (not just images) some html parsing needs to happen. To extract links from html. Here is how what I would do for images for example: const el = document.createElement('html');
el.innerHTML = html;
const imageUrl = el.querySelector('img').getAttribute('src');
EDIT: Sorry, I forgot this is react native world. We can use |
@puneetlath I updated the OP here a bit, can we please update the Upwork job to reflect that? |
Hm, @roryabraham @iwiznia @parasharrajat I think a few different issues are being conflated here. The original issue reported here was that when you copy a message that contains an image, it puts the raw html on your clipboard instead of just the image. This also was happening with messages that contained links, but isn't anymore (I had already removed @isagoico's screenshot that showed it). I think we should split up what y'all are saying into separate issues and implement it slightly differently.
That's how I'd implement this. And I'd do it in two different issues. What do y'all think? |
There's #3317 too |
It's a good summation of the problem, but I would approach it slightly different. Those two issues could be separate, but imo they should not be. I'd prefer to see the same contributor work on both these issues (if they want to do 2 PRs, that's fine). My reasoning is that, at a very high level the solution is the same: When the user right-clicks or long-presses an html element in a chat message, the
I'm not a huge fan of this implementation. It would work for now, but in order to complete
Relying on this would be fine, but since we have to implement a more sophisticated solution for links anyways, let's use the same solution for images. Plus then we get the added bonus that it will be easier to support images + text + links together in one message, if we ever want to do that. |
Okay I'm good with that. What do you think of what I proposed for links?
|
Hmmm I'm not sure I completely understand that proposal.
Is this true on mobile? I don't think so... |
Any new proposals here? @puneetlath Should we increase the offer for this ticket? |
@roryabraham I was looking at this issue to possibly work it. I agree with you that we should be able to wrap the individual HTML elements ( and ) so that when a user clicks that it brings up specific action menus. We can do this in the RenderHTML file if we pull out and reuse some of the logic for positioning in the ReportActionItem controller. The issue I was seeing was there doesn't seem to be an off-the-shelf copy-image solution that we know is going to work on all devices (ios, web, and mac). React-native docs point us to @react-native-clipboard/clipboard but if you look they don't yet support images react-native-clipboard/clipboard#6. We could make something custom of course but seems like that's its own issue. If I can see a workable solution for images in the clipboard then I can make a proposal. |
@Drewfergusson Would you be interested in working on the portion of this that targets links/URLs? If you can build a general solution to tailor the content of our custom context menu based on the html tag that was interacted with to open the menu, I think that would be a really valuable first step. I think that you're correct that the solution will involve the Then we could move on to a follow-up that focuses on the ability to copy images, and more-or-less copies your solution used to target links in the context menu. |
@roryabraham sounds like a plan. I just submitted a proposal on Upwork. Also if you make a separate ticket for creating an image to the clipboard solution link it and I'd like to take a look at it too. |
PROPOSAL We get the source of the image OR URL from HTML at this point and copy it to the clipboard instead of the HTML and also show appropriate text in case of the image OR URL at this point Thanks I used this package and I think we can use image/URL preview when we have URL in the message as you can see this approach used in slack or another social platform by pasting some URL. |
Thanks @aliabbasmalik8, but I think we're going to move forward with @Drewfergusson on this issue for now. @puneetlath Will you please hire @Drewfergusson on Upwork? |
@Drewfergusson I don't see a proposal from you on this job https://www.upwork.com/jobs/~015ed0068d5788ef5a. Can you apply there so I can hire you? Thanks! |
@puneetlath I submitted my proposal with the name Andrew Michael Ferguson. It was a couple of days ago so you may have to look. Not sure if this link works for you but this is the link where I can view my proposal. https://www.upwork.com/ab/proposals/1409996432714612737 |
Hey, @puneetlath @roryabraham I was working on testing the solution I came up with and ran into an issue with what I proposed. In my proposal, I am essentially creating a reusable component to wrap some "thing" (in this case the link) with a react native Pressable component . This special Pressable then triggers a Popover. This works fine on browser, desktop, and mobile web. (PR here) For mobile though, links at their core have a Text element with an onPress attribute. It seems that on mobile, events are not propagating out as they do in a browser normally. (or something is preventing this that I don't know of). If I remove the onPress attribute from the Text component, wrapping it with the special Pressable I created works fine. As soon as I add back the onPress attribute then wrapping does not propagate onPress nor onLongPress events. It seems like the same Text component or Pressable component will have to have to have the onLongPress and on onPress attributes. It will not be as cleanly composable as I first thought. Still working on a nice solution on the mobile side and should have an update soon. Let me know if anything comes to mind. |
@roryabraham @puneetlath I left a comment in the PR (link) that it's ready for review, just following up here. |
Was curious about this issue because I often try to right-click to copy links. |
Just got my first review of @Drewfergusson's PR in today, so we're making progress 👍 |
PR has been merged. Will be paid out on Aug 18 if no regressions. |
Just to notify you guys. Image part is still pending. May be a separate issue. Linked PR only added feature for Links |
Yeah, as stated in this comment and the previous one, @Drewfergusson only worked on the portion of this issue related to copying links, but he also set up a really easily extensible framework to display different types of context menus depending on what was interacted with. So we need to follow-up on this issue with part 2. I created a separate issue over here: #4629 |
Paid! Thanks for the great work @Drewfergusson. |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Expected Result:
ReportActionContextMenu
, but theCopy to Clipboard
menu item should instead sayCopy URL to Clipboard
. Pressing that menu item, the link url should be copied to the clipboard.ReportActionContextMenu
, but theCopy to Clipboard
menu should instead sayCopy Image to Clipboard
. Pressing that menu item, the image should be copied to the clipboard.Actual Result:
When copying and pasting an image, the HTML coding is displayed instead of the link or image.
Action Performed:
Workaround:
No way of copying an image by using copy to clipboard.
Platform:
Where is this issue occurring?
Web ✔️
iOS ✔️
Android ✔️
Desktop App ✔️
Mobile Web ✔️
Version Number: 1.0.60-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
Expensify/Expensify Issue URL:
View all open jobs on Upwork
From @iwiznia https://expensify.slack.com/archives/C01GTK53T8Q/p1622579145427200
Upwork job: https://www.upwork.com/jobs/~015ed0068d5788ef5a
The text was updated successfully, but these errors were encountered: