What’s broken?
It is not possible to select a single block via the setSelection function or seemingly any other way. Passing the same block or block id throws the error:
Attempting to set selection with the same anchor and head blocks (id ${startBlockId}).
The following also does not set the selection for the given block:
editor.setTextCursorPosition(block.id, "start");
editor.focus();
What did you expect to happen?
editor.setSelection(block.id); or editor.setSelection(block.id, block.id); should select a single block from its start to its end.
Steps to reproduce
- Using the setSelection function pass it the same block id for the
startBlock and endBlock.
- The error is thrown, rather than the block being selected from beginning to end.
BlockNote version
0.47.1
Environment
React 18.2
Additional context
I'm currently trying to build a custom SideMenu button that on click selects the corresponding block and opens a custom FormattingToolbar that uses editor.getSelection().
Contribution
Sponsor
What’s broken?
It is not possible to select a single block via the
setSelectionfunction or seemingly any other way. Passing the same block or block id throws the error:Attempting to set selection with the same anchor and head blocks (id ${startBlockId}).The following also does not set the selection for the given block:
What did you expect to happen?
editor.setSelection(block.id);oreditor.setSelection(block.id, block.id);should select a single block from its start to its end.Steps to reproduce
startBlockandendBlock.BlockNote version
0.47.1
Environment
React 18.2
Additional context
I'm currently trying to build a custom SideMenu button that on click selects the corresponding block and opens a custom FormattingToolbar that uses
editor.getSelection().Contribution
Sponsor