Shiny/R Wrapper for 'clipboard.js'

Leverages the functionality of 'clipboard.js', a JavaScript library for HMTL5-based copy to clipboard from web pages (see < https://clipboardjs.com> for more information), and provides a reactive copy-to-clipboard UI button component, called 'rclipButton', for 'shiny' R applications.


Introduction

clipboard.js is a super light javascript framework, which provides copy-to-clipboard functionality using HTML5. The simple rclipboard R package is simple and leverages clipboard.js functionality to provide a reactive copy-to-clipboard UI button component, called rclipButton, for Shiny R applications.

Example

This example only works when deployed on a Shiny server. If this app is run from RStudio, the UI displays correctly but the rclipButton UI button is not functional. A workaround is to also include an observeEvent associated to the rclipButton and use the clipr function from the clipr package (this function only works when the app is run locally, eg from RStudio, and not when deployed on a server).

library(rclipboard)
library(shiny)
 
# The UI
ui <- bootstrapPage(
  
  rclipboardSetup(),
  
  # Add a text input
  textInput("copytext", "Copy this:", "Zlika!"),
 
  # UI ouputs for the copy-to-clipboard buttons
  uiOutput("clip"),
  
  # A text input for testing the clipboard content.
  textInput("paste", "Paste here:")
  
)
 
# The server
server <- function(input, output) {
 
  # Add clipboard buttons
  output$clip <- renderUI({
    rclipButton("clipbtn", "rclipButton Copy", input$copytext, icon("clipboard"))
  })
  
}
 
shinyApp(ui = ui, server = server)
 

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rclipboard")

0.1 by Sebastien Bihorel, 2 years ago


http://github.com/sbihorel/rclipboard


Report a bug at http://github.com/sbihorel/rclipboard/issues


Browse source code at https://github.com/cran/rclipboard


Authors: Sebastien Bihorel


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports shiny


Imported by spotGUI.


See at CRAN