feat(client): implement clipboard fallback method

This commit is contained in:
Elian Doran 2025-05-26 20:30:32 +03:00
parent ac0f6662a6
commit 3ca2b24db3
No known key found for this signature in database

View File

@ -120,8 +120,18 @@ export function copyText(text: string) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text);
succeeded = true;
} else {
// Fallback method: https://stackoverflow.com/a/72239825
const textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
succeeded = document.execCommand('copy');
document.body.removeChild(textArea);
}
} catch (e) {
console.warn(e);
succeeded = false;
}