TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
5.9k stars 384 forks source link

`tryParseMarkdownToBlocks` not parsing checklists #826

Closed TheMikeyRoss closed 3 weeks ago

TheMikeyRoss commented 3 weeks ago

Describe the bug I'm parsing a markdown to blocks and it works fine but it seems to be missing the checkboxes (see attached image

image

Misc

matthewlipski commented 3 weeks ago

I was scratching my head with this a little as well, but turns out things are actually being parsed correctly according to the GitHub flavoured Markdown spec. You just need to have a space in between the brackets as shown in the example.

TheMikeyRoss commented 3 weeks ago

@matthewlipski But I didn't manually type the brackets I literally just fetched them from my DB and parsed with tryParseMarkdownToBlocks. To replicate my issue:

1- In blocknote, click the plus button to open the dropdown menu and select checklist 2- Start typing and you'll see an actual checkbox in every line your write (not brackets, but actual interactive checkboxes) 3- Save the content you wrote in a database using graphql or whatever, or maybe even a react state temporarily 4- Parse that content you saved using tryParseMarkdownToBlocks and it will look like the screenshot above

I didn't add or remove any spaces between any brackets.

TheMikeyRoss commented 3 weeks ago

I just checked directly in my mongoDB and it has a space between the brackets:

image

but when parsed in the client ui:

image

I consoled logged the notes (before parsing it) and it looks fine with a space between the brackets:

image

So I'm fairly confident the tryParseMarkdownToBlocks is removing a space between the brackets or doing something else wrong

TheMikeyRoss commented 3 weeks ago

image the console.log is showing that there's a space between the brackets, but the tryParseMarkdownToBlocks isn't

TheMikeyRoss commented 3 weeks ago

@matthewlipski or maybe it's replaceBlocks that's removing the space between brackets?

TheMikeyRoss commented 3 weeks ago

@matthewlipski Oops my bad, the problem is in replaceBlocks and not tryParseMarkdownToBlocks

I console logged the parsed blocks and it's keeping the space between the brackets image

So the problem is 100% coming from replaceBlocks

matthewlipski commented 3 weeks ago

Nice find, thanks for diving into this!