jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.42k stars 1.16k forks source link

The decorator is unavailable for EditorState.createWithContent #589

Open aleafo opened 6 years ago

aleafo commented 6 years ago

I was trying to edit the html content made by other rich editor ( not by draft ), so the import htmlToDraft from 'html-to-draftjs' is unavailable, or else it will throw fatal error in some conditions. But the decorator is unavailable when use the component Editor from react-draft-wysiwyg.

http://runjs.cn/code/8wgkxjp1 Just like above, it's all be ok for the decorator while using the component Editor form react-draft.

So, it must be something wrong with this plugin.

aleafo commented 6 years ago

I found the answer by review the source code. The decorator should be an array like this: const decorator = [ { strategy: findImageEntities, component: Image, }, ]; And then pass it to the Editor prop. `

` I suggest the decorator param reserving, or else it may be difficult to decorate the data dynamically.

354574876 commented 6 years ago

By this way , the Image in Editor cant`t be edited

aleafo commented 6 years ago

Yes. Images could not be edited. If you have any idea ?