1 // Assumes the presence of an input element with ID #_copyInput
2 export const copyToClipboard = value => {
3 const listener = e => {
4 e.clipboardData.setData('text/plain', value)
6 document.removeEventListener('copy', listener)
9 // Required for Safari. Contents of selection are not used.
10 document.getElementById('_copyInput').select()
12 document.addEventListener('copy', listener)
13 document.execCommand('copy')