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

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

Open rlpacht opened this issue 9 years ago • 8 comments

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?

rlpacht avatar Oct 03 '16 19:10 rlpacht

@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

sudodoki avatar Oct 03 '16 19:10 sudodoki

It's happening for me in chrome.

rlpacht avatar Oct 03 '16 20:10 rlpacht

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

shrey18111 avatar Nov 01 '16 20:11 shrey18111

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

sudodoki avatar Nov 02 '16 08:11 sudodoki

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

alejandro-arrabal avatar Jan 25 '17 13:01 alejandro-arrabal

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

gravitypersists avatar Mar 20 '17 23:03 gravitypersists

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

webuniverseio avatar Jul 12 '17 14:07 webuniverseio

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

webuniverseio avatar Jul 12 '17 14:07 webuniverseio