Type: | Package |
Title: | Shiny Module for a Markdown Input with Result Preview |
Version: | 0.1.2 |
Maintainer: | Julien Diot <juliendiot@ut-biomet.org> |
Description: | An R-Shiny module containing a "markdownInput". This input allows the user to write some markdown code and to preview the result. This input has been inspired by the "comment" window of https://github.com/. |
Imports: | shiny (≥ 1.0.5), shinyAce, markdown |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://github.com/juliendiot42/markdownInput |
BugReports: | https://github.com/juliendiot42/markdownInput/issues |
RoxygenNote: | 7.0.2 |
NeedsCompilation: | no |
Packaged: | 2020-01-20 09:50:20 UTC; julien |
Author: | Julien Diot |
Repository: | CRAN |
Date/Publication: | 2020-01-31 14:20:05 UTC |
Create a markdown input control with a result preview
Description
Create a markdown input control with a result preview
Usage
markdownInput(
inputId,
label,
value = "Some **markdown** _text_",
theme = "github",
height = "400px",
class = ""
)
Arguments
inputId |
The codeinput slot that will be used to access the value. |
label |
Label of the input. |
value |
The initial text to be contained in the editor. |
theme |
The Ace theme to be used by the editor. The theme in Ace
determines the styling and coloring of the editor.
Use |
height |
A number (which will be interpreted as a number of pixels) or any valid CSS dimension (such as "50%", "200px", or "auto"). |
class |
The CSS class name of the input. (optional) |
Value
A tabset containing two tabs:
"Write" tab: Containing a code editor (
aceEditor
)."Preview" tab: Containing the preview of the markdown render.
Author(s)
Julien Diot juliendiot42@gmail.com
References
shinyAce package: Vincent Nijs, Forest Fang, Trestle Technology, LLC and Jeff Allen (2019). shinyAce: Ace Editor Bindings for Shiny.
shiny package: Winston Chang, Joe Cheng, JJ Allaire, Yihui Xie and Jonathan McPherson (2018). shiny: Web Application Framework for R.
markdown package: JJ Allaire, Jeffrey Horner, Yihui Xie, Vicent Marti and Natacha Porte (2018). markdown: 'Markdown' Rendering for R.
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(markdownInput)
ui <- fluidPage(titlePanel("Markdown input"),
sidebarLayout(
# inputs:
sidebarPanel(
markdownInput(
"mdInputID",
label = "Write your text",
value = "Write some _markdown_ **here:**"
)
),
# outputs:
mainPanel(
h3("Raw value of the input:"),
verbatimTextOutput("rawResult"))
))
server <- function(input, output, session) {
# myText is a reactive variable containing the raw markdown text
myText <- callModule(moduleMarkdownInput, "mdInputID")
# show "myText"
output$rawResult <- renderPrint({
print(myText())
})
}
shinyApp(ui, server)
}
Server function of the markdownInput
module
Description
Server function of the markdownInput
module
Usage
moduleMarkdownInput(input, output, session, class = "")
Arguments
input |
The session's input object. |
output |
The session's output object. |
session |
The shiny's session. |
class |
(optional) The CSS class name of the priview tab. |
Value
The reactive value of the input.
Author(s)
Julien Diot juliendiot42@gmail.com
References
shinyAce package: Vincent Nijs, Forest Fang, Trestle Technology, LLC and Jeff Allen (2019). shinyAce: Ace Editor Bindings for Shiny.
shiny package: Winston Chang, Joe Cheng, JJ Allaire, Yihui Xie and Jonathan McPherson (2018). shiny: Web Application Framework for R.
markdown package: JJ Allaire, Jeffrey Horner, Yihui Xie, Vicent Marti and Natacha Porte (2018). markdown: 'Markdown' Rendering for R.
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(markdownInput)
ui <- fluidPage(titlePanel("Markdown input"),
sidebarLayout(
# inputs:
sidebarPanel(
markdownInput(
"mdInputID",
label = "Write your text",
value = "Write some _markdown_ **here:**"
)
),
# outputs:
mainPanel(
h3("Raw value of the input:"),
verbatimTextOutput("rawResult"))
))
server <- function(input, output, session) {
# myText is a reactive variable containing the raw markdown text
myText <- callModule(moduleMarkdownInput, "mdInputID")
# show "myText"
output$rawResult <- renderPrint({
print(myText())
})
}
shinyApp(ui, server)
}
Run a Shiny application presenting the "markdownInput" package.
Description
Run a Shiny application presenting the "markdownInput" package.
Usage
runExample()