MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / copyStr

Function copyStr

smallthinker/tools/server/webui/src/utils/misc.ts:42–57  ·  view source on GitHub ↗
(textToCopy: string)

Source from the content-addressed store, hash-verified

40
41// copy text to clipboard
42export const copyStr = (textToCopy: string) => {
43 // Navigator clipboard api needs a secure context (https)
44 if (navigator.clipboard && window.isSecureContext) {
45 navigator.clipboard.writeText(textToCopy);
46 } else {
47 // Use the 'out of viewport hidden text area' trick
48 const textArea = document.createElement('textarea');
49 textArea.value = textToCopy;
50 // Move textarea out of the viewport so it's not visible
51 textArea.style.position = 'absolute';
52 textArea.style.left = '-999999px';
53 document.body.prepend(textArea);
54 textArea.select();
55 document.execCommand('copy');
56 }
57};
58
59/**
60 * filter out redundant fields upon sending to API

Callers 1

CopyButtonFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected