react-native-clipboard / clipboard

React Native Clipboard API for both iOS and Android.
MIT License
689 stars 140 forks source link

Image support #6

Open Ashoat opened 5 years ago

Ashoat commented 5 years ago

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.

Ashoat commented 5 years ago

@harisbaig100, friendly ping! :)

Naturalclar commented 4 years ago

@Ashoat sounds great! I'll be open for a PR to have this implemented.

Ashoat commented 4 years ago

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

watadarkstar commented 3 years ago

Very interested in this!

tvpranav commented 3 years ago

@Ashoat @Naturalclar @watadarkstar @harisbaig100 Have you guys get any way to copy image to clipboard in iOS react-native? Please Help!!

JulesPatry commented 3 years ago

Also interested in this!

roryabraham commented 3 years ago

👍 would love to see this 👍

Ashoat commented 3 years ago

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.

Ashoat commented 3 years ago

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

nguyentuanit97 commented 2 years ago

.

karaolidis commented 2 years ago

Any updates on this? I tried using react-native-file-provider as an alternative implementation with little success :thinking:

tsalama commented 1 year ago

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;