Skip to content

Commit d32126c

Browse files
jakubsobJakub Sobolewski
andauthored
Support HTML in React context (#66)
* feat: support html in react context * fix: disable import/no-unresolved linter for html-react-parser * chore: build js * chore: update dependencies * fix: js lint * chore: add asReactData.html to NAMESPACE * fix: remove isHTML function * feat: add tests for rendering html in react * feat: cleanup shinytest2 files after tests * fix: namespaces in tests * refactor: switch to testing html instead of screenshots * chore: sort suggests field in DESCRIPTION --------- Co-authored-by: Jakub Sobolewski <jakub.sobolewski@appsilon.com>
1 parent 6e2e837 commit d32126c

File tree

12 files changed

+3266
-23
lines changed

12 files changed

+3266
-23
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
^pkgdown$
1515

1616
^js$
17+
_\.new\.png$

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
# R CMD CHECK output
88
/check/
99
/docs/
10+
# {shinytest2}: Ignore new debug snapshots for `$expect_values()`
11+
*_.new.png

DESCRIPTION

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ Imports:
2525
rlang,
2626
shiny
2727
Suggests:
28+
chromote,
2829
covr,
2930
knitr,
3031
leaflet,
31-
methods,
3232
lintr (>= 3.0.0),
33+
methods,
3334
rcmdcheck,
3435
rmarkdown,
36+
shinytest2,
3537
styler,
36-
testthat
38+
testthat,
39+
withr

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ S3method(asReactData,JS_EVAL)
44
S3method(asReactData,ReactData)
55
S3method(asReactData,data.frame)
66
S3method(asReactData,default)
7+
S3method(asReactData,html)
78
S3method(asReactData,html_dependency)
89
S3method(asReactData,list)
910
S3method(asReactData,shiny.tag)

R/reactData.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ asReactData <- function(x) UseMethod("asReactData")
1010
#' @export
1111
asReactData.ReactData <- function(x) x
1212

13+
#' @export
14+
asReactData.html <- function(x) {
15+
ReactData(
16+
type = "html",
17+
value = dropDeps(x),
18+
deps = getDeps(x)
19+
)
20+
}
21+
1322
#' @export
1423
asReactData.default <- function(x) {
1524
ReactData(

0 commit comments

Comments
 (0)