Skip to content

Unexpected peer cursor position after line break #554

Answered by doodlewind
Flrande asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for your feedback. It's an excellent question about how BlockSuite works!

As a block-based framework, BlockSuite models different blocks into different objects (Y.Map under the hood). So for paragraphs, each paragraph block holds a different Y.Text instance. When you perform a line break, we split the paragraph into two paragraphs so they hold different text instances.

After splitting, the right-hand part of the existing paragraph will be deleted. But the peer cursor still references this block. Instead of losing the cursor or throwing an index error, we use the RelativePosition to transform that previous index to a reasonable one, which is the end of the existing block.

As an exam…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by doodlewind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #350 on January 06, 2023 00:57.