Unknown DraftEntity key: null.
See original GitHub issueError:

Code to run:
const contentBlock = htmlToDraft(sanitizeHtml(this.wysiwygHtml.value, sanitizeRules));
const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks);
const newEditorState = EditorState.createWithContent(contentState);
this.onEditorStateChange(newEditorState);
Code to paste:
<a href="https://test.com" target="_blank" data-saferedirecturl="https://www.test.com/url?hl=ru&q=https://test.com&source=gmail&ust=1518687009434000&usg=AFQjCNGJCuM_hG6wsHlvqVTpepzndFgVkQ"><img src="https://proxy/28oL4gKFefkX8wOuCE5zIS5UPzeCfGKO-3mjWWCNk_HZOIIhR9Kxyx9sKG2nNKU_SWOVY_dk_lVVJKxv-P7pRe__6VurG3wi6kOwiHXAERe7RjM=s0-d-e1-ft#https://test.com/images/signatures/new/ira.jpg" alt="" class="CToWUd"></a>
Versions:
"react-draft-wysiwyg": "^1.12.7",
"draft-js": "^0.10.5",
"draftjs-to-html": "^0.8.2",
"html-to-draftjs": "^1.1.2"
Issue Analytics
- State:
- Created 6 years ago
- Comments:46 (7 by maintainers)
Top Results From Across the Web
Unknown DraftEntity key when inserting media in Draftjs
I solve the problem with adding one space so I convert : editorState:AtomicBlockUtils.insertAtomicBlock( newEditorState, entityKey, '' ).
Read more >Uncaught Invariant Violation: Unknown DraftEntity key: null. -
Uncaught Invariant Violation: Unknown DraftEntity key: null. react-draft-wysiwyg. 18 October 2020 Posted by Liqiankun. A bad issue.
Read more >解决Unknown DraftEntity key: null. 插入图片,再输入中文会 ...
在React富文本编辑react-draft-wysiwyg中插入图片,在之后输入中文就会报错。错误如下;这个错误在Github有题issue但是没有被解决,我在简书上面找到 ...
Read more >v0.10 API Migration - Draft.js
DraftEntity instances and storage will be immutable. ... entityKey is a string key associated with that entity when it was created.
Read more >react-draft-wysiwyg で画像を入れた後に文字入力するとエラー ...
Copied! Unknown DraftEntity key: null. 解決. draft-js のバージョンの問題だった。 0.11.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a very real problem and I got a good reproduction case:
in the html preview.
First Problem: The image is still in the generated html but not in the editor anymore.
Second problem: If you initialize an editor with this HTML (which is generated by
draftjs-to-html) you get the above crash:Invariant Violation: Unknown DraftEntity key: null.–
Edit: Here’s the broken state json dump:
The first block (c9cv2) crash because
block.getEntityAt(0)is null here: https://github.com/jpuri/react-draft-wysiwyg/blob/f0da14fe8d082ee078da1c2eceac3789d400db26/src/renderer/index.js#L11I solved this error. I do a function which one add an image into editor, it’s mean I have to get the link of image then add it to
imgtag of HTML, problem is here. Add it into<p><img src="your_image_link" ></img></p>before parse it into editor again. Theptag is required in editor.