简体   繁体   English

ShinyMCE 在 renderUI 和 shinyDashboard 中不起作用

[英]ShinyMCE does not work in renderUI and shinyDashboard

This MWE is working:这个 MWE 正在工作:

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(#uiOutput("body")
                                     tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  #output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

This is how it looks like:这是它的样子:

在此处输入图像描述

However, if I use the tinyMCE inside renderUI :但是,如果我在renderUI tinyMCE

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(uiOutput("body")
                                     #tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

..it does not work properly: ..它不能正常工作:

在此处输入图像描述

I need to use renderUI because I have several elements to render in the body.我需要使用renderUI ,因为我有几个元素要在主体中呈现。 Any suggestion?有什么建议吗?

As I saw in here .正如我在这里看到的。 I added the source of the script in a singleton:我在 singleton 中添加了脚本源:

library(shiny)
library(shinydashboard)
library(shinyMCE)

ui<-dashboardPage(header=dashboardHeader(),
                  sidebar=dashboardSidebar(),
                  body=dashboardBody(singleton(tags$head(tags$script(src = "//cdn.tiny.cloud/1/5a5deew2z9gml5pwn95iosioop446qny3vyfh994kujzkwu6/tinymce/5/tinymce.min.js", referrerpolicy="origin"))),
                                     uiOutput("body")
                                     #tinyMCE("tinyInput","Some html text")
                                     ))

server <- function(input, output, session) {
  output$body <- renderUI({tinyMCE('tinyInput',"Some html text")})
}

shinyApp(ui = ui, server = server)

It fixed my problem.它解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM