clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

Image support

Open Ashoat opened this issue 5 years ago • 12 comments

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 avatar Jun 19 '19 19:06 Ashoat

@harisbaig100, friendly ping! :)

Ashoat avatar Jul 12 '19 18:07 Ashoat

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

Naturalclar avatar Feb 03 '20 01:02 Naturalclar

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

Ashoat avatar Feb 03 '20 16:02 Ashoat

Very interested in this!

watadarkstar avatar Oct 31 '20 04:10 watadarkstar

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

tvpranav avatar Nov 04 '20 18:11 tvpranav

Also interested in this!

JulesPatry avatar Nov 19 '20 16:11 JulesPatry

👍 would love to see this 👍

roryabraham avatar Mar 22 '21 18:03 roryabraham

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 avatar Mar 22 '21 18:03 Ashoat

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

Ashoat avatar May 17 '21 22:05 Ashoat

.

nguyentuanit97 avatar Mar 16 '22 05:03 nguyentuanit97

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

karaolidis avatar Sep 06 '22 15:09 karaolidis

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;

tsalama avatar Dec 22 '22 21:12 tsalama