githubnext/chopinPublic

Let's compose rich plans together

Anchor a passage of prose, to the character

A passage is a block run plus a range inside it, held twice over: Yjs relative
positions so it stretches as somebody types inside the phrase, and the quoted
text so it can be found again when they cannot be resolved. Same ladder as an
anchor, one level finer, and the same refusal at the bottom — two occurrences
equally near the recorded offset recover neither.

The forward half of the position arithmetic is not exported by @lexical/yjs,
so it is repeated here. passages.test.ts pins it: if a version bump changes how
a text node's characters are indexed inside its parent, the tests fail rather
than the highlight quietly landing a word to the left.

The offset a client sends is a hint the server searches near, not a coordinate,
so the two never have to agree on where text begins. Block digests are still a
precondition, as they are for anchoring a decision.
KCKrzysztof Cieslak authored
f88af19Patch
Parentc5d03ab
2 files changed+552-2
StackedSplit
apps/server/src/plan/passages.test.ts+243 −0
apps/server/src/plan/room.ts+309 −2