Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用DraftJS导入自定义html?_Javascript_Reactjs_Draftjs - Fatal编程技术网

Javascript 如何使用DraftJS导入自定义html?

Javascript 如何使用DraftJS导入自定义html?,javascript,reactjs,draftjs,Javascript,Reactjs,Draftjs,我正在尝试用draftJS编写一个编辑器。无法正确导入HTML结构。 我把标准结构改成了我自己的。如 是的 粗体 变成 <p class="article_paragraph"> <span className="custom_bold"> BOLD </span> <br> </p> 粗体 之后,当导入html数据时,草稿不理解此结构。我使用stateToHTML-draft js导出ht

我正在尝试用draftJS编写一个编辑器。无法正确导入HTML结构。 我把标准结构改成了我自己的。如 是的

粗体

变成

<p class="article_paragraph"> <span className="custom_bold"> BOLD </span> <br> </p>

粗体

之后,当导入html数据时,草稿不理解此结构。我使用stateToHTML-draft js导出html

例如,有数据

<p class="article_paragraph"> <span class="custom_bold"> BOLD TEXT </span> <a class="custom_link" href=""> <span class="custom_bold"> 123 </span> </ a> </p>
粗体文本 html的结构在于数据

常量数据=

粗体和斜体

export default function CustomEditor() {
  const [editorState, setEditorState] = useState(
    EditorState.createWithContent(stateFromHTML(data), decorator)
  );
  return (
    <div className="CustomEditor">
      <Tollbar editorState={editorState} onChange={setEditorState} />
      <Editor
        editorState={editorState}
        onChange={editorState => setEditorState(editorState)}
      />

      <textarea
        disabled
        style={{ width: 800, height: 300, marginTop: 20 }}
        value={stateToHTML(editorState.getCurrentContent(), getOptions())}
      />
    </div>
导出默认函数CustomEditor(){
常量[editorState,setEditorState]=useState(
EditorState.createWithContent(stateFromHTML(数据),decorator)
);
返回(
setEditorState(editorState)}
/>
<p class="article_paragraph"> BOLD AND ITALIC </p>
export default function CustomEditor() {
  const [editorState, setEditorState] = useState(
    EditorState.createWithContent(stateFromHTML(data), decorator)
  );
  return (
    <div className="CustomEditor">
      <Tollbar editorState={editorState} onChange={setEditorState} />
      <Editor
        editorState={editorState}
        onChange={editorState => setEditorState(editorState)}
      />

      <textarea
        disabled
        style={{ width: 800, height: 300, marginTop: 20 }}
        value={stateToHTML(editorState.getCurrentContent(), getOptions())}
      />
    </div>