您如何在资产手册中输入java脚本代码并用闪亮的代码调用它?在让它工作时遇到一些麻烦。我需要找到一种方法在RCloud的资产簿中获取它,并且能够在Rcloud中调用它,而无需在线引用代码
#Link to JS Code I am trying to save inside Rcloud
tinymce.cachefly.net/4.0/tinymce.min.js
# Call asset to provide JS Code
tinymce.fn.source< - rcloud.get.asset(" tinymce.js",notebook = assetsNotebook) 源(textConnection(tinymce.fn.source))
Side Text Panel Code
fluidRow(
singleton(tags$head(tags$script(src ="tinymce.fn.source"))),
column(12, offset = 0,
hr(),
h4('Side Panel Text'),
uiOutput("editor1"))),
答案 0 :(得分:1)
我改编了this example from The Dub World:
library(rcloud.shiny)
library(shiny)
ui <- shinyUI(
fluidPage(tags$head(tags$script(src='/notebook.R/6a4819a38814bdad910e837f0c4de702/tinymce.min.js')),
# Application title
fluidRow(
titlePanel('tinyMCE Modal Example'),
br(),
actionButton('modal', 'Modal Example', icon=icon('paper-plane-o'), class='btn-success', style='margin-left:15px;',`data-toggle`='modal', `data-target`='#modalExample'),
br(),br(),
tags$pre(htmlOutput('modalText')),
### Modal ###
tags$div(class='modal fade', id='modalExample', tabindex='-1', role='dialog',`aria-labelledby`='modalExample', `aria-hidden`='true',
tags$div(class='modal-dialog', role='document',
tags$div(class='modal-content',
tags$div(class='modal-header', tags$button(type='button', class='close', `data-dismiss`='modal', `aria-label`='Close', tags$span(`aria-hidden`='true', 'x')),tags$h4(class='modal-title', 'HTML Editor in a modal')),
tags$div(class='modal-body', tags$form(method='post', tags$textarea(id='modalEditor')),tags$script("tinymce.init({selector:'#modalEditor', theme: 'modern', height: 200});")),
tags$div(class='modal-footer',tags$button(type='button', class='btn btn-primary', `data-dismiss`='modal', onclick="Shiny.onInputChange('modalTextArea',tinyMCE.get('modalEditor').getContent());",'Close')))
)
)
)
)
)
server <- function(input, output, session) {
output$modalText <- renderUI({
req(input$modalTextArea)
HTML(enc2utf8(input$modalTextArea))
})
}
rcloud.shinyApp(ui=ui, server=server)
我将JS保存到桌面,然后使用文件上载GUI 勾选上传到笔记本框加载以创建RCloud资产:
单击RCloud Asset部分中的链接图标,您将看到作为notebook.R静态资产加载的JS代码:
The notebook.R interface (web service)允许您拨打static asset using the relative path of your notebook ...因此您可以在其他笔记本中创建功能,并使用该路径调用它们,例如。