clipboard
clipboard copied to clipboard
Image support
Describe the Feature
I'd like to be able to copy and paste images. Would the maintainers be open to a PR that adds support?
Possible Implementations
This should be pretty doable on iOS. There is a simplistic copy implementation on StackOverflow that I could update to use RCTImageLoader
so that it would support any RN URI (including fake ones like the "ph://" protocol).
For paste on iOS, I could make an API that lets users pick between PNG/JPEG representations, as well as between having the file saved to disk or delivered as a base64-encoded data URI.
It appears that support on Android won't be as easy. This StackOverflow question addresses copy-paste of images on Android, and the tl;dr is that "copy/paste can only be achieved when the two applications work together". That said, the answer is pretty old, so this may have been gotten easier as of late. I can look into it more later.
@harisbaig100, friendly ping! :)
@Ashoat sounds great! I'll be open for a PR to have this implemented.
I still want to do this, but it may be a couple months before I can get to it unfortunately. If somebody gets to it before me that would be great, otherwise I will check back in when I get started :)
Very interested in this!
@Ashoat @Naturalclar @watadarkstar @harisbaig100 Have you guys get any way to copy image to clipboard in iOS react-native? Please Help!!
Also interested in this!
👍 would love to see this 👍
We specifically wanted to add the ability to paste into a TextInput
. To do this we ended up needing to make some patches to react-native
, and it ultimately didn't have to do with this package at all. You can see the patch here, and you can look around that repo to see how we're using it exactly.
@atulsmadhugiri just put up a PR to add the ability to programmatically retrieve images from the clipboard! This is only part of the story... the ability to programmatically set the clipboard is missing, and as mentioned above the TextInput
stuff requires patching react-native
itself.
.
Any updates on this? I tried using react-native-file-provider as an alternative implementation with little success :thinking:
Clipboard.setImage
is already available/working for me on iOS but it says iOS only. Would love support for Android.
/**
* (iOS Only)
* Set content of base64 image type. You can use following code to set clipboard content
* ```javascript
* _setContent() {
* Clipboard.setImage(...);
* }
* ```
* @param the content to be stored in the clipboard.
*/
setImage(content: string): void;