Skip to content

Commit

Permalink
removed fallback copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
steveKit committed Feb 7, 2025
1 parent a22dafe commit f54f93a
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions R/coreUI.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,12 @@ createHeader <- function() {
createClipboardHandler <- function() {
tags$script(HTML("
Shiny.addCustomMessageHandler('copyToClipboard', async function(rCode) {
function fallbackCopyToClipboard(rCode) {
const tempInput = document.createElement('input');
tempInput.value = rCode;
document.body.appendChild(tempInput);
tempInput.select();
try {
document.execCommand('copy');
alert('R Code copied to clipboard!');
} catch (err) {
alert('Failed to copy to clipboard:', err);
} finally {
document.body.removeChild(tempInput);
}
}
try {
await navigator.clipboard.writeText(rCode);
alert('R Code copied to clipboard!');
} catch (err) {
alert('Failed to copy to clipboard:', err);
fallbackCopyToClipboard(rCode);
alert('Failed to copy to clipboard. Your browser may not be compatible');
}
});
"))
Expand Down

0 comments on commit f54f93a

Please sign in to comment.