mdInput: Create a Markdown Editor

Description Usage Arguments Value Server value Examples

View source: R/shinymarkdown.R

Description

Create an instance of a Markdown editor for text that may require formatting.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mdInput(
  inputId,
  min_height = "300px",
  height = "500px",
  preview_style = "tab",
  preview_highlight = FALSE,
  initial_edit_type = "markdown",
  hide_mode_switch = TRUE,
  language = "en-us",
  initial_value = NULL
)

Arguments

inputId

The input prefix used to access the value.

min_height

The editor's miniminum height value (pixels). Default = '300px'. Overwritten by the height parameter.

height

The editor's height value, applied as a border-box. Example values include "300px", "100%", and "auto". Defaults to "500px".

preview_style

The Markdown editor's preview style. Either "tab" or "vertical". Default is "tab".

preview_highlight

Should the Markdown Editor's HTML preview have a highlighted element corresponding to the cursor position in the Markdown editor. Default is FALSE.

initial_edit_type

Initial editor type: "markdown" or "wysiwyg". Default is "markdown".

hide_mode_switch

Should the user be able to switch the editor mode from "wysiwyg" to "markdown" or vice versa? Default is TRUE.

language

Editor language ISO code. Defaults to "en-us".

initial_value

Should the editor have text already present? If so, supply a character string. Default is NULL.

Value

An instance of the markdown editor for use within a Shiny App.

Server value

A character string of the text input in two formats:

See the examples section for more an example.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
if(interactive()) {

library(shiny)
library(shinymarkdown)
ui <- fluidPage(
mdInput(inputId = "myEditor", height = "500px", hide_mode_switch = F)
)

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

# Print the markdown version of what is typed
observe({print(input$myEditor_markdown)})

# Print the HTML version of what is typed
observe({print(input$myEditor_html)})

}

shinyApp(ui, server)

}

jdtrat/shinymarkdown documentation built on March 18, 2021, 11:40 a.m.