Describe the bug
When using the <FormattingToolbar>, if the user double-clicks at end of a line, BlockNote crashes.
To Reproduce
- Use the FormattingToolbar, like this:
<BlockNoteView
editor={editor}
formattingToolbar={false}>
<FormattingToolbar />
</BlockNoteView>
- Enter a few characters.
- Double-click at the end of the line.
- Note errors in the console, Blocknote unreachable. "Uncaught TypeError: Cannot read properties of undefined (reading 'type')"
Sandbox: https://stackblitz.com/edit/github-5bekpt?file=App.tsx
The issue seems to start in this function in TextAlignButton.tsx, where block === undefined, which causes checkBlockHasDefaultProp to error.
const textAlignment = useMemo(() => {
const block = selectedBlocks[0];
if (checkBlockHasDefaultProp("textAlignment", block, editor)) {
return block.props.textAlignment;
}
return;
}, [editor, selectedBlocks]);
Misc
Describe the bug
When using the
<FormattingToolbar>, if the user double-clicks at end of a line, BlockNote crashes.To Reproduce
Sandbox: https://stackblitz.com/edit/github-5bekpt?file=App.tsx
The issue seems to start in this function in
TextAlignButton.tsx, whereblock === undefined, which causescheckBlockHasDefaultPropto error.Misc