Skip to content

Bug: shinyace dependencies issue #43

@DivadNojnarg

Description

@DivadNojnarg

Reprex @nbenn:

library(shiny)
library(bslib)
library(shinyAce)

editorUI <- function(id) {
  ns <- NS(id)

  fluidRow(
    shiny::column(width = 4,
      shinyAce::aceEditor(
        ns("code"),
        mode = "r",
        height = "200px",
        autoComplete = "live",
        autoCompleters = "rlang",
        hotkeys = list(
          runKey=list(
            win = "Ctrl-Enter",
            mac = "CMD-ENTER"
          )
        )
      )
    ), # column
    shiny::column(width = 8,
      tags$div(
        style = "overflow-y:scroll; max-height: 300px;",
        verbatimTextOutput(ns("codeOutput"))
      )
    ) # column
  ) # row

}

editorSERVER <- function(id) {
  moduleServer(id, function(input, output, session) {
    ns <- session$ns
    shinyAce::aceAutocomplete("code")
    tmpFile <- tempfile()

    output$codeOutput <- renderPrint({
      val <- input$code_runKey
      if(is.null(val)) {
        return(
          "Execute [R] chunks with Ctrl/Cmd-Enter"
        )
      }

      selectionLocal <- val$selection
      lineLocal <- val$line
      if(val$selection != "") {
        toExecute <- selectionLocal
      } else {
        shiny::validate(
          need(!is.null(lineLocal), "Unable to find execution text")
        )
        toExecute <- lineLocal
      }
      writeLines(toExecute, con = tmpFile)
      return(source(tmpFile, echo = TRUE, local = TRUE))

    })
  })
}

ui <- page_fluid(
  dockViewOutput("dock")
)

server <- function(input, output, session) {

  output$dock <- renderDockView({
    dock_view(
      panels = list(
        panel(
          id = "editor",
          title = "Editor",
          content = editorUI("termone")
        )
      )
    )
  })

  editorSERVER("termone")
}

shinyApp(ui, server)

The issue is the way dependencies are managed in shinyAce. Basically, when you call htmltools::findDependencies on an shinyAce::aceEditor you get NULL. There is nothin dockViewR can do.

Just keeping it there so everyone knows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions