Can't select a single block

Đang mở
#2,708 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Start with the setSelection API described in the linked cursor-selections documentation and reproduce the issue using identical startBlock and endBlock IDs. Check the related setTextCursorPosition behavior and ensure selecting one block works from its start through its end without throwing; verify the custom SideMenu and FormattingToolbar use case through editor.getSelection().

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
  1. Using the setSelection function pass it the same block id for the startBlock and endBlock.
  2. 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
  • 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 💖
Ngôn ngữ chính
TypeScript
Star
10.2k
Fork
772
Merge trung bình
3 ngày 11 giờ
Pull request đã merge (30 ngày)
17

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TypeCellOS/BlockNote

Tất cả issue của TypeCellOS/BlockNote

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.