MCPcopy
hub / github.com/github/awesome-copilot / copyToClipboard

Function copyToClipboard

website/src/scripts/utils.ts:157–173  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

155 * Copy text to clipboard
156 */
157export async function copyToClipboard(text: string): Promise<boolean> {
158 try {
159 await navigator.clipboard.writeText(text);
160 return true;
161 } catch {
162 // Deprecated fallback for older browsers that lack the async clipboard API.
163 const textarea = document.createElement("textarea");
164 textarea.value = text;
165 textarea.style.position = "fixed";
166 textarea.style.opacity = "0";
167 document.body.appendChild(textarea);
168 textarea.select();
169 const success = document.execCommand("copy");
170 document.body.removeChild(textarea);
171 return success;
172 }
173}
174
175/**
176 * Generate VS Code install URL

Callers 6

setupModalFunction · 0.90
copyInstallCommandFunction · 0.90
setupActionHandlersFunction · 0.90
shareFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected