export function copyToClipboard(textToCopy: string) {
if (!textToCopy) {return;}
const textArea = document.createElement('textarea');
textArea.value = textToCopy;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
textArea.style.top = '-999999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
return new Promise((resolve, reject) => {
if (document.execCommand('copy')) {
resolve(true);
}
else {
reject(new Error('-1'));
}
textArea.remove();
});
}