sudodoki / copy-to-clipboard

Copy stuff into clipboard from your browser using JS
http://sudodoki.github.io/copy-to-clipboard/example/
MIT License
1.32k stars 130 forks source link

Copied text has a grey background when pasted into gmail or google docs. #46

Open rlpacht opened 8 years ago

rlpacht commented 8 years ago

This is pretty much the same issue as #43 but now the background is grey instead of yellow. Do you know what might cause this and if there is a way to make that not happen?

sudodoki commented 8 years ago

@rlpacht which browser are you experiencing this in? Can you provide codepen/jsfiddle/jsbin with reproducible keys? Supposedly, https://github.com/sudodoki/copy-to-clipboard/commit/30590d47b9f4ae7d77e7d674ec206fefe2c94a49#diff-168726dbe96b3ce427e7fedce31bb0bcR26 should force this to have no background whatsoever

rlpacht commented 8 years ago

It's happening for me in chrome.

shrey18111 commented 7 years ago

@sudodoki This issue is happening for me in chrome as well when I paste into Google Sheets. When I perform the paste, the background color of the cells is this grey color.

sudodoki commented 7 years ago

@shrey18111 not sure what you mean - is Google Sheets using this library?

alejandro-arrabal commented 7 years ago

@sudodoki This issue is happening for me when I had styles for body element http://codepen.io/AArrabal/pen/dNzKjq?editors=0110

gravitypersists commented 7 years ago

this would be fixed by fixing https://github.com/sudodoki/copy-to-clipboard/issues/47 - by specifying 'text/plain' as the format type.

Until then, you can get around it by adding:

    document.addEventListener('copy', e => {
      e.clipboardData.setData('text/html', STRING_TO_COPY);
      e.preventDefault();
    });

see updated codepen: http://codepen.io/anon/pen/KWQxXG?editors=0110

webuniverseio commented 7 years ago

@gravitypersists doesn't seem to be working in latest Chrome

webuniverseio commented 7 years ago

Oh, that's because of text/html in the example, Should be text/plain 😄