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

html to draftjs not working properly for some elements #765

Open jan0991 opened 5 years ago

jan0991 commented 5 years ago

I need to be able to toggle HTML editor, so I used the solution provided by @NukaPunk here: https://github.com/jpuri/react-draft-wysiwyg/issues/315#issuecomment-439028260

The only issue is that if I try to use <div>...</div> in HTML mode it just deletes it or converts to <span> or <p>.. I also can't add class names or styles.

What could be causing this? Any other way to get a properly working HTML editor?

Thanks!

jpuri commented 5 years ago

Current fix for HTML to DraftJS conversion is sadly not good enough :( I am not able to think of a good solution for you atm, you can play around with the code of html-to-draftjs for this.

Huespal commented 5 years ago

I'm also on this.

I think htmlToDraft() function makes the html tag's being converted magic. Did you, @jan0991 find out some imaginative solution to get it working?

I'm playing with this libs at the moment, with no luck.

import { stateToHTML } from 'draft-js-export-html';
import { stateFromHTML } from 'draft-js-import-html';

Thank you.

Solved -> https://github.com/jpuri/react-draft-wysiwyg/issues/772#issuecomment-460251352