0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

react-draft-wysiwyg html読み込み時に画像が📷になってしまう。

Posted at

カメラになっちゃう。。

画像挿入時は、表示されているが次回読み込み時にカメラになっちゃう。
スクリーンショット 2022-09-16 19.32.04.png

解決

バックエンドのデータ(html)を EditorState へ変更するときに、
convertFromHTML でなく、 htmlToDraft を利用することで解決した。

htmlToDraft は、こちら


before

const conv = convertFromHTML(contents);

const contentState = ContentState.createFromBlockArray(
  conv.contentBlocks,
  conv.entityMap,
);
const data = EditorState.createWithContent(contentState);

const [val, setVal] = useState(data)

after

const conv = htmlToDraft(contents); // 変更

const contentState = ContentState.createFromBlockArray(
  conv.contentBlocks,
  conv.entityMap,
);
const data = EditorState.createWithContent(contentState);

const [val, setVal] = useState(data)

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?