Skip to content

[lexical-website] Documentation Update: point the selection guide at NodeCaret - #9229

Merged
etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-selection-caret-crosslink
Sep 24, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-selection-caret-crosslink

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

concepts/selection.md explains selection without ever mentioning the caret
model, and its only cross-link is to the Shadow DOM page. NodeCaret is the
API for traversing from a selection point — it has its own page, it is what
LexicalSelection is built on internally, and lexical exports
$caretRangeFromSelection / $setSelectionFromCaretRange to convert between
the two. A reader who needs to walk the document from a selection currently
has no path from this page to that one.

This adds a tip in "Working with selection" naming the page and the two
conversion helpers. No existing text changes.

Test plan

Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that the link and the named exports
resolve.

Before

$ grep -c "traversals\|NodeCaret" packages/lexical-website/docs/concepts/selection.md
0

$ grep -c "Caret" packages/lexical/src/LexicalSelection.ts
99

The page a reader needs is unreachable from the one they are on.

After

$ grep -n "traversals\|caretRangeFromSelection" packages/lexical-website/docs/concepts/selection.md
68:[Node Traversals with NodeCaret](./traversals.md).
69:`$caretRangeFromSelection(selection)` converts a `RangeSelection` into the
71:`$setSelectionFromCaretRange(range)` converts back.

$ ls packages/lexical-website/docs/concepts/traversals.md
packages/lexical-website/docs/concepts/traversals.md

$ grep -n "caretRangeFromSelection\|setSelectionFromCaretRange" packages/lexical/src/index.ts
55:  $caretRangeFromSelection,
66:  $setSelectionFromCaretRange,

Both helpers are exported from lexical
(packages/lexical/src/caret/LexicalCaretUtils.ts:133,162), and
traversals.md documents the range type they produce.

…NodeCaret

## Description

`concepts/selection.md` explains selection without ever mentioning the caret
model, and its only cross-link is to the Shadow DOM page. NodeCaret is the
API for traversing from a selection point — it has its own page, it is what
`LexicalSelection` is built on internally, and `lexical` exports
`$caretRangeFromSelection` / `$setSelectionFromCaretRange` to convert between
the two. A reader who needs to walk the document from a selection currently
has no path from this page to that one.

This adds a tip in "Working with selection" naming the page and the two
conversion helpers. No existing text changes.

## Test plan

Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that the link and the named exports
resolve.

### Before

```
$ grep -c "traversals\|NodeCaret" packages/lexical-website/docs/concepts/selection.md
0

$ grep -c "Caret" packages/lexical/src/LexicalSelection.ts
99
```

The page a reader needs is unreachable from the one they are on.

### After

```
$ grep -n "traversals\|caretRangeFromSelection" packages/lexical-website/docs/concepts/selection.md
68:[Node Traversals with NodeCaret](./traversals.md).
69:`$caretRangeFromSelection(selection)` converts a `RangeSelection` into the
71:`$setSelectionFromCaretRange(range)` converts back.

$ ls packages/lexical-website/docs/concepts/traversals.md
packages/lexical-website/docs/concepts/traversals.md

$ grep -n "caretRangeFromSelection\|setSelectionFromCaretRange" packages/lexical/src/index.ts
55:  $caretRangeFromSelection,
66:  $setSelectionFromCaretRange,
```

Both helpers are exported from `lexical`
(`packages/lexical/src/caret/LexicalCaretUtils.ts:133,162`), and
`traversals.md` documents the range type they produce.
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 24, 2026 4:49pm UTC
lexical-playground Ready Ready Preview Sep 24, 2026 4:49pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 24, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 24, 2026
Merged via the queue into meta:main with commit 3085cb2 Sep 24, 2026
42 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 6b4a4b73 Deployed Sep 24, 2026 by vercel[bot]
Preview – lexical-playground — 6b4a4b73 Deployed Sep 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants