Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/timelyportfolio/excalidrawr

Excalidraw for R
https://github.com/timelyportfolio/excalidrawr

Last synced: about 2 months ago
JSON representation

Excalidraw for R

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# excalidrawr

Quick experiment to wrap [Excalidraw](https://excalidraw.com/) for use in R.

## Installation

``` r
remotes::install_github("timelyportfolio/excalidrawr")
```

## Example

Currently, the package does very little except open an `Excalidraw` instance ready for your creative adventures.

``` r
library(excalidrawr)

excalidraw()
```

We can also use the `onChange` prop to communicate with Shiny.

``` r
library(htmltools)
library(shiny)
library(excalidrawr)

ui <- excalidraw(
onChange = htmlwidgets::JS(
"
function(elements, state) {
if(Shiny && Shiny.setInputValue) {
Shiny.setInputValue('excal1', {elements})
}
}
"
),
elementId = "excal1"
)

server <- function(input, output, session) {
draw <- reactive({
input$excal1
})
draw_d <- debounce(draw, 1000)
observe({
str(draw_d())
})
}

shinyApp(ui, server)
```