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
{{ message }}
Repository navigation
useSelectedBlocks / getTextCursorPosition report the block after a gap cursor #3421
When the selection is a gap cursor (e.g. between two blocks without inline content, such as images or custom blocks with content: "none"), BlockNote treats the block after the gap cursor as the one holding the cursor: getTextCursorPosition().block and useSelectedBlocks() return that block. A custom block that highlights itself when it is selected therefore looks selected while the cursor is actually above it.
#3361 fixed Enter at a gap cursor, but not what these APIs report.
What did you expect to happen?
With a gap cursor, no block should be reported as selected (or the API should expose that the selection is a gap cursor), since the cursor is between blocks, not inside one.
Steps to reproduce
Insert two images one after the other
Put the cursor at the end of the paragraph above and press ArrowDown until the gap cursor shows between the two images
Log editor.getTextCursorPosition().block or useSelectedBlocks(editor)
See the second image reported as the cursor block
BlockNote version
v0.55.0
Environment
No response
Additional context
We hit this with custom blocks (content: "none") that draw their own selection outline based on useSelectedBlocks; with a gap cursor between two of them, the lower one gets outlined. We work around it by checking whether the selection is a gap cursor.
Contribution
I'd be interested in contributing a fix for this issue
Sponsor
I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Activity