微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

React Draft.js 中的图像显示问题

如何解决React Draft.js 中的图像显示问题

我在我的一个项目中使用了 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 },}}
  />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。