Package‘monaco’
October13,2022
Type Package
Title The'Monaco'Editor as a HTML Widget
Version0.2.2
Description A HTML widget rendering the'Monaco'editor.The'Monaco'editor is the code edi-tor which powers'VS Code'.It is particularly well developed for'JavaScript'.In addi-
tion to the built-in features of the'Monaco'editor,the widget allows to prettify multiple lan-
guages,to view the'HTML'rendering of'Markdown'code,and to view and resize'SVG'images. URL github/stla/monaco
editorjs
BugReports github/stla/monaco/issues
License GPL-3
Encoding UTF-8
Imports htmlwidgets(>=1.5.3),rstudioapi,tools,htmltools,shiny
Suggests sass
RoxygenNote7.1.1
NeedsCompilation no
Author Stéphane Laurent[aut,cre],
Microsoft Corporation[ctb,cph]('Monaco Editor'library),
James Long and contributors[ctb,cph]('Prettier'library),
Rich Harris[ctb,cph]('svg-parser'library),
Lionel Tzatzkin[ctb,cph]('scale-that-svg'library),
Andrei Kashcha[ctb,cph]('panzoom'library),
Vitaly Puzrin[ctb,cph]('markdown-it'library),
Alex Kocharin[ctb,cph]('markdown-it'library),
John Schlinkert[ctb,cph]('word-wrap'library),
jQuery contributors[ctb,cph]('jQuery'library),
Kyle Fox[ctb,cph]('jQuery Modal'library),
Tristan Edwards[ctb,cph]('sweetalert2'library),
Limon Monte[ctb,cph]('sweetalert2'library)
Maintainer Stéphane Laurent<***********************>
Repository CRAN
Date/Publication2022-05-1809:20:02UTC
1
R topics documented:
getMonacoLanguages (2)
getMonacoThemes (2)
monaco (2)
monaco-shiny (5)
Index8 getMonacoLanguages Monaco languages
Description
Get the list of available languages in the Monaco editor.
Usage
getMonacoLanguages()
getMonacoThemes Monaco themes
Description
Get the list of available themes of the Monaco editor.All themes are dark,excepted"vs".
Usage
getMonacoThemes()
monaco 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 afile,NULL to open an empty editor,missing to open the file currently open in RStudio,or a character vector which corresponds to the
lines of afile
language the language of the contents;if NULL and the contents are read from afile,the mode is guessed from the extension of thefile;run getMonacoLanguages to get
the list of available languages
theme the theme of the editor;run getMonacoThemes to get the list of available themes tabSize number of spaces for the indentation(usually2or4);if NULL,it is set to the one used in RStudio
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,),
div(ed2,)
)
)
}
#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",),
div(ed2,class="editor",)
)
)
)
}
monaco-shiny5 monaco-shiny Shiny bindings for Monaco editor
Description
Output and render functions for using Monaco editors within Shiny applications and interactive Rmd documents.
Usage
monacoOutput(outputId,width="100%",height="400px")
renderMonaco(expr,env=parent.frame(),quoted=FALSE)
Arguments
outputId output variable to read from
width,height CSS measurements like"100%","400px","auto",or a number,which will be coerced to a string and have"px"appended
expr an expression that creates a Monaco editor with monaco
env the environment in which to evaluate expr
quoted logical,whether expr is a quoted expression
Examples
library(monaco)
library(shiny)
ui<-fluidPage(
monacoOutput("ed",height="400px")
)
server<-function(input,output){
output[["ed"]]<-renderMonaco({
monaco(
system.file("exampleFiles","JavaScript.js",package="monaco")
)
})
}
if(interactive()){
shinyApp(ui,server)
}
#Customizing the input range,using the sass package####

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。