export const copy = (text)=>{
if(navigator.clipboard && window.isSecureContext){
console.log(text);
return navigator.clipboard.writeText(text)
}else{
if (!document.execCommand('copy')) return Promise.reject()
const textArea = document.createElement('textarea')
textArea.style.position = 'fixed'
textArea.style.top = textArea.style.left = '-100vh'
textArea.style.opacity = '0'
textArea.value = text
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
return new Promise((resolve, reject) => {
document.execCommand('copy') ? resolve() : reject()
textArea.remove()
})
}
}