From 16d05cd19c2f1f153a7fc47fa0ef777e576fd4f9 Mon Sep 17 00:00:00 2001 From: pvictor Date: Wed, 22 Dec 2021 17:02:19 +0100 Subject: [PATCH] clean dependencies and functions --- DESCRIPTION | 15 +-------------- NAMESPACE | 4 ---- R/dependencies.R | 38 ++------------------------------------ README.md | 2 +- man/capture.Rd | 10 +++++----- man/html-dependencies.Rd | 14 ++++---------- 6 files changed, 13 insertions(+), 70 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 998f38a..8fa1356 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,19 +8,7 @@ Authors@R: email = "victor.perrier@dreamrs.fr"), person(given = "Fanny", family = "Meyer", - role = "aut"), - person(given = "Anatolii", - family = "Saienko", - comment = "Author of dom-to-image JavaScript library", - role = "cph"), - person(given = "Eli", - family = "Grey", - comment = "Author of FileSaver JavaScript library", - role = "cph"), - person(given = "James", - family = "Hall", - comment = "Author of jsPDF JavaScript library", - role = "cph")) + role = "aut")) Description: Add a button in web page ('Shiny' or 'RMarkdown') to take a screenshot of a specified element. License: GPL-3 Encoding: UTF-8 @@ -30,7 +18,6 @@ Imports: htmltools, jsonlite, shiny, - shinybusy, tools Suggests: knitr, diff --git a/NAMESPACE b/NAMESPACE index 965b54c..aec6dc2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,9 +3,6 @@ export(capture) export(capture_pdf) export(html_dependency_capture) -export(html_dependency_domtoimage) -export(html_dependency_filesaver) -export(html_dependency_jspdf) export(loading) export(lookbook) importFrom(htmltools,htmlDependency) @@ -13,6 +10,5 @@ importFrom(htmltools,tagList) importFrom(htmltools,tags) importFrom(jsonlite,toJSON) importFrom(shiny,absolutePanel) -importFrom(shinybusy,html_dependency_notiflix) importFrom(tools,file_ext) importFrom(utils,packageVersion) diff --git a/R/dependencies.R b/R/dependencies.R index 1517a79..d64f80f 100644 --- a/R/dependencies.R +++ b/R/dependencies.R @@ -1,5 +1,7 @@ #' HTML dependencies used by capture +#' +#' @param type Type of dependency to use. #' #' @return an [htmltools::htmlDependency()]. #' @export @@ -19,39 +21,3 @@ html_dependency_capture <- function(type = c("image", "pdf", "lookbook")) { script = sprintf("capture-%s.js", type) ) } - -#' @rdname html-dependencies -#' @export -html_dependency_domtoimage <- function() { - htmlDependency( - name = "dom-to-image", - version = "2.6.0", - src = list(file = "assets"), - package = "capture", - script = "dom-to-image/dom-to-image.min.js" - ) -} - -#' @rdname html-dependencies -#' @export -html_dependency_filesaver <- function() { - htmlDependency( - name = "FileSaver", - version = "2.0.4", - src = list(file = "assets"), - package = "capture", - script = "FileSaver/FileSaver.min.js" - ) -} - -#' @rdname html-dependencies -#' @export -html_dependency_jspdf <- function() { - htmlDependency( - name = "jsPDF", - version = "2.1.1", - src = list(file = "assets"), - package = "capture", - script = "jsPDF/jspdf.umd.min.js" - ) -} diff --git a/README.md b/README.md index b2148dc..bdc4c7b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # capture -> Add a button in Shiny application or R Markdown document to take a screenshot (PNG or PDF) of a specified element. It uses [dom-to-image](https://github.com/tsayen/dom-to-image) to convert DOM elements to PNG and [jsPDF](https://github.com/parallax/jsPDF) to generate PDF. Doesn't work in IE. +> Add a button in Shiny application or R Markdown document to take a screenshot (PNG or PDF) of a specified element. It uses [html-to-image](https://github.com/bubkoo/html-to-image) to convert DOM elements to PNG and [jsPDF](https://github.com/parallax/jsPDF) to generate PDF. Doesn't work in IE. [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) diff --git a/man/capture.Rd b/man/capture.Rd index 739b9d5..3dd4001 100644 --- a/man/capture.Rd +++ b/man/capture.Rd @@ -76,23 +76,23 @@ ui <- fluidPage( ), capture( selector = "#result-block", - filename = "results", + filename = "results-screenshot", icon("camera"), "Take screenshot of results", - options = list(bgcolor = "#FFF") + options = list(backgroundColor = "#FFF") ), capture( selector = "#result-block", - filename = "results", + filename = "results-screenshot", icon("camera"), "Take screenshot of results (bigger scale)", scale = 3, - options = list(bgcolor = "#FFF") + options = list(backgroundColor = "#FFF") ), capture( selector = "#result-block", filename = NULL, # no download client side icon("camera"), "Take screenshot of results (retrieve server side)", inputId = "screenshot", - options = list(bgcolor = "#FFF") + options = list(backgroundColor = "#FFF") ), uiOutput("out") ) diff --git a/man/html-dependencies.Rd b/man/html-dependencies.Rd index 5bc0bd8..9eff9d7 100644 --- a/man/html-dependencies.Rd +++ b/man/html-dependencies.Rd @@ -3,18 +3,12 @@ \name{html-dependencies} \alias{html-dependencies} \alias{html_dependency_capture} -\alias{html_dependency_domtoimage} -\alias{html_dependency_filesaver} -\alias{html_dependency_jspdf} \title{HTML dependencies used by capture} \usage{ -html_dependency_capture() - -html_dependency_domtoimage() - -html_dependency_filesaver() - -html_dependency_jspdf() +html_dependency_capture(type = c("image", "pdf", "lookbook")) +} +\arguments{ +\item{type}{Type of dependency to use.} } \value{ an \code{\link[htmltools:htmlDependency]{htmltools::htmlDependency()}}.