monaco {monaco} | R Documentation |
Monaco editor
Description
Open the Monaco editor.
Usage
monaco(
contents,
language = NULL,
theme = NULL,
tabSize = NULL,
fontSize = 14,
header = TRUE,
width = NULL,
height = NULL,
elementId = NULL
)
Arguments
contents |
this can be the path to a file, |
language |
the language of the contents; if |
theme |
the theme of the editor; run |
tabSize |
number of spaces for the indentation (usually |
fontSize |
font size in pixels |
header |
logical, whether to display the header of the widget |
width , height |
dimensions; the default values are nice for usage in the RStudio viewer pane |
elementId |
a HTML id for the container; this is useless for common usage |
Examples
# in RStudio, `monaco()` opens the current file:
monaco()
# opens a new, empty JavaScript file:
monaco(NULL, language = "javascript")
# opens an existing file:
monaco(system.file("exampleFiles", "JavaScript.js", package = "monaco"))
# try the SVG viewer; you can zoom and pan the image:
monaco(system.file("exampleFiles", "react.svg", package = "monaco"))
# a dirty Markdown file, try to prettify it:
monaco(system.file("exampleFiles", "Markdown.md", package = "monaco"))
# opens two editors side-by-side:
library(monaco)
library(htmltools)
ed1 <- monaco(
system.file("exampleFiles", "JavaScript.js", package = "monaco")
)
ed2 <- monaco(
system.file("exampleFiles", "react.svg", package = "monaco")
)
if(interactive()){
browsable(
div(
div(ed1, style="position: fixed; left: 1vw; right: 51vw;"),
div(ed2, style="position: fixed; left: 51vw; right: 1vw;")
)
)
}
# stacks two editors:
library(monaco)
library(htmltools)
ed1 <- monaco(
system.file("exampleFiles", "JavaScript.js", package = "monaco"),
height = "calc(50vh - 40px)"
)
ed2 <- monaco(
system.file("exampleFiles", "react.svg", package = "monaco"),
height = "calc(50vh - 40px)"
)
if(interactive()){
browsable(
tagList(
tags$style(HTML(
".editor {",
" position: fixed;",
" left: 1vw;",
" width: 98vw;",
"}"
)),
div(
div(ed1, class = "editor", style = "bottom: calc(50vh + 5px);"),
div(ed2, class = "editor", style = "top: calc(50vh + 5px);")
)
)
)
}