Skip to content

[lexical] Bug Fix: collapse to a paragraph on select-all delete of a non-paragraph first block - #8884

Merged
etrepum merged 15 commits into
meta:mainfrom
gunjanjaswal:fix/5835-select-all-delete-non-paragraph-first-block
Aug 31, 2026
Merged

etrepum merged 15 commits into
meta:mainfrom
gunjanjaswal:fix/5835-select-all-delete-non-paragraph-first-block

Conversation

@gunjanjaswal

@gunjanjaswal gunjanjaswal commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

When you select all and delete, the document should collapse to a single empty paragraph, the same as an empty editor. It does when the first block is a paragraph, but when the only remaining block is a heading, quote, list, or nested list, that block survives empty and keeps its type instead of becoming a paragraph.

RangeSelection.collapseAtStart already covers backwards deletion of a heading or quote, but not forward Delete or the list cases. This adds a targeted collapse in RangeSelection.deleteCharacter: after a full-range delete leaves the selection collapsed, if the root's only content is a single empty non-paragraph block sitting on a single empty branch, it is replaced with a fresh empty paragraph. The guard is deliberately tight, so any sibling content, decorator, shadow root, or surviving text leaves the block untouched.

It lives in deleteCharacter rather than the shared removeText / $removeTextFromCaretRange primitive on purpose. insertText also routes through removeText to clear the selection before inserting (the Prettier "format" flow does this on a lone code block), and that replacement has to keep its block type.

Closes #5835

Test plan

Before

Select all + delete with a heading, quote, list item, or nested list as the only block left an empty block of that type instead of a paragraph, and there was no coverage for it.

After

Added unit tests in LexicalCaret.test.ts covering select-all + delete, both Backspace and forward Delete, with the only block being a heading, quote, list item, and a nested list. Each collapses to a single empty paragraph. Controls confirm the paragraph-first case and a partial (non-full-range) delete are unaffected. The new behavior tests fail on main without the source change. Unit tests for the affected packages, tsc, and eslint all pass.

…raph first block

When a range deletion removes all root content and the surviving block is a non-paragraph element block (list item, heading, quote, or nested list), it lingered empty while keeping its element type instead of collapsing to a plain paragraph.

Add a tight special-case in $removeTextFromCaretRange: once the removal settles, if the sole remaining root content is a single empty non-paragraph block whose ancestor chain to the root is a single empty branch, replace that top-level subtree with a fresh empty paragraph. Shadow roots, decorators, and any sibling content bail out so the shared deletion path is otherwise untouched.

Closes meta#5835
@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 Jul 27, 2026
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 31, 2026 5:54pm
lexical-playground Ready Ready Preview Aug 31, 2026 5:54pm

Request Review

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't pass tests.

The previous approach put the "empty document collapses to a paragraph"
special case inside $removeTextFromCaretRange. That primitive is shared:
insertText() also calls removeText() to clear the old selection before
inserting, so replacing all of a lone non-paragraph block's content (for
example the Prettier "format" button on a single code block) was wrongly
collapsing the block to a paragraph, and the reformatted text landed in a
plain paragraph. That broke the CodeActionMenu e2e test.

Move the logic to RangeSelection.deleteCharacter, the actual delete-key
path, so replacements are untouched. The existing collapseAtStart handling
there only covers backwards deletion of a heading or quote; extend it to
also cover forward Delete and list / nested-list survivors. The guard stays
tight: it only fires when a full-range delete leaves the root with a single
empty non-paragraph block on a single empty branch, bailing on any sibling
content, decorator, or shadow root.

Revert the $removeTextFromCaretRange change and rewrite the unit tests to
drive the behavior through deleteCharacter (both directions), plus a
regression test that replacing all text in a lone block keeps its type.

Closes meta#5835
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Good catch, that was a real bug on my end, not a flake. The collapse-to-paragraph was sitting in $removeTextFromCaretRange, but insertText clears the old selection through removeText too, so the Prettier format flow on a lone code block was getting collapsed into a paragraph before the reformatted text was inserted, which is what timed out the CodeActionMenu test.

I moved it to deleteCharacter where the existing collapseAtStart handling already lives, extended that to cover forward Delete and list survivors, and reverted the change to the caret primitive. The tests now drive it through the delete path in both directions, plus a regression test that replacing all text in a lone block keeps its type. Rebased on current main; the unit suite and the e2e specs around select-all/delete are green locally.

@etrepum

etrepum commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

@gunjanjaswal gunjanjaswal changed the title fix: collapse to paragraph when select-all delete empties a non-paragraph first block [lexical] Bug Fix: collapse to a paragraph on select-all delete of a non-paragraph first block Jul 30, 2026
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks, updated the title and description to match the template (packages tag + PR type in the title, Closes #5835 and a Before/After test plan in the body). CI is green now as well. Happy to adjust anything else.

claude added 2 commits August 30, 2026 21:23
… delete gesture and respect collapseAtStart when collapsing an emptied root

## Description

Follow-up to the select-all-delete collapse on this branch. As it stands the
collapse hardcodes `topLevel.replace($createParagraphNode())` and only runs from
`RangeSelection.deleteCharacter`, which leaves three problems:

- **Other delete gestures still leave the empty block behind.** `deleteWord`,
  `deleteLine` (for a selection inside one block) and the rich-text cut handler
  reach `removeText` directly, so select-all followed by Ctrl/Alt+Backspace,
  Cmd+Backspace or Ctrl+X still ends on an empty heading/quote/list while plain
  Backspace ends on a paragraph.
- **It overrides `collapseAtStart`.** Replacing the block outright converts
  every non-paragraph element, including a block node whose `collapseAtStart`
  returns `false` -- the `ElementNode` default, so every third-party block node
  that never implemented it. Those blocks used to survive even a backwards
  delete.
- **It dissolves slot hosts.** The up-walk treats any single-regular-child
  ancestor as a transparent wrapper, so a host whose one child was emptied is
  replaced and its slot content is re-homed onto a plain `ParagraphNode` that
  declares no slots and never renders it.

The collapse is now delegated to `$collapseAtStart`, the extension point each
block type already implements to say how -- and whether -- it dissolves:
`HeadingNode` and `QuoteNode` become paragraphs, `ListItemNode` lifts itself out
of its list, `CodeNode` unwraps its children, and a node returning `false` keeps
its block. That covers every case the hardcoded replace did (heading, quote,
list, nested list, both directions), so the replace is gone.

`deleteWord`, `deleteLine` and `onCutForRichText` now run the same collapse. The
helper is exported as `INTERNAL_$collapseEmptiedRootToParagraph` under the
existing `INTERNAL_` convention (as `INTERNAL_$isBlock` is) so
`@lexical/rich-text` can reach it from its cut handler.

The up-walk also bails on an ancestor with occupied slots, mirroring
`ElementNode.isEmpty`, which is already slot-aware: a host still holding slot
content means the document is not empty. The unreachable `$isElementNode`
narrowing is dropped (`getParent` is typed to `ElementNode`) and the in-loop
`$isRootOrShadowRoot` is now `isShadowRoot`, since the loop condition already
excludes the root.

The unit tests move out of `LexicalCaret.test.ts` -- the change is in
`RangeSelection`, not in the `$removeTextFromCaretRange` primitive -- into
`Issue5835Repro.test.ts`, following the repo's `IssueNNNNRepro` convention, and
grow coverage for every gesture and direction plus the `collapseAtStart` opt-out
and the slot host. A rich-text unit test covers cut, and a playground e2e spec
covers the bug as reported, in a browser.

## Test plan

### Before

The new tests against this branch's parent commit:

```
$ npx vitest run packages/lexical/src/__tests__/unit/Issue5835Repro.test.ts \
    packages/lexical-rich-text/src/__tests__/unit/RichTextCutAllCollapse.test.ts
 Test Files  2 failed (2)
      Tests  20 failed | 10 passed (30)
```

```
 FAIL  RichTextCutAllCollapse.test.ts > select-all + cut collapses to an empty paragraph (meta#5835) > a lone heading becomes an empty paragraph
AssertionError: expected [ 'heading' ] to deeply equal [ 'paragraph' ]
- Expected
+ Received
+   "heading",
```

The playground e2e spec, against a dev server on the parent commit:

```
$ npx playwright test --project=chromium --retries=0 \
    packages/lexical-playground/__tests__/e2e/SelectAllDelete.spec.mjs
  ok   1 ... a heading, with Backspace (4.2s)
  FAIL 2 ... a heading, with forward Delete (8.7s)
  FAIL 3 ... a quote, with forward Delete (7.6s)
  FAIL 4 ... a list followed by a paragraph, with Backspace (8.4s)
  FAIL 5 ... a heading, with delete-by-word (7.9s)
  4 failed
  1 passed (22.1s)
```

```
    Error: innerHTML of contenteditable in page did not match
    - Expected  - 2
    + Received  + 2

    - <p class="PlaygroundEditorTheme__paragraph" dir="auto">
    + <h1 class="PlaygroundEditorTheme__h1" dir="auto">
        <br data-lexical-managed-linebreak="true" />
    - </p>
    + </h1>
```

### After

Full unit suite (jsdom):

```
$ npx vitest run
 Test Files  341 passed (341)
      Tests  6008 passed | 2 skipped (6010)
```

Playground e2e, Chromium, against a dev server:

```
$ npx playwright test --project=chromium --retries=0 \
    packages/lexical-playground/__tests__/e2e/SelectAllDelete.spec.mjs \
    packages/lexical-playground/__tests__/e2e/Selection.spec.mjs
  11 skipped
  43 passed (1.7m)
```

The delete- and clipboard-heavy specs, which cover the `removeText` paths this
change hooks into (CopyAndPaste exercises cut, CardSlot exercises a slot host):

```
$ npx playwright test --project=chromium \
    .../CopyAndPaste .../List.spec.mjs .../CodeBlock.spec.mjs .../Headings \
    .../CardSlot.spec.mjs .../Clear.spec.mjs .../Keyboard.spec.mjs
  2 skipped
  135 passed (4.5m)
```

Static checks:

```
$ npx tsc --noEmit -p .            # no output
$ npm run flow                     # No errors!
$ npx eslint packages/ scripts/    # no output
$ npx prettier --check "packages/**/*.{ts,tsx,mjs}"
All matched files use Prettier code style!
```

Firefox and WebKit were not exercised: this container has no matching Playwright
builds for them, so only the Chromium project was run.

Co-Authored-By: Claude Opus 5 <[email protected]>
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Gentle bump on this one. It's been green a while (40 checks passing), and the title and description follow the template now, per @etrepum's earlier note.

It's a small, scoped fix: after select-all-delete, an empty heading/quote/list block now collapses to a paragraph like the empty-editor case, with a Before/After test plan and Closes #5835. No rush at all, just flagging it's ready whenever someone has a moment to look. Happy to rebase if anything's drifted since July.

@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks @etrepum, this is a much better shape than where I left it. I'd scoped the collapse narrowly to deleteCharacter and missed the other delete paths and the cut handler, and the collapseAtStart override is exactly the kind of contract break that would've bitten third-party block nodes quietly. Running the unwrap to a fixpoint for nested lists is the right call too. My nested test was passing by luck on that second non-nested item.

Happy with the expanded approach, and glad the repro coverage grew with it. Appreciate you taking it the rest of the way.

claude and others added 2 commits August 31, 2026 16:24
…s itself

## Description

Three review findings on the select-all-delete collapse.

**A `collapseAtStart` that removes its block left the root childless.** The
collapse was not followed by `$ensureRootHasParagraph()`, so a block node whose
`collapseAtStart` calls `this.remove()` rather than replacing itself left the
root with zero children on a forward select-all Delete -- not a usable editor
state. Backspace over the same document was fine only because the pre-existing
backward `deleteCharacter` branch runs that guard itself. The collapse helper
now runs it once, after the loop, when it actually dissolved something; that
covers all four call sites (`deleteCharacter`, `deleteLine`, `deleteWord`, and
the rich-text cut handler) in one place.

**The `collapseAtStart` opt-out was decided by the wrong thing.**
`$collapseAtStart` walks up past the top-level block into the `RootNode`, whose
`collapseAtStart` returns `true` unconditionally, so `if (!$collapseAtStart(...))
return;` could never fire on the single-child branch `$emptiedLoneBlock` has
just verified. A block that returns `false` was surviving only because the
loop's `depth >= previousDepth` progress guard stopped it -- the documented
return-value contract was doing nothing. The walk is now `$collapseBranchAtStart`,
which stops at the top-level block, so declining actually reports declined. This
is a mechanism fix: no in-tree shape changes behaviour, because the progress
guard was reaching the same outcome by accident.

**The `deleteLine` comment overstated the coverage.** On a selection spanning
more than one block `deleteLine` takes the branch above, collapses to the anchor
and deletes a single character -- so Cmd+A then Cmd+Backspace on a multi-block
document deletes nothing at all. That is pre-existing behaviour and is left
alone, but the comment now says which case it actually covers, matching the note
already in the test file.

A fourth finding -- that a document left as `quote > list > listitem` collapses
to `quote > paragraph` rather than the empty-editor state -- is **not** fixed
here, deliberately. Walking past the paragraph into the quote means calling
`QuoteNode.collapseAtStart` on block children, which merges them into a
paragraph and nests one paragraph inside another. That is a pre-existing
`QuoteNode` bug, reachable today by plain Backspace at the start of such a quote
with no select-all involved, so unwrapping the quote here would spread it rather
than fix it. The outcome is still an improvement on leaving the bullet list
behind, and it is now pinned by a test and stated in the helper's doc comment
instead of being implied away.

## Test plan

### Before

Probing the findings against the parent commit (throwaway test, deleted after):

```
PROBE A back=false -> []
PROBE A back=true  -> [["paragraph",[]]]
PROBE C back=false -> [["quote",[["paragraph",[]]]]]
PROBE D stubborn   -> [["probe_stubborn",[]]]
```

`PROBE A back=false` is the bug: no children under the root at all.

The new self-removing test, with the `$ensureRootHasParagraph()` call removed:

```
$ npx vitest run packages/lexical/src/__tests__/unit/Issue5835Repro.test.ts -t "removes itself"
AssertionError: expected [] to deeply equal [ 'paragraph' ]
- Expected
+ Received
+ []
      Tests  1 failed | 1 passed | 41 skipped (43)
```

Confirming the `QuoteNode` bug is pre-existing rather than introduced here --
plain Backspace at the start of `quote > paragraph("one")`, no select-all, run
against both this branch and an unmodified `LexicalSelection.ts`:

```
=== with this branch ===
PROBE3 backspace-at-start-of-quote -> [["paragraph",[["paragraph",["text"]]]]]
=== against unmodified upstream LexicalSelection ===
PROBE3 backspace-at-start-of-quote -> [["paragraph",[["paragraph",["text"]]]]]
```

### After

The same probes:

```
PROBE A back=false -> [["paragraph",[]]]
PROBE A back=true  -> [["paragraph",[]]]
PROBE D stubborn   -> [["probe_stubborn",[]]]
```

Full unit suite (jsdom):

```
$ npx vitest run
 Test Files  346 passed (346)
      Tests  6068 passed | 2 skipped (6070)
```

Playground e2e, Chromium, against a dev server:

```
$ npx playwright test --project=chromium \
    .../SelectAllDelete.spec.mjs .../Selection.spec.mjs .../CopyAndPaste \
    .../List.spec.mjs .../CodeBlock.spec.mjs .../Headings .../CardSlot.spec.mjs \
    .../Clear.spec.mjs .../Keyboard.spec.mjs
  13 skipped
  179 passed (7.0m)
```

Static checks:

```
$ npx tsc --noEmit -p .            # no output
$ npm run flow                     # No errors!
$ npx eslint packages/ scripts/    # no output
$ npx prettier --check "packages/**/*.{ts,tsx,mjs}"
All matched files use Prettier code style!
```

Firefox and WebKit were not exercised: this container has no matching Playwright
builds for them, so only the Chromium project was run.

Co-Authored-By: Claude Opus 5 <[email protected]>
…7f0zt' into fix/5835-select-all-delete-non-paragraph-first-block

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs some more work because the removed content doesn't match what ends up on the clipboard, normally you would expect Cmd-X then Cmd-V to be a no-op other than the changes to history. The approach should be to expand the selection before deletion, where applicable, in order to avoid that kind of quirk.

claude and others added 2 commits August 31, 2026 17:50
…efore deleting instead of repairing the block afterwards

## Description

The select-all-delete fix on this branch worked by deleting the selected text
and then dissolving whatever empty block was left behind. That is the wrong end
of the operation, and it shows on cut: `copyToClipboard` runs against the
selection the user made, but the block the collapse then destroys was never part
of it. What leaves the document and what lands on the clipboard describe
different operations, so Cmd+X followed by Cmd+V is not the no-op it should be
other than the history entry.

It also forced everything downstream of that mistake. Dissolving a block the
user did not select meant asking each block type whether and how it should
dissolve, which brought in the `collapseAtStart` delegation, a multi-pass loop
for nests that shed one level per call, a depth bound to make that loop
terminate, an `$ensureRootHasParagraph` guard for nodes that remove themselves,
and a known-bad case where a quote wrapping a list could only ever be left
holding a stray paragraph.

The range is now widened before the delete instead. When a selection covers the
whole document, `INTERNAL_$expandSelectionToWholeDocument` resets its points to
the root's own element points, so the range contains the top-level blocks rather
than only the text inside them. `removeText` then removes those blocks the way
it removes anything else and leaves the editor on a fresh empty paragraph. The
rich-text cut handler widens before the copy, so the clipboard carries exactly
what the removal takes out.

Nothing has to decide whether a heading, a nested list, a code block, a quote
wrapping a list or a third-party node should dissolve -- they are simply inside
the range the user selected -- and no node is destroyed that they did not
select. That deletes `$emptiedLoneBlock`, `$collapseBranchAtStart`,
`INTERNAL_$collapseEmptiedRootToParagraph` and their loop, and fixes the quote
case that the previous approach documented as a limitation.

The `wasCollapsed` guards stay: widening applies only to a delete that started
from a real range, so extending a collapsed caret over a word or to a line
boundary remains an ordinary delete that leaves the block alone.

Scoping is unchanged and comes from `$isBlockFullySelected(root, selection)`:
a range that stops short of either end does not cover the root, and neither does
a select-all scoped to a named slot, so neither widens. A select-all anchored in
a table cell is whole-document by design in the rich-text handler and removes
the table, which is what `LexicalCaret`'s ported table test already sets up by
hand ("the table plug-in would normally do this normalization").

`INTERNAL_$expandSelectionToWholeDocument` replaces the
`INTERNAL_$collapseEmptiedRootToParagraph` export added earlier on this branch;
neither has shipped in a release.

## Test plan

### Before

Probing the shapes the old approach could not reach, against the parent commit
(throwaway test, deleted after):

```
EXP quote>list  -> [["quote",[["paragraph",[]]]]]
```

The clipboard/removal mismatch, with the old collapse in place: the heading is
destroyed by a step that ran after the copy, not by the removal the copy
described.

### After

The same shape, and the ones the old loop needed multiple passes for, now come
out of a single `removeText` over the widened range:

```
EXP heading           afterRemoveText=[["paragraph",[]]] rootEmpty=false
EXP nested-list-only  afterRemoveText=[["paragraph",[]]] rootEmpty=false
EXP quote>list        afterRemoveText=[["paragraph",[]]] rootEmpty=false
EXP code              afterRemoveText=[["paragraph",[]]] rootEmpty=false
EXP heading+para      afterRemoveText=[["paragraph",[]]] rootEmpty=false
EXP lone-table        afterRemoveText=[["paragraph",[]]] rootEmpty=false
```

Scoping, confirming a widened range is not reachable where it must not be:

```
EXP2 slot-anchored coversRoot          = false
EXP2 partial-from-offset-1 coversRoot  = false
EXP2 first-block-only coversRoot       = false
```

Full unit suite (jsdom):

```
$ npx vitest run
 Test Files  346 passed (346)
      Tests  6071 passed | 2 skipped (6073)
```

Playground e2e, Chromium, against a dev server -- the delete, clipboard, slot
and table specs, since widening changes what a select-all delete removes:

```
$ npx playwright test --project=chromium \
    .../SelectAllDelete.spec.mjs .../Selection.spec.mjs .../CopyAndPaste \
    .../List.spec.mjs .../CodeBlock.spec.mjs .../Headings .../CardSlot.spec.mjs \
    .../Clear.spec.mjs .../Tables.spec.mjs .../Keyboard.spec.mjs
  14 skipped
  267 passed (8.3m)
```

Static checks:

```
$ npx tsc --noEmit -p .            # no output
$ npm run flow                     # No errors!
$ npx eslint packages/ scripts/    # no output
$ npx prettier --check "packages/**/*.{ts,tsx,mjs}"
All matched files use Prettier code style!
```

Note on the cut round-trip tests added here: they pass against the previous
approach too, because the HTML serializer already reconstructs block ancestry
for a text-point selection, so paste happened to restore the heading anyway.
Widening before the copy is what makes that a property of the code rather than
of the serializer, but it is not a case that can be shown failing today.

Firefox and WebKit were not exercised: this container has no matching Playwright
builds for them, so only the Chromium project was run.

Co-Authored-By: Claude Opus 5 <[email protected]>
…7f0zt' into fix/5835-select-all-delete-non-paragraph-first-block
@etrepum
etrepum added this pull request to the merge queue Aug 31, 2026
Merged via the queue into meta:main with commit 846f683 Aug 31, 2026
42 checks passed
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks for taking this the whole way, @etrepum. The cut round-trip catch was the right call. Cmd-X/Cmd-V staying a no-op matters, and expanding the selection before deletion is a cleaner model than collapsing after the fact. Good to watch the shape it landed in, and glad #5835 is finally closed.

@etrepum etrepum mentioned this pull request Sep 2, 2026
@gunjanjaswal
gunjanjaswal deleted the fix/5835-select-all-delete-non-paragraph-first-block branch September 16, 2026 10:29
zurfyx added a commit that referenced this pull request Oct 15, 2026
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page

## Description

Depends on the changesets tooling in #9357.

Past versions in CHANGELOG.md only list commits, so someone upgrading from
an older version cannot find what broke, or how to migrate, without reading
every GitHub release. Future versions get curated sections from changesets;
this gives v0.23.0 to v0.52.0 the same sections.

- Every version from v0.23.0 to v0.52.0 now starts with `### Breaking
  changes` (35 entries), `### Behavior changes` (43) and `### Deprecations`
  (29), each with packages and a PR link. The existing lines are kept,
  unchanged, under `### All changes` (the diff only adds lines).
- Rule, stated in the preamble: a breaking change needs a code change (an
  API removed or renamed, a type that no longer checks, a call that now
  throws) and has `Detect:` and `Migration:`. A behavior change keeps
  building but behaves or renders differently and has `Verify:`. The entries
  come from a verified inventory of those releases, which marked each change
  as manual, mechanical, or runtime-only ("no type or build error points at
  it"). Runtime-only entries are behavior changes, except #7341 (now throws)
  and #8603 (a signature change), which stay breaking.
- v0.50.0: the items its release notes list as "Behavior Changes to Watch"
  (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes;
  the listener return-type tightening (#8990), the new invariants (#6483)
  and the two items the release called breaking (#8938, #8995) stay
  breaking. Checked against the v0.50.0 release notes.
- Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin`
  (#8199; present in the v0.41.0 tag, absent in v0.42.0).
- Deprecations come from a pass over every `@deprecated` tag added between
  consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag
  and attributed with `git log -S`. Each has `Replacement:` and `Removal:`:
  the version that removed it, "no earlier than v0.53.0" for the ones #9316
  removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only
  moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated
  earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`),
  and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed.
- Entries that mixed a breaking change and a deprecation are split with no
  double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated
  aliases, so they are listed under Deprecations alone.
- `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade
  all packages together, read CHANGELOG.md between your version and the
  target (also at `node_modules/lexical/CHANGELOG.md`) or print that range,
  and a copy-paste `AGENTS.md` snippet that points coding agents at the
  installed changelog. Nothing is installed automatically.
- The repository CHANGELOG.md test checks every backfilled entry: `Detect:`
  and `Migration:` on breaking changes, `Verify:` on behavior changes,
  `Replacement:` and a valid `Removal:` on deprecations, a PR link on all.

## Test plan

### Before

```
$ pnpm run changelog:range -- --from 0.49.0 --breaking
Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full.
No breaking changes, behavior changes or deprecations recorded after 0.49.0.
```

### After

```
$ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md
1412	0	CHANGELOG.md

$ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### '
## v0.50.0 (2026-09-02)
### Breaking changes
### Behavior changes
### Deprecations
## v0.51.0 (2026-09-17)
### Breaking changes
### Deprecations
## v0.52.0 (2026-09-27)
### Breaking changes
### Behavior changes
### Deprecations

$ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])]

$ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts
      Tests  63 passed (63)

$ pnpm -C packages/lexical-website run docusaurus build
[SUCCESS] Generated static files in "build".
```
zurfyx added a commit that referenced this pull request Oct 15, 2026
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page

## Description

Depends on the changesets tooling in #9357.

Past versions in CHANGELOG.md only list commits, so someone upgrading from
an older version cannot find what broke, or how to migrate, without reading
every GitHub release. Future versions get curated sections from changesets;
this gives v0.23.0 to v0.52.0 the same sections.

- Every version from v0.23.0 to v0.52.0 now starts with `### Breaking
  changes` (35 entries), `### Behavior changes` (43) and `### Deprecations`
  (29), each with packages and a PR link. The existing lines are kept,
  unchanged, under `### All changes` (the diff only adds lines).
- Rule, stated in the preamble: a breaking change needs a code change (an
  API removed or renamed, a type that no longer checks, a call that now
  throws) and has `Detect:` and `Migration:`. A behavior change keeps
  building but behaves or renders differently and has `Verify:`. The entries
  come from a verified inventory of those releases, which marked each change
  as manual, mechanical, or runtime-only ("no type or build error points at
  it"). Runtime-only entries are behavior changes, except #7341 (now throws)
  and #8603 (a signature change), which stay breaking.
- v0.50.0: the items its release notes list as "Behavior Changes to Watch"
  (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes;
  the listener return-type tightening (#8990), the new invariants (#6483)
  and the two items the release called breaking (#8938, #8995) stay
  breaking. Checked against the v0.50.0 release notes.
- Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin`
  (#8199; present in the v0.41.0 tag, absent in v0.42.0).
- Deprecations come from a pass over every `@deprecated` tag added between
  consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag
  and attributed with `git log -S`. Each has `Replacement:` and `Removal:`:
  the version that removed it, "no earlier than v0.53.0" for the ones #9316
  removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only
  moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated
  earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`),
  and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed.
- Entries that mixed a breaking change and a deprecation are split with no
  double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated
  aliases, so they are listed under Deprecations alone.
- `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade
  all packages together, read CHANGELOG.md between your version and the
  target (also at `node_modules/lexical/CHANGELOG.md`) or print that range,
  and a copy-paste `AGENTS.md` snippet that points coding agents at the
  installed changelog. Nothing is installed automatically.
- The repository CHANGELOG.md test checks every backfilled entry: `Detect:`
  and `Migration:` on breaking changes, `Verify:` on behavior changes,
  `Replacement:` and a valid `Removal:` on deprecations, a PR link on all.

## Test plan

### Before

```
$ pnpm run changelog:range -- --from 0.49.0 --breaking
Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full.
No breaking changes, behavior changes or deprecations recorded after 0.49.0.
```

### After

```
$ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md
1412	0	CHANGELOG.md

$ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### '
## v0.50.0 (2026-09-02)
### Breaking changes
### Behavior changes
### Deprecations
## v0.51.0 (2026-09-17)
### Breaking changes
### Deprecations
## v0.52.0 (2026-09-27)
### Breaking changes
### Behavior changes
### Deprecations

$ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])]

$ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts
      Tests  63 passed (63)

$ pnpm -C packages/lexical-website run docusaurus build
[SUCCESS] Generated static files in "build".
```
zurfyx added a commit that referenced this pull request Oct 28, 2026
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page

Depends on the changesets tooling in #9357.

Past versions in CHANGELOG.md only list commits, so someone upgrading from
an older version cannot find what broke, or how to migrate, without reading
every GitHub release. Future versions get curated sections from changesets;
this gives v0.23.0 to v0.52.0 the same sections.

- Every version from v0.23.0 to v0.52.0 now starts with `### Breaking
  changes` (35 entries), `### Behavior changes` (43) and `### Deprecations`
  (29), each with packages and a PR link. The existing lines are kept,
  unchanged, under `### All changes` (the diff only adds lines).
- Rule, stated in the preamble: a breaking change needs a code change (an
  API removed or renamed, a type that no longer checks, a call that now
  throws) and has `Detect:` and `Migration:`. A behavior change keeps
  building but behaves or renders differently and has `Verify:`. The entries
  come from a verified inventory of those releases, which marked each change
  as manual, mechanical, or runtime-only ("no type or build error points at
  it"). Runtime-only entries are behavior changes, except #7341 (now throws)
  and #8603 (a signature change), which stay breaking.
- v0.50.0: the items its release notes list as "Behavior Changes to Watch"
  (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes;
  the listener return-type tightening (#8990), the new invariants (#6483)
  and the two items the release called breaking (#8938, #8995) stay
  breaking. Checked against the v0.50.0 release notes.
- Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin`
  (#8199; present in the v0.41.0 tag, absent in v0.42.0).
- Deprecations come from a pass over every `@deprecated` tag added between
  consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag
  and attributed with `git log -S`. Each has `Replacement:` and `Removal:`:
  the version that removed it, "no earlier than v0.53.0" for the ones #9316
  removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only
  moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated
  earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`),
  and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed.
- Entries that mixed a breaking change and a deprecation are split with no
  double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated
  aliases, so they are listed under Deprecations alone.
- `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade
  all packages together, read CHANGELOG.md between your version and the
  target (also at `node_modules/lexical/CHANGELOG.md`) or print that range,
  and a copy-paste `AGENTS.md` snippet that points coding agents at the
  installed changelog. Nothing is installed automatically.
- The repository CHANGELOG.md test checks every backfilled entry: `Detect:`
  and `Migration:` on breaking changes, `Verify:` on behavior changes,
  `Replacement:` and a valid `Removal:` on deprecations, a PR link on all.

```
$ pnpm run changelog:range -- --from 0.49.0 --breaking
Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full.
No breaking changes, behavior changes or deprecations recorded after 0.49.0.
```

```
$ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md
1412	0	CHANGELOG.md

$ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### '

$ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])]

$ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts
      Tests  63 passed (63)

$ pnpm -C packages/lexical-website run docusaurus build
[SUCCESS] Generated static files in "build".
```

This branch was successfully deployed

2 active deployments
Preview – lexical — c6967a3a Deployed Aug 31, 2026 by vercel[bot]
Preview – lexical-playground — c6967a3a Deployed Aug 31, 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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: select all + delete should remove all blocks

3 participants