I find a bug when playing with examples/draft-0-10-0/media/media.html
Steps to reproduce


Expected behavior
The old image is replaced by the new one. Or whatever, there should be no error console.
My attempts
The latest commit in my local draft.js master branch is 0a89522, and I run the example in OS X,
chrome.
Thanks for reporting this and including so much detail! @aadsm was able to reproduce this using your steps. If you do end up finding a solution, then we're happy to review a PR. Does this affect your own use of Draft.js? I'm hoping it's a corner case, not sure when this was introduced.
I am building a rich text editor able to insert images. The width of images are not set as 100% of the editor's. So I find this bug.
It is common that images are set as 80% or 70% width, in the center of editor. So I think it is not a corner case.
I used a not that good way to handle with this. Later I will try to better work it out and raise a MR.
朋友,你是怎么解决这个问题的?不管图片是不是100%,我只要按回车立马就有你这个报错:
Unknown DraftEntity key: null.
除非将img外面那层figure 的宽度设为0。让他永远也选不中才勉强解决?
盼复。
i‘v been met the same problem,how can I fixed it?? @flarnie 。
1st:upload a image;(and the image’s width is not 100%)
2nd:click and focus the right blank of the image:
3rd:press the enter key;
4th:BOOM,you will see the bug Unknown DraftEntity key: null
help~~~~
const Media = (props) => {
const entity = props.contentState.getEntity(
props.block.getEntityAt(0)
);
const {src} = entity.getData();
const type = entity.getType();
let media;
if (type === 'audio') {
media = <Audio src={src} />;
} else if (type === 'image') {
media = <Image src={src} />;
} else if (type === 'video') {
media = <Video src={src} />;
}
return media;
};
const entity = props.contentState.getEntity(props.block.getEntityAt(0)); cause the Bug ; @flarnie
@liangwenzhu 这个问题不太好解决,时间太久了我记不清具体过程了(当时基于draft开发的编辑器最终也没上线)。如果你要想解决这个问题,需要去看看源码,然后在源码的基础上去把报错的地方给修正下。比如去监听 onEnter 事件,判断下当前光标是否在图片上,如果在图片上就额外怎么处理下。别的比如 delete,backspace 可能也需要做额外处理。