Show a shinyAce::aceEditor() in a shiny::modalDialog().
Usage
displayCodeModal(
code,
title = NULL,
clip = "clipboard",
footer = shiny::modalButton("Dismiss"),
size = c("m", "s", "l"),
easyClose = TRUE,
fade = TRUE,
session = shiny::getDefaultReactiveDomain(),
...
)Arguments
- code
Either a language object or a character string.
- title
An optional title for the dialog.
- clip
An
shiny::icon()namethat a user can press to copycodeto the clipboard. If you wish to not have an icon, specifyclip = NULL.UI for footer. Use
NULLfor no footer.- size
One of
"s"for small,"m"(the default) for medium,"l"for large, or"xl"for extra large. Note that"xl"only works with Bootstrap 4 and above (to opt-in to Bootstrap 4+, passbslib::bs_theme()to thethemeargument of a page container likefluidPage()).- easyClose
If
TRUE, the modal dialog can be dismissed by clicking outside the dialog box, or be pressing the Escape key. IfFALSE(the default), the modal dialog can't be dismissed in those ways; instead it must be dismissed by clicking on amodalButton(), or from a call toremoveModal()on the server.- fade
If
FALSE, the modal dialog will have no fade-in animation (it will simply appear rather than fade in to view).- session
a shiny session object (the default should almost always be used).
- ...
arguments passed along to
shinyAce::aceEditor()
Examples
if (interactive()) {
library(shiny)
ui <- fluidPage(
sliderInput("n", label = "Number of samples", min = 10, max = 100, value = 30),
actionButton("code", icon("code")),
plotOutput("p")
)
server <- function(input, output) {
output$p <- metaRender(renderPlot, {
plot(sample(..(input$n)))
})
observeEvent(input$code, {
code <- expandChain(output$p())
displayCodeModal(code)
})
}
shinyApp(ui, server)
}