sstur / draft-js-utils

DraftJS: import/export ContentState to and from HTML/Markdown
ISC License
883 stars 234 forks source link

stateFromHTML reorders content #151

Open tfsjohan opened 5 years ago

tfsjohan commented 5 years ago

I have an issue where I can get crappy HTML and it breaks stateFromHTML in a weird way.

Givning it html like this:

<h1>Heading</h1>Some content without a wrapping tag<h2>Heading 2</h2>

Is parsed to:

<p>Some content without a wrapping tag</p><h1>Heading 1</h1><h2>Heading 2</h2>

I would like to wrap the content in a P tag, but I don't want it to get reordered.

sstur commented 5 years ago

This is a known issue. I do believe this has been an issue since the logic was first written 4-5 years ago.

Specifically the behavior is this: Any content that is not wrapped in a block gets put at the top of the document before all content that IS wrapped in a block.

I would need to do some non-trivial refactoring to change this behavior.