Rosey/markdown-draft-js

Two spaces and a new-line in Markdown doesn't translate into a new-line in draft-js

Closed this issue ยท 5 comments

tilds commented

Hi, I was checking out the demo: http://www.roserobertson.me/markdown-draft-js/ and noticed that if I end a line in the markdown with two spaces and a new-line then the next line is just appended on to the first in the draft-js.
This is intended?
image

Rosey commented

Hmm yeah I think that is a bug, nice catch ๐Ÿ‘ / ๐Ÿ˜ข

tilds commented

I looked at it a bit more and the problem seems to be that 'hardbreak' is not handled in markdown-to-draft.parseInline()

Looking at the debug mode of the remarkable demo: https://jonschlinkert.github.io/remarkable/demo/ I get this:

  {
    "type": "paragraph_open",
    "tight": false,
    "lines": [
      0,
      2
    ],
    "level": 0
  },
  {
    "type": "inline",
    "content": "First line  \nSecond line",
    "level": 1,
    "lines": [
      0,
      2
    ],
    "children": [
      {
        "type": "text",
        "content": "First line",
        "level": 0
      },
      {
        "type": "hardbreak",
        "level": 0
      },
      {
        "type": "text",
        "content": "Second line",
        "level": 0
      }
    ]
  },
  {
    "type": "paragraph_close",
    "tight": false,
    "level": 0
  }
]
Rosey commented

ahh, very nice. OK I'm a bit busy these days but I'll try to get to this, or if anyone else who is reading this issue and has the inclination they are welcome to take it on!

Rosey commented

Thanks to @kamilbielawski a fix for this has been released under 1.4.0

Rosey commented

(and thanks @tilds for your detailed comment about what the issue was too ๐Ÿ˜„)