You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When having a static formatting toolbar, and a table as the first block of the editor, clicking in the left margin of it will crash the editor (the whole client to feel more precise) - You have to click the empty space, avoid clicking the plus sign or the drag icon.
An easier way to reproduce it is having a table as the first block, then create a second block beneath it and nest it. Then you click the margin on the nested block (there's plenty of space to click now) the crash occurs again.
I tested a possible fix in packages/core/src/extensions/TableHandles/TableHandles.ts in getCellSelection:
<...>returneditor.transact((tr)=>{<...>}else{constfromCellPos=selection.$from.pos-selection.$from.parentOffset-1;consttoCellPos=selection.$to.pos-selection.$to.parentOffset-1;// Opt-out when the selection is not pointing into cellsif(fromCellPos<=1||toCellPos<=1){returnundefined;}$fromCell=tr.doc.resolve(fromCellPos);$toCell=tr.doc.resolve(toCellPos);}<...>
And that worked, but I am not sure if that's the right approach, seems buggy to select a magic number like 1 to be the threshold of fromCellPos and toCellPos.
What did you expect to happen?
I'd expect it not to crash if I clicked anywhere, really.
Steps to reproduce
Create a new document with static toolbar (there's an example in the playground with it);
With an empty document, create a table as the first block in the editor;
Create another block and then nest it;
When hovering the nested block you'll see the plus sign and the drag button a bit to the right, click on the empty space to its left;
See the whole thing crashes, with error RangeError: Position -1 out of range;
BlockNote version
I could reproduce with v0.50.0, but I know it also happened with v0.48.1
Environment
Chrome v140.0.7339.80 - Ubuntu 22.04
Additional context
Following videos done with example static-formatting-toolbar from playground
What’s broken?
When having a static formatting toolbar, and a table as the first block of the editor, clicking in the left margin of it will crash the editor (the whole client to feel more precise) - You have to click the empty space, avoid clicking the plus sign or the drag icon.
An easier way to reproduce it is having a table as the first block, then create a second block beneath it and nest it. Then you click the margin on the nested block (there's plenty of space to click now) the crash occurs again.
I tested a possible fix in
packages/core/src/extensions/TableHandles/TableHandles.tsingetCellSelection:And that worked, but I am not sure if that's the right approach, seems buggy to select a magic number like 1 to be the threshold of
fromCellPosandtoCellPos.What did you expect to happen?
I'd expect it not to crash if I clicked anywhere, really.
Steps to reproduce
RangeError: Position -1 out of range;BlockNote version
I could reproduce with v0.50.0, but I know it also happened with v0.48.1
Environment
Chrome v140.0.7339.80 - Ubuntu 22.04
Additional context
Following videos done with example static-formatting-toolbar from playground
I'll link a video of the problem:
The easiest way to reproduce:
bn-table-crash.mp4
A bit harderbut still able:
bn-table-crash-only-table.mp4