React-draft-wysiwyg: Feature request: convert state from HTML

Created on 4 Dec 2016  Â·  11Comments  Â·  Source: jpuri/react-draft-wysiwyg

Thanks for great editor!
Currently it works well when writing a new post, but when I try to edit posts, some tags are not converted to editorState properly.
For example, iframe tag isn't converted to editorState using draft-js 's basic convertFromHTML method.
I think this editor will be better if it supports converting tags, which are used by this editor, into editorState.

enhancement

Most helpful comment

I am realizing this is one most wanted thing to have lib to convert html to editorState, I am prioritizing it and starting on coding for it.

All 11 comments

@ZeroCho: I see, I will work on it. But I can not promise how soon as this is comparatively bigger requirement. But you will definitely hear back from me.

@ZeroCho: why do not you consider saving editor state as JSON ?

@jpuri Because i already wrote 100+ posts in my blog. All of them are saved in HTML. So I cannot take risk to convert all of them into JSON. But I'll consider it anyway.

I include a way in https://andresin87.github.io/wysiwyg/ under [import HTML] story

@andreslucas Well, I'm afraid that your import HTML doesn't work correctly.
I typed this below code, and it didn't render correctly.

<p>test</p>
<iframe src="//codepen.io/zerocho/embed/mOMyJb/?height=265&theme-id=0&default-tab=html,result&embed-version=2" height="315px" width="100%" />
<p>Yeah</p>

Also this didn't work correctly

<p>test</p>
<p>paragraph</p>
<p>Yeah</p>

@ZeroCho You're right. I'll review what is happening. I'm using https://github.com/sstur/draft-js-import-html as a dependency.

draft-js-import-html lost inline style when convert html to contentState。

I am realizing this is one most wanted thing to have lib to convert html to editorState, I am prioritizing it and starting on coding for it.

Thank you @jpuri :-)

I just published this on npm [email protected]. Plz not atm it can take care of only html generated by react-draft-wysiwyg.

I am open to extend it for more common use cases.

Next version of the lib 0.1.0-beta2 is out there for use. Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trongbang86 picture trongbang86  Â·  3Comments

FriOne picture FriOne  Â·  3Comments

june50232 picture june50232  Â·  4Comments

kcabading picture kcabading  Â·  3Comments

DiegoGallegos4 picture DiegoGallegos4  Â·  4Comments