BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Error due to block insertion via Side Menu - Slash Menu open in a block that doesn't contain inline content

Open marsee339 opened this issue 1 year ago • 4 comments

Bug

image

To Reproduce

  1. Add a custom block without InlineContent
  2. Click the + in its Side Menu and select the default text block (e,g, Heading). The editor crashes with the error - Slash Menu open in a block that doesn't contain inline content.

Reproduced in https://www.blocknotejs.org/examples/alert-block (if you remove InlineContent in it). Other custom blocks are added under the current block without problems

marsee339 avatar Oct 31 '23 11:10 marsee339

Hmm I'm seeing a different bug, the slash menu opens fine but a new block below isn't created - did you both remove the InlineContent component from render, and change containsInlineContent to false?

matthewlipski avatar Nov 01 '23 13:11 matthewlipski

Here is the full code for Alert.tsx https://www.blocknotejs.org/examples/alert-block File: sample.txt

It's still reproducing image

Just slightly correct the condition in const blockIsEmpty = block.content!.length === 0; to const blockIsEmpty = block.content && block.content!.length === 0;

marsee339 avatar Nov 01 '23 15:11 marsee339

Ah yeah, I see the issue now. The bug actually goes deeper - for some reason the text cursor position doesn't update internally when the slash menu opens, only after you start typing. Thanks for reporting this, will fix👍

matthewlipski avatar Nov 05 '23 17:11 matthewlipski

Ah yeah, I see the issue now. The bug actually goes deeper - for some reason the text cursor position doesn't update internally when the slash menu opens, only after you start typing. Thanks for reporting this, will fix👍

Would this also cause the behaviour of having your cursor active in a block above, and then if you scroll to add a block somewhere else the slash menu tries to scroll back to where your cursor was last active?

EDIT: No, this seems to be from the floating-ui library settings. Disregard here, but I haven't quite fixed it yet.

nicholasdavidbrown avatar Feb 27 '24 04:02 nicholasdavidbrown

Seems like both of these issues are fixed now, can't reproduce them on 0.13.4 - gonna close this issue

matthewlipski avatar May 31 '24 18:05 matthewlipski