Show a shinyAce::aceEditor()
in a shiny::modalDialog()
.
displayCodeModal(
code,
title = NULL,
clip = "clipboard",
footer = shiny::modalButton("Dismiss"),
size = c("m", "s", "l"),
easyClose = TRUE,
fade = TRUE,
session = shiny::getDefaultReactiveDomain(),
...
)
Either a language object or a character string.
An optional title for the dialog.
An icon()
name
that a user can press to copy code
to the clipboard.
If you wish to not have an icon, specify clip = NULL
.
UI for footer. Use NULL
for no footer.
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+,
pass bslib::bs_theme()
to the theme
argument of a page container
like fluidPage()
).
If TRUE
, the modal dialog can be dismissed by
clicking outside the dialog box, or be pressing the Escape key. If
FALSE
(the default), the modal dialog can't be dismissed in those
ways; instead it must be dismissed by clicking on a modalButton()
, or
from a call to removeModal()
on the server.
If FALSE
, the modal dialog will have no fade-in animation
(it will simply appear rather than fade in to view).
a shiny session object (the default should almost always be used).
arguments passed along to shinyAce::aceEditor()
nothing. Call this function for its side effects.
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)
}