0

我在我的一个项目中使用 react draftjs。但是,当我尝试通过 url 添加图像时,图像会显示,但是当我保存它并将信息发送到服务器并稍后获取它时,我没有得到任何图像。它只是空的数字标签。

我的状态:

const [editorState, setEditorState] = useState(() =>
    EditorState.createEmpty()
);

const [convertedContent, setConvertedContent] = useState(null);

const handleEditorChange = (state) => {
    setEditorState(state);
    convertContentToHTML();
};

const convertContentToHTML = () => {
    let currentContentAsHTML = convertToHTML(editorState.getCurrentContent());
    setConvertedContent(currentContentAsHTML);
};

我的编辑器组合:

<Editor
     editorState={editorState}
     onEditorStateChange={handleEditorChange}
     wrapperClassName="wrapper-class"
     editorClassName="editor-class"
   toolbarClassName="toolbar-class"
    placeholder="Type something here..."
    toolbar={{
    inline: { inDropdown: false },
    list: { inDropdown: true },
    textAlign: { inDropdown: false },
    link: { inDropdown: true },
    history: { inDropdown: false },
   }}
  />
4

0 回答 0