copyToClipboard function presentation ✓ 100.0%

Last updated: 2026-03-02T13:35:57.087Z

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)

graph LR copyToClipboard["copyToClipboard"] render["render"] render -->|calls| copyToClipboard style copyToClipboard fill:#dbeafe,stroke:#2563eb,stroke-width:2px click copyToClipboard "a758a4a218f84aaf.html" click render "80ece8fdb820f2e0.html"
SourceType
render calls