MCPcopy Index your code
hub / github.com/devspace-sh/devspace / fallbackCopyTextToClipboard

Function fallbackCopyTextToClipboard

ui/src/lib/utils.tsx:68–84  ·  view source on GitHub ↗
(text: any)

Source from the content-addressed store, hash-verified

66}
67
68const fallbackCopyTextToClipboard = (text: any) => {
69 const textArea = document.createElement('textarea');
70 textArea.value = text;
71 document.body.appendChild(textArea);
72 textArea.focus();
73 textArea.select();
74
75 try {
76 const successful = document.execCommand('copy');
77 const msg = successful ? 'successful' : 'unsuccessful';
78 console.log('Fallback: Copying text command was ' + msg);
79 } catch (err) {
80 console.error('Fallback: Oops, unable to copy', err);
81 }
82
83 document.body.removeChild(textArea);
84};
85export function copyToClipboard(text: string) {
86 if (!(navigator as any).clipboard) {
87 fallbackCopyTextToClipboard(text);

Callers 1

copyToClipboardFunction · 0.85

Calls 1

execCommandMethod · 0.80

Tested by

no test coverage detected