Javascript 从HTML创建的DraftJS编辑器不工作

Javascript 从HTML创建的DraftJS编辑器不工作,javascript,reactjs,editor,draftjs,Javascript,Reactjs,Editor,Draftjs,编辑器正在启动,就好像它有空字符串一样 我试过这个: EditorState.createWithContent(ContentState.createFromText('Hello')) 这是: const html = '<p>Hey this <strong>editor</strong> rocks You don't show what you are doing with the content but the following (i.e. y

编辑器正在启动,就好像它有空字符串一样

我试过这个:

EditorState.createWithContent(ContentState.createFromText('Hello'))
这是:

const html = '<p>Hey this <strong>editor</strong> rocks You don't show what you are doing with the content but the following (i.e. your first option) works correctly 

<Editor
   editorState={EditorState.createWithContent(
          ContentState.createFromText("Hello")
     )}
/>

const html='嘿,这是一个编辑器rocks你没有显示你正在对内容做什么,但是下面的(即你的第一个选项)工作正常


正如这一点:

导入{
编辑
编辑状态,
内容国,
转换格式HTML
}摘自《js草案》;
...
const blocksFromHTML=convertFromHTML(

“嘿,这是一个编辑器如果你感兴趣的话,我已经通过功能组件将HTML引入DraftJS编辑器。下面是基于@Grantnz的答案构建的代码

import React,{useState}来自“React”
从'draft js'导入{Editor、EditorState、RichUtils、ContentState、convertFromHTML}
常量DraftJS=()=>{
//断言硬编码的HTML字符串,将其转换为状态
const blocksFromHTML=convertFromHTML(
“嘿,这是编辑rocks