convertFromHTML doesn't preserve <br>s inside <div>s
See original GitHub issueLet’s say I have some text in the editor:
hello
we're separated by a line
and us by two
In the editor, when creating this text, I end up with 6 blocks, with the 2nd, 4th, and 5th having empty text.
The HTML I generate from this text looks like this (which is very similar to the HTML outputted during editing):
<div>hello</div>
<div><br></div>
<div>we're separated by a line</div>
<div><br></div>
<div><br></div>
<div>and us by two</div>
If I use convertFromHTML()
on this HTML, I would expect to get 6 content blocks back. Instead, I only get 3, and all of the empty lines get collapsed. So after I load the 3 blocks, the text in the editor ends up like this:
hello
we're separated by a line
and us by two
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Empty elements removed when using convertFromHTML()
The problem is that any HTML block elements that don't have text in them don't get converted to ContentBlocks. So all of the...
Read more >Re: convert from Div.innerhtml to image in vb.net - ASP.NET ...
Save (Server.MapPath("generated_image.jpg"), ImageFormat.Jpeg) //Response.Write("View the generated image <a target=""_blank"" ...
Read more >Data Conversion | Draft.js
This is useful when saving an editor state for storage, conversion to other formats, or other usage within an application. convertFromHTML() #.
Read more >Head First HTML - Index of
In other words, if you use anything in Head First HTML with CSS & XHTML ... here your brain is doing you a...
Read more >Page 7 - Okler Themes
As you can see in our preview demo, the filter on the right sidebar are not functional. So EZY doesn't comes with a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This was discussed a bit in https://github.com/facebook/draft-js/issues/231:
This is awful default behavior.