angular-clipboard icon indicating copy to clipboard operation
angular-clipboard copied to clipboard

throw failure copy

Open je3f0o opened this issue 8 years ago • 6 comments

Hi, and thank you for this small module. I'm trying to resize image and convert to base64 text and copy to clipboard. But it throws error when higher resolution image to copy. Is copy text has limit ?

je3f0o avatar May 30 '16 05:05 je3f0o

I'm not aware of any limitations to the size of what you copy to the clipboard (except for actual memory limitations in the system). Which error are you getting?

omichelsen avatar Jun 01 '16 00:06 omichelsen

in the title I said throw failure copy. When I inspect in console it says "failure copy". I tried to use service and copyText lower than 400px width image it worked just fine. width: 400px image to base64 44k characters copied fine. But when I tried to copy width: 800px image to base64 and copy it failed. And I don't think there is actual memory issue. Because when I'm trying to copy resized base64 image result put into textarea and using Command + C it copied. Actually right now I'm using Command + C manually copying. It scares the users. Because they don't know what is going on xD I will reproduce the error in plunker later...

je3f0o avatar Jun 03 '16 05:06 je3f0o

I was having a similar issue (same error message) when trying to copy a long text string (over 32,000 characters). From testing with other methods, I think that the issue is due to the permissions from the trusted user event (button click). I placed a timeout on the command document.execCommand('copy'), and any timeout greater than 1000ms after the click event would cause the command to fail (no matter how small the text being copied was). So if your function is taking more than 1second after the click to generate/copy the text, then document.execCommand('copy') seems to fail. This was done on Chrome v.51.0.2704.84. However, I am so far unable to find any documentation on how the trusted user events are handled to support this theory.

michael-michael1 avatar Jun 07 '16 15:06 michael-michael1

I still get this error. I am using it as a service with Google Chrome (latest version). The following snippet is run on click.

$http.get('api/passengers/generatePublicLink/'+$stateParams.id).success(function(id){
    if (!clipboard.supported) {
        console.log('Sorry, copy to clipboard is not supported');
    }else{
        clipboard.copyText('mytext');
   }
});

Is there a solution yet?

molerat619 avatar Jul 16 '16 13:07 molerat619

I'm also getting this error on some of the browsers, not all of them, but if it happens on the same machine it happens on all browser, can it be related to browsers permissions settings ?

liadlivnat avatar Jul 26 '16 14:07 liadlivnat

I'm getting this error too when I try to copy a big text, and then I found a similar issue from stackoverflow https://stackoverflow.com/questions/44774820/copying-to-clipboard-with-document-execcommandcopy-fails-with-big-texts I guess this the same?

YungMH avatar Jan 31 '18 14:01 YungMH