首页 > 解决方案 > 所见即所得编辑器无法在编辑器框中显示图像?

问题描述

我正在尝试使用所见即所得编辑器在我的编辑器上显示图像,该编辑器能够在编辑器中显示文本,但无法显示仅显示相机图标的图像。在这里我正在尝试将字符串转换为 html

这是我的代码 -

> template:"<p><img src="https://i.imgur.com/RcsU9GA.png"
> alt="undefined" style="float:none;height: undefined;width:
> undefined"/></p>"

useEffect(() => {
    if (props.template) {
      debugger;
      const sampleMarkup = props.template;
      console.log(convertFromHTML(props.template));
      const blocksFromHTML = convertFromHTML(sampleMarkup);
      seteditorState(
        EditorState.createWithContent(
          ContentState.createFromBlockArray(
            blocksFromHTML.contentBlocks,
            blocksFromHTML.entityMap
          )
        )
      );
    } else {
      seteditorState(EditorState.createEmpty());
    }
  }, [props.template]);

标签: reactjs

解决方案


推荐阅读