MCPcopy Create free account
hub / github.com/error311/FileRise / copyTextToClipboard

Function copyTextToClipboard

public/js/fileLink.js:5–26  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

3import { escapeHTML, showToast } from './domUtils.js?v={{APP_QVER}}';
4
5async function copyTextToClipboard(text) {
6 if (navigator.clipboard && window.isSecureContext) {
7 await navigator.clipboard.writeText(text);
8 return true;
9 }
10 const ta = document.createElement('textarea');
11 ta.value = text;
12 ta.setAttribute('readonly', '');
13 ta.style.position = 'absolute';
14 ta.style.left = '-9999px';
15 document.body.appendChild(ta);
16 ta.select();
17 let ok = false;
18 try {
19 ok = document.execCommand('copy');
20 } catch (e) {
21 ok = false;
22 } finally {
23 ta.remove();
24 }
25 return ok;
26}
27
28function buildInternalLink(token) {
29 return `${window.location.origin}${withBase(`/index.html?fileLink=${encodeURIComponent(token)}`)}`;

Callers 1

openFileLinkResultModalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected