githubnext/chopinPublic

Let's compose rich plans together

Resolve and paint commented passages in the browser

Resolution happens client-side for the reason anchors already do: a Lexical key
is per-editor, so the server's key means nothing here. The inverse of the
arithmetic the server had to reimplement is exported by @lexical/yjs, so this
half is theirs to keep correct.

Describing a selection deliberately produces no positions — block indices, the
digests they were read at, and the selected text are all things the server can
check against its own copy. The two ends must agree on which blocks the source
addresses; they need not agree on the offset, because the server searches for
the quote near it, so a divergence surfaces as a refusal rather than as a
comment landing on the wrong sentence.

Painting uses the CSS Custom Highlight API, the same route Lexical takes for
remote selections, under names that cannot collide with its. Nothing enters the
document: the dialect has no mark node, and adding one would make one reader's
pointer everybody's, and undoable. Without the API the covered blocks are
outlined instead, which is less precise and honest about it.
KCKrzysztof Cieslak authored
31f0defPatch
Parent11ce29d
6 files changed+477-0
StackedSplit
bun.lock+1 −0
packages/editor/package.json+1 −0
packages/editor/src/marks.ts+123 −0
packages/editor/src/passage.test.ts+115 −0
packages/editor/src/passage.ts+215 −0
packages/editor/src/styles.css+22 −0