copyToClipboard function presentation ✓ 100.0%
Last updated: 2026-03-02T13:35:57.087Z
Location
Metrics
LOC: 15
Complexity: 2
Params: 1
Coverage: 100.0% (10/10 lines, 5x executed)
Signature
copyToClipboard(text: string): : Promise<void>
Source Code
async function copyToClipboard(text: string): Promise<void> {
try {
await navigator.clipboard.writeText(text);
} catch {
// Fallback for contexts where clipboard API is restricted
const ta = document.createElement("textarea");
ta.value = text;
ta.style.position = "fixed";
ta.style.opacity = "0";
document.body.appendChild(ta);
ta.select();
document.execCommand("copy");
document.body.removeChild(ta);
}
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| render | calls |