kadikraman / draftjs-md-converter

Converts content from Draft.js blocks to Markdown and vice versa.
https://kadikraman.github.io/draftjs-md-converter/
MIT License
145 stars 37 forks source link

Broken parsing from DraftJS content to Markdown when adding an emoji after bolded text #62

Closed aroc closed 4 years ago

aroc commented 4 years ago

What is happening?

When adding an emoji specifically after bolded text in DraftJS, the conversion to markdown breaks.

Here is a full reproduction: https://repl.it/@EricAnderson7/SweetSneakyExecutable#index.js

aroc commented 4 years ago

Also here is the same example but with the single emoji replace with a single letter. The markdown bolding characters are properly placed in this case: https://repl.it/@EricAnderson7/SweetSneakyExecutable-1

aroc commented 4 years ago

Ok it turns out we can simply use Array.from(block.text) instead of block.text.split(''). Of course, this means no support for Internet Explorer as per MDN.

kadikraman commented 4 years ago

Nice, thanks for posting the code examples! Using Array.from resolves it like you said. I'll raise a PR for it.

As for IE - good spot! The latest version doesn't support IE11 either as there are already instances of Array.from in the bundle, so this isn't a regression.