Skip to content

Commit 63efe20

Browse files
Use navigator.clipboard in Clipboard_CopyTo with execCommand fallback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1dbcd8a commit 63efe20

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

docs/content/fsdocs-tips.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ function showTip(evt, name, unique, owner) {
4545
}
4646

4747
function Clipboard_CopyTo(value) {
48-
const tempInput = document.createElement("input");
49-
tempInput.value = value;
50-
document.body.appendChild(tempInput);
51-
tempInput.select();
52-
document.execCommand("copy");
53-
document.body.removeChild(tempInput);
48+
if (navigator.clipboard) {
49+
navigator.clipboard.writeText(value);
50+
} else {
51+
const tempInput = document.createElement("input");
52+
tempInput.value = value;
53+
document.body.appendChild(tempInput);
54+
tempInput.select();
55+
document.execCommand("copy");
56+
document.body.removeChild(tempInput);
57+
}
5458
}
5559

5660
window.showTip = showTip;

0 commit comments

Comments
 (0)