R 如何将tinyMCE文本区域填充为闪亮?

R 如何将tinyMCE文本区域填充为闪亮?,r,shiny,tinymce,R,Shiny,Tinymce,我试图从R中填充tinyMCE示例中的文本区域 看起来我应该写$textHolder输出 但是我在observe()函数中的语句没有这样做 我正在使用tinymce网站上的示例 在这个问题上我找不到太多的支持 这是我的服务器代码: shinyServer(function(input, output, session) { observe({ print ("observe") output$textHolder = renderText("XXX")

我试图从R中填充tinyMCE示例中的文本区域

看起来我应该写$textHolder输出

但是我在observe()函数中的语句没有这样做

我正在使用tinymce网站上的示例

在这个问题上我找不到太多的支持

这是我的服务器代码:

shinyServer(function(input, output, session) {


    observe({
      print ("observe")
      output$textHolder = renderText("XXX")

    })

  output$htmlText <- renderUI({
    req(input$typedText)
    HTML(enc2utf8(input$typedText))
  })

  output$rawText <- renderText({
    req(input$typedText)
    enc2utf8(input$typedText)
  })
})

<>你可以考虑使用SynMyCE包:(使用例如
devtools::install_github(“mul118/shinyMCE”)
进行安装)

在ui端,您将使用:

tinyMCE('editor1', 'Click to edit text')
在服务器端,您可以通过
input$editor1
访问html代码

下面我将代码集成到你的应用程序中

完整示例如下:

library(shiny)
library(shinyMCE)

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

  output$htmlText <- renderUI({
    req(input$editor1)
    HTML(enc2utf8(input$editor1))
  })

  output$rawText <- renderText({
    req(input$editor1)
    enc2utf8(input$editor1)
  })
}

ui <- shinyUI(
  fluidPage(
    fluidRow(
      titlePanel("tinyMCE Shiny"),
      br(),
      column(width = 6,
             tinyMCE('editor1', 'Click to edit text'),
             br(),
             actionButton("fetch", "Get Results!", icon=icon("lightbulb-o"),class="btn-primary",
                          onclick = "Shiny.onInputChange('typedText', tinyMCE.get('textHolder').getContent());")
  ),
  column(width = 6,
         tags$style(HTML('pre {height:240px;}')),
         tags$label(`for`="rawText", "Raw String"),
         hr(),
         tags$pre(textOutput("rawText")),
         br(),
         tags$label(`for`="htmlText", "HTML Version"),
         hr(),
         tags$pre(htmlOutput("htmlText"))
  )
      )
  )
)


shinyApp(ui, server)
库(闪亮)
图书馆(shinyMCE)

服务器不清楚要用什么填充该文本区域。文本区域是否需要更改或是静态的?目前,您的
observe
没有从
输入环境中获取任何值,因此将永远不会更新。它也不是用来包含更新
输出
环境的语句。这里的答案应该很简单,但不清楚你想要的行为是什么。如果文本区域不需要反应性,它会变得更容易。基本上,我需要允许用户在TyMyCE窗口中输入数据,将数据移动到永久存储,然后将存储的数据写入到TyMyCE窗口。下面的答案是否为您工作?对SynMyCE非常感兴趣,但如果(需要)(“DeVoToCs”))安装。(“devtools”)devtools::install_github(“shinyMCE”,“mul118”)生成:解析_repo_spec(repo)时出错:无效的git repo规范:“shinyMCE”似乎是一个文档问题。使用
devtools::install_github(“mul118/shinyMCE”)
应该可以。不,我仍然无法在RSTUDIO中的Windows10计算机上安装shinyMCE。如果您将联系人发送给我,我将转发错误日志。
library(shiny)
library(shinyMCE)

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

  output$htmlText <- renderUI({
    req(input$editor1)
    HTML(enc2utf8(input$editor1))
  })

  output$rawText <- renderText({
    req(input$editor1)
    enc2utf8(input$editor1)
  })
}

ui <- shinyUI(
  fluidPage(
    fluidRow(
      titlePanel("tinyMCE Shiny"),
      br(),
      column(width = 6,
             tinyMCE('editor1', 'Click to edit text'),
             br(),
             actionButton("fetch", "Get Results!", icon=icon("lightbulb-o"),class="btn-primary",
                          onclick = "Shiny.onInputChange('typedText', tinyMCE.get('textHolder').getContent());")
  ),
  column(width = 6,
         tags$style(HTML('pre {height:240px;}')),
         tags$label(`for`="rawText", "Raw String"),
         hr(),
         tags$pre(textOutput("rawText")),
         br(),
         tags$label(`for`="htmlText", "HTML Version"),
         hr(),
         tags$pre(htmlOutput("htmlText"))
  )
      )
  )
)


shinyApp(ui, server)