export function copyTextToClipboard(text: string) { return new Promise((resolve, reject) => { const textArea = document.createElement('textarea') textArea.value = text textArea.style.width = '0' textArea.style.height = '0' textArea.style.zIndex = '-1' textArea.style.position = 'fixed' document.body.appendChild(textArea) textArea.focus() textArea.select()
try { const successful = document.execCommand('copy') if (successful) { resolve(void 0) } else { reject() } } catch (err) { reject() console.error('Fallback: Oops, unable to copy', err) }
document.body.removeChild(textArea) })}