Skip to content

Commit 5de2093

Browse files
committed
refactor: remove deprecated execCommand fallback for clipboard copy
Use navigator.clipboard.writeText directly as execCommand is fully deprecated. Removes the fallback textarea + execCommand approach.
1 parent 1a333bc commit 5de2093

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

assets/js/copy-to-llm.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,9 @@
8080
}
8181

8282
function copyToClipboard(text, data, type) {
83-
if (navigator.clipboard && navigator.clipboard.writeText) {
84-
navigator.clipboard.writeText(text).then(function () {
85-
showFeedback(data, type);
86-
}).catch(function () {
87-
fallbackCopy(text, data, type);
88-
});
89-
} else {
90-
fallbackCopy(text, data, type);
91-
}
92-
}
93-
94-
function fallbackCopy(text, data, type) {
95-
var textarea = document.createElement('textarea');
96-
textarea.value = text;
97-
textarea.style.position = 'fixed';
98-
textarea.style.opacity = '0';
99-
document.body.appendChild(textarea);
100-
textarea.select();
101-
try {
102-
document.execCommand('copy');
83+
navigator.clipboard.writeText(text).then(function () {
10384
showFeedback(data, type);
104-
} catch (e) {
105-
// silent fail
106-
}
107-
document.body.removeChild(textarea);
85+
});
10886
}
10987

11088
function showFeedback(data, type) {

0 commit comments

Comments
 (0)