@allurereport/web-classic
Version:
The static files for Allure Classic Report
17 lines (15 loc) • 453 B
text/typescript
export const copyToClipboard = async (text: string) => {
if (navigator.clipboard) {
await navigator.clipboard.writeText(text);
return;
}
const textarea = document.createElement("textarea");
textarea.value = text;
textarea.style.position = "fixed";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
};