Skip to content

[lexical][lexical-html] Breaking Change: honor $createDOM overrides in default DOM export - #9231

Merged
etrepum merged 2 commits into
meta:mainfrom
etrepum:fix/export-dom-create-dom
Sep 25, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
etrepum:fix/export-dom-create-dom

Conversation

@etrepum

@etrepum etrepum commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Breaking Change

The default LexicalNode.exportDOM fallback now calls through $createDOM instead of directly to this.createDOM. This new behavior is only observable when using DOMRenderExtension to override $createDOM, because the default $createDOM is this.createDOM.

Description

The default LexicalNode.exportDOM called this.createDOM directly, so DOMRenderExtension $createDOM overrides would affect reconciliation but be missing from exported HTML, as identified in #9224. Rather than document the quirk, this change makes it consistent.

Resolve the editor DOM render config and call its $createDOM hook instead. This preserves the default createDOM fallback and lets nodes that inherit exportDOM or call super.exportDOM(editor), including TextNode and ParagraphNode, use the configured creation chain before applying their export-specific formatting.

Closes #9224

Test plan

Add regression coverage for paragraph, line break, plain text, and bold text exports, with and without an attached editor root. Clarify the documentation about which hooks participate in export.

…errides in default DOM export

## Description

The default LexicalNode.exportDOM calls this.createDOM directly, so DOMRenderExtension $createDOM overrides affect reconciliation but are missing from exported HTML, as identified in meta#9224.

Resolve the editor DOM render config and call its $createDOM hook instead. This preserves the default createDOM fallback and lets nodes that inherit exportDOM or call super.exportDOM(editor), including TextNode and ParagraphNode, use the configured creation chain before applying their export-specific formatting.

Add regression coverage for paragraph, line break, plain text, and bold text exports, with and without an attached editor root. Clarify the documentation about which hooks participate in export.

## Test plan

### Before

With the regression tests added to the unchanged implementation:

```text
$ npm run test-unit -- packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts
FAIL  |unit| packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts > DOMRenderExtension > $createDOM overrides apply to HTML export (with root: false)
FAIL  |unit| packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts > DOMRenderExtension > $createDOM overrides apply to HTML export (with root: true)

Test Files  1 failed (1)
     Tests  2 failed | 10 passed (12)
```

### After

```text
$ npm run test-unit -- packages/lexical-html/src/__tests__/unit packages/lexical/src/__tests__/unit/LexicalNode.test.ts packages/lexical/src/__tests__/unit/LexicalTextNode.test.ts packages/lexical/src/__tests__/unit/LexicalParagraphNode.test.ts packages/lexical/src/__tests__/unit/LexicalLineBreakNode.test.ts
Test Files  15 passed (15)
     Tests  261 passed (261)

$ npm run test-unit -- packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts
Test Files  1 passed (1)
     Tests  12 passed (12)

$ node_modules/.bin/prettier --check packages/lexical/src/LexicalNode.ts packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts
Checking formatting...
All matched files use Prettier code style!

$ node_modules/.bin/eslint packages/lexical/src/LexicalNode.ts packages/lexical-html/src/__tests__/unit/DOMRenderExtension.test.ts
```

Tests ran on Linux with jsdom; the browser and operating-system matrix was not run.

The full test TypeScript check reports the same seven benchmark errors on the unchanged base and patched tree:

```text
$ node_modules/.bin/tsc --noEmit -p tsconfig.test.json
packages/lexical/src/__bench__/dom/editorCycle.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(136,15): error TS2740: Type 'LexicalNode' is missing the following properties from type 'ParagraphNode': extractWithChild, insertNewAfter, collapseAtStart, __first, and 57 more.
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(221,16): error TS7006: Parameter 'task' implicitly has an 'any' type.
packages/lexical/src/__bench__/getWritable.bench.ts(9,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/nodeMap.bench.ts(9,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/serialization.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
```
@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 11:17pm UTC
lexical-playground Ready Ready Preview Sep 24, 2026 11:17pm 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 the extended-tests Run extended e2e tests on a PR label Sep 24, 2026
@etrepum
etrepum marked this pull request as ready for review September 24, 2026 23:09
@etrepum etrepum changed the title [lexical][lexical-html] Bug Fix: honor $createDOM overrides in default DOM export [lexical][lexical-html] Breaking Change: honor $createDOM overrides in default DOM export Sep 24, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 25, 2026
Merged via the queue into meta:main with commit e73055d Sep 25, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026
Om-singhaI added a commit to Om-singhaI/lexical that referenced this pull request Sep 28, 2026
…pers out of exported HTML

## Description

main's meta#9231 routes exportDOM through the render overrides. The default LexicalNode.exportDOM now builds its element with the editor's $createDOM hook, and LineBreakNode has no exportDOM of its own. So the $createDOM override in CodeLineNumbersExtension ran on export too. Exported HTML and the clipboard got <span data-lexical-code-line-break><br></span> for every line break in a numbered code block, mounted or headless. A trailing line break also lost its managed <br>, because the exporter only adds one when the last child is a <br>.

So the LineBreakNode $createDOM override now returns the plain <br> while RenderContextExport is set, which is how the DOM render docs say to tell an export from the editor render. The check sits in the override that adds the wrapper, so it's on exactly when the wrapper is, in both modes. An $exportDOM override that unwraps the result would also hide the wrapper, but it would drop whatever a LineBreakNode or wildcard $createDOM override composed after this one did to it. With the check, those overrides get the <br> itself, so their changes reach the export. CodeNode's own exportDOM builds its <pre> directly, so it never had the problem and isn't changed. The <pre> still gets data-lexical-code-word-wrap.

The doc comment on CodeLineNumbersExtension and the README said export doesn't use the render pipeline. They now say what actually happens.

In CodeLineNumbers.test.ts, an HTML export block replaces the test "never reaches exported HTML, mounted or not". For both modes, with word wrap off and on, it checks that $generateHtmlFromNodes and a copy of the whole document give exactly the HTML of an editor without the extension, mounted and headless. Two more tests add a LineBreakNode override and a wildcard override after the extension and check that the export and the copy still match an editor that has the same override but no extension. Another test pastes a copied block into a new editor and checks that it keeps all its lines and word wrap. CodeBlockWordWrap.spec.mjs now checks that the copy made with wrap on has no line number markup and matches the copy made before it, apart from the word wrap attribute.

## Test plan

### Before

The new tests with CodeLineNumbers.ts from the parent commit:

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > numbering every code block > exports and copies the same HTML as without the extension, mounted or not (word wrap false)
AssertionError: expected '<pre spellcheck="false" data-language…' to be '<pre spellcheck="false" data-language…' // Object.is equality
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><span data-lexical-code-line-break="true"><br></span><span data-lexical-code-line-break="true"><br></span><span style="white-space: pre-wrap;">b</span><span data-lexical-code-line-break="true"><br></span></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  5 failed | 37 passed (42)

The five that fail are the three cases where the block is numbered and the two with a later override. On the parent commit itself, the old export test fails the same way:

       × never reaches exported HTML, mounted or not 7ms
AssertionError: expected '<pre spellcheck="false" data-language…' not to contain 'data-lexical-code-line-break'
      Tests  1 failed | 35 passed (36)

The e2e spec with CodeLineNumbers.ts from the parent commit:

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

    Error: expect(received).not.toContain(expected) // indexOf
    Expected substring: not "data-lexical-code-line"
  2 failed

With an $exportDOM override that unwraps the wrapper instead, only the two tests with a later override fail, because the mark on the wrapper is dropped:

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > export keeps what a later LineBreakNode override does to the <br>
Expected: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br data-mark="true"><br data-mark="true"><span style="white-space: pre-wrap;">b</span><br data-mark="true"><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br><br><span style="white-space: pre-wrap;">b</span><br><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  2 failed | 40 passed (42)

### After

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 Test Files  1 passed (1)
      Tests  42 passed (42)

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

  2 passed

The same with firefox and webkit. pnpm run tsc and pnpm run flow pass, and prettier and eslint are clean on the changed files. All of this ran headless on macOS.
AlessioGr added a commit to payloadcms/payload that referenced this pull request Sep 30, 2026
…18397)

_Written with AI_

Upgrades `lexical` and every installed `@lexical/*` package from
`0.50.0` to `0.52.0` for Payload 4.x (`main`), and pinned `tsx`
dependencies from `4.22.4` to `4.23.15`. Removes the native-loader
workaround no longer needed with the new tsx version.

Also fixes duplicate image uploads triggered by repeated node transforms
in Lexical 0.52. CI fixes update the keyboard-navigation expectation and
correct an existing auth-test parameter error that blocked integration
tests.

Fixes #17757

3.x counterpart: #18398.

## Why this fixes the CLI failure

With Payload 3.90.1 on Node 22.22.0, importing a config that included
`lexicalEditor()` could leave CLI startup pending before the config or
target script was evaluated. The process then exited 0 with no output
and left a pending PostgreSQL migration unapplied. Previously, Payload
started the CLI with `void start()`, and an unresolved promise alone
does not keep Node's event loop alive.

Lexical 0.50's Node entry points select their build with top-level
`await import(...)`, which is probably what caused it. Lexical has
shipped ESM-only packages since **0.51**, using static imports instead
of those asynchronous Node wrappers. Upgrading to 0.52 fixes this issue.

Also removes the `module.registerHooks = undefined` workaround for
#16949. tsx 4.23.15 [excludes bare built-ins from namespace
inheritance](privatenumber/tsx@38e1588),
following its [Node 24 `tsImport` bridge
fix](privatenumber/tsx@6e5236b).

## CLI exit codes

CLI startup is now awaited at the top level in all three loader paths:
tsx, SWC, and disabled transpilation. If an import never settles and
Node runs out of work, Node reports an unsettled top-level await and
exits 13. Successful commands still exit 0, and command-specific failure
codes are preserved.

## Breaking changes

Rich-text data keeps its existing format. No database migration is
needed. Payload's built-in features have been updated, but your own
TypeScript code or custom features may need changes:

- **Generic types:** `SerializedEditorState<T>`,
`SerializedElementNode<T>`, and `SerializedRootNode<T>` no longer accept
`<T>`. Remove it if the base node type is enough, or use Payload's
`TypedEditorState<T>` for documents with your own node types. Without
`<T>`, children are still `SerializedLexicalNode[]`.
- **Export types:** `ReturnType<Node['exportJSON']>` can now make fields
such as `version` and `url` optional. Use the node's explicit serialized
type, such as `SerializedLinkNode`, when you need the full format.
Normal `node.exportJSON()` calls still return full JSON.
- **Selection listeners:** `SELECTION_CHANGE_COMMAND` now fires before
the DOM is updated. If your custom listener reads the DOM, defer that
work with `$onUpdate(() => editor.read('latest', callback))`.
- **Saved node references:** If you keep a node reference across an
editor update, call `node.getLatest().exportJSON()` to export its
current values.

The type changes also affect imports through
`@payloadcms/richtext-lexical/lexical` and its subpaths. Payload's
`TypedEditorState<T>` and its own serialized node types keep their
generic APIs for this upgrade.

Keep importing Lexical through Payload's re-exports; do not install a
separate Lexical version. See the [custom feature
documentation](https://payloadcms.com/docs/rich-text/custom-features).
The table below also lists removed APIs that may affect custom features.
`LexicalComposer` is deprecated but still available.

## Breaking changes and Payload migrations

Reviewed
[0.51.0](https://github.com/facebook/lexical/releases/tag/v0.51.0) and
[0.52.0](https://github.com/facebook/lexical/releases/tag/v0.52.0),
including the serialization declarations. **Yes** means Payload code
needed adaptation; **No** means no Payload migration was required.

| Release | Breaking change | Required migration in Payload | Changes
made |
| ------- | --------------- | ----------------------------- |
------------ |
| 0.51 | [npm packages are ESM
only](meta/lexical#9127); older CommonJS
consumers must use dynamic imports. | No | Payload already uses ESM.
This removes the asynchronous Lexical wrapper involved in the CLI
reproducer. |
| 0.51 | [Serialization schemas and compact
export](meta/lexical#8602) add `exportJSON`
overloads and remove the `SerializedEditorState`,
`SerializedElementNode`, and `SerializedRootNode` generics. `ReturnType`
can now infer compact, partial JSON. | Yes | Infer the full-format
overload for node hooks, validation and population while preserving
custom nodes' literal `type` discriminants. Update `hasText` to the
non-generic editor-state type. |
| 0.51 | [`exportJSON` can serialize a retained instance without calling
`getLatest()`](meta/lexical#8602). | No |
Audited Payload's clipboard and Markdown call sites: they serialize
nodes obtained from the current selection/tree, without an intervening
mutation. Custom callers holding stale references should use
`node.getLatest().exportJSON()`. |
| 0.51 | [Deprecated Prism re-exports are removed from
`@lexical/code`](meta/lexical#9141). | No |
Payload does not consume the removed exports. |
| 0.52 | [`SELECTION_CHANGE_COMMAND` runs before DOM
reconciliation](meta/lexical#9219),
including node and table selections. | Yes | Defer link popup, inline
toolbar and decorator DOM work with `$onUpdate` and
`editor.read('latest', ...)`. Keep nested decorator updates with their
own editor. The table menu already defers DOM reads. |
| 0.52 | [Default HTML export honors `DOMRenderExtension` `$createDOM`
overrides](meta/lexical#9231). | No |
Payload does not configure these extension overrides; existing converter
tests pass. |
| 0.52 | [`LexicalNode.getCommonAncestor` is
removed](meta/lexical#9238). | No | No
Payload call sites. Custom consumers can use `$getCommonAncestor`,
accounting for its different handling of non-element nodes. |

React package entry points were compared against 0.50.0; no Payload
proxy exports need adding or removing.

## Previous Lexical upgrades

- [#18149](#18149) — 0.48.0 →
0.50.0
- [#17554](#17554) — 0.45.0 →
0.48.0
- [#17064](#17064) — 0.41.0 →
0.45.0
Om-singhaI added a commit to Om-singhaI/lexical that referenced this pull request Sep 30, 2026
…pers out of exported HTML

## Description

main's meta#9231 routes exportDOM through the render overrides. The default LexicalNode.exportDOM now builds its element with the editor's $createDOM hook, and LineBreakNode has no exportDOM of its own. So the $createDOM override in CodeLineNumbersExtension ran on export too. Exported HTML and the clipboard got <span data-lexical-code-line-break><br></span> for every line break in a numbered code block, mounted or headless. A trailing line break also lost its managed <br>, because the exporter only adds one when the last child is a <br>.

So the LineBreakNode $createDOM override now returns the plain <br> while RenderContextExport is set, which is how the DOM render docs say to tell an export from the editor render. The check sits in the override that adds the wrapper, so it's on exactly when the wrapper is, in both modes. An $exportDOM override that unwraps the result would also hide the wrapper, but it would drop whatever a LineBreakNode or wildcard $createDOM override composed after this one did to it. With the check, those overrides get the <br> itself, so their changes reach the export. CodeNode's own exportDOM builds its <pre> directly, so it never had the problem and isn't changed. The <pre> still gets data-lexical-code-word-wrap.

The doc comment on CodeLineNumbersExtension and the README said export doesn't use the render pipeline. They now say what actually happens.

In CodeLineNumbers.test.ts, an HTML export block replaces the test "never reaches exported HTML, mounted or not". For both modes, with word wrap off and on, it checks that $generateHtmlFromNodes and a copy of the whole document give exactly the HTML of an editor without the extension, mounted and headless. Two more tests add a LineBreakNode override and a wildcard override after the extension and check that the export and the copy still match an editor that has the same override but no extension. Another test pastes a copied block into a new editor and checks that it keeps all its lines and word wrap. CodeBlockWordWrap.spec.mjs now checks that the copy made with wrap on has no line number markup and matches the copy made before it, apart from the word wrap attribute.

## Test plan

### Before

The new tests with CodeLineNumbers.ts from the parent commit:

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > numbering every code block > exports and copies the same HTML as without the extension, mounted or not (word wrap false)
AssertionError: expected '<pre spellcheck="false" data-language…' to be '<pre spellcheck="false" data-language…' // Object.is equality
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><span data-lexical-code-line-break="true"><br></span><span data-lexical-code-line-break="true"><br></span><span style="white-space: pre-wrap;">b</span><span data-lexical-code-line-break="true"><br></span></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  5 failed | 37 passed (42)

The five that fail are the three cases where the block is numbered and the two with a later override. On the parent commit itself, the old export test fails the same way:

       × never reaches exported HTML, mounted or not 7ms
AssertionError: expected '<pre spellcheck="false" data-language…' not to contain 'data-lexical-code-line-break'
      Tests  1 failed | 35 passed (36)

The e2e spec with CodeLineNumbers.ts from the parent commit:

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

    Error: expect(received).not.toContain(expected) // indexOf
    Expected substring: not "data-lexical-code-line"
  2 failed

With an $exportDOM override that unwraps the wrapper instead, only the two tests with a later override fail, because the mark on the wrapper is dropped:

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > export keeps what a later LineBreakNode override does to the <br>
Expected: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br data-mark="true"><br data-mark="true"><span style="white-space: pre-wrap;">b</span><br data-mark="true"><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br><br><span style="white-space: pre-wrap;">b</span><br><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  2 failed | 40 passed (42)

### After

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 Test Files  1 passed (1)
      Tests  42 passed (42)

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

  2 passed

The same with firefox and webkit. pnpm run tsc and pnpm run flow pass, and prettier and eslint are clean on the changed files. All of this ran headless on macOS.
Om-singhaI added a commit to Om-singhaI/lexical that referenced this pull request Oct 5, 2026
…pers out of exported HTML

## Description

main's meta#9231 routes exportDOM through the render overrides. The default LexicalNode.exportDOM now builds its element with the editor's $createDOM hook, and LineBreakNode has no exportDOM of its own. So the $createDOM override in CodeLineNumbersExtension ran on export too. Exported HTML and the clipboard got <span data-lexical-code-line-break><br></span> for every line break in a numbered code block, mounted or headless. A trailing line break also lost its managed <br>, because the exporter only adds one when the last child is a <br>.

So the LineBreakNode $createDOM override now returns the plain <br> while RenderContextExport is set, which is how the DOM render docs say to tell an export from the editor render. The check sits in the override that adds the wrapper, so it's on exactly when the wrapper is, in both modes. An $exportDOM override that unwraps the result would also hide the wrapper, but it would drop whatever a LineBreakNode or wildcard $createDOM override composed after this one did to it. With the check, those overrides get the <br> itself, so their changes reach the export. CodeNode's own exportDOM builds its <pre> directly, so it never had the problem and isn't changed. The <pre> still gets data-lexical-code-word-wrap.

The doc comment on CodeLineNumbersExtension and the README said export doesn't use the render pipeline. They now say what actually happens.

In CodeLineNumbers.test.ts, an HTML export block replaces the test "never reaches exported HTML, mounted or not". For both modes, with word wrap off and on, it checks that $generateHtmlFromNodes and a copy of the whole document give exactly the HTML of an editor without the extension, mounted and headless. Two more tests add a LineBreakNode override and a wildcard override after the extension and check that the export and the copy still match an editor that has the same override but no extension. Another test pastes a copied block into a new editor and checks that it keeps all its lines and word wrap. CodeBlockWordWrap.spec.mjs now checks that the copy made with wrap on has no line number markup and matches the copy made before it, apart from the word wrap attribute.

## Test plan

### Before

The new tests with CodeLineNumbers.ts from the parent commit:

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > numbering every code block > exports and copies the same HTML as without the extension, mounted or not (word wrap false)
AssertionError: expected '<pre spellcheck="false" data-language…' to be '<pre spellcheck="false" data-language…' // Object.is equality
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><span data-lexical-code-line-break="true"><br></span><span data-lexical-code-line-break="true"><br></span><span style="white-space: pre-wrap;">b</span><span data-lexical-code-line-break="true"><br></span></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  5 failed | 37 passed (42)

The five that fail are the three cases where the block is numbered and the two with a later override. On the parent commit itself, the old export test fails the same way:

       × never reaches exported HTML, mounted or not 7ms
AssertionError: expected '<pre spellcheck="false" data-language…' not to contain 'data-lexical-code-line-break'
      Tests  1 failed | 35 passed (36)

The e2e spec with CodeLineNumbers.ts from the parent commit:

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

    Error: expect(received).not.toContain(expected) // indexOf
    Expected substring: not "data-lexical-code-line"
  2 failed

With an $exportDOM override that unwraps the wrapper instead, only the two tests with a later override fail, because the mark on the wrapper is dropped:

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > export keeps what a later LineBreakNode override does to the <br>
Expected: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br data-mark="true"><br data-mark="true"><span style="white-space: pre-wrap;">b</span><br data-mark="true"><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br><br><span style="white-space: pre-wrap;">b</span><br><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  2 failed | 40 passed (42)

### After

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 Test Files  1 passed (1)
      Tests  42 passed (42)

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

  2 passed

The same with firefox and webkit. pnpm run tsc and pnpm run flow pass, and prettier and eslint are clean on the changed files. All of this ran headless on macOS.
Om-singhaI added a commit to Om-singhaI/lexical that referenced this pull request Oct 6, 2026
…pers out of exported HTML

## Description

main's meta#9231 routes exportDOM through the render overrides. The default LexicalNode.exportDOM now builds its element with the editor's $createDOM hook, and LineBreakNode has no exportDOM of its own. So the $createDOM override in CodeLineNumbersExtension ran on export too. Exported HTML and the clipboard got <span data-lexical-code-line-break><br></span> for every line break in a numbered code block, mounted or headless. A trailing line break also lost its managed <br>, because the exporter only adds one when the last child is a <br>.

So the LineBreakNode $createDOM override now returns the plain <br> while RenderContextExport is set, which is how the DOM render docs say to tell an export from the editor render. The check sits in the override that adds the wrapper, so it's on exactly when the wrapper is, in both modes. An $exportDOM override that unwraps the result would also hide the wrapper, but it would drop whatever a LineBreakNode or wildcard $createDOM override composed after this one did to it. With the check, those overrides get the <br> itself, so their changes reach the export. CodeNode's own exportDOM builds its <pre> directly, so it never had the problem and isn't changed. The <pre> still gets data-lexical-code-word-wrap.

The doc comment on CodeLineNumbersExtension and the README said export doesn't use the render pipeline. They now say what actually happens.

In CodeLineNumbers.test.ts, an HTML export block replaces the test "never reaches exported HTML, mounted or not". For both modes, with word wrap off and on, it checks that $generateHtmlFromNodes and a copy of the whole document give exactly the HTML of an editor without the extension, mounted and headless. Two more tests add a LineBreakNode override and a wildcard override after the extension and check that the export and the copy still match an editor that has the same override but no extension. Another test pastes a copied block into a new editor and checks that it keeps all its lines and word wrap. CodeBlockWordWrap.spec.mjs now checks that the copy made with wrap on has no line number markup and matches the copy made before it, apart from the word wrap attribute.

## Test plan

### Before

The new tests with CodeLineNumbers.ts from the parent commit:

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > numbering every code block > exports and copies the same HTML as without the extension, mounted or not (word wrap false)
AssertionError: expected '<pre spellcheck="false" data-language…' to be '<pre spellcheck="false" data-language…' // Object.is equality
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><span data-lexical-code-line-break="true"><br></span><span data-lexical-code-line-break="true"><br></span><span style="white-space: pre-wrap;">b</span><span data-lexical-code-line-break="true"><br></span></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  5 failed | 37 passed (42)

The five that fail are the three cases where the block is numbered and the two with a later override. On the parent commit itself, the old export test fails the same way:

       × never reaches exported HTML, mounted or not 7ms
AssertionError: expected '<pre spellcheck="false" data-language…' not to contain 'data-lexical-code-line-break'
      Tests  1 failed | 35 passed (36)

The e2e spec with CodeLineNumbers.ts from the parent commit:

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

    Error: expect(received).not.toContain(expected) // indexOf
    Expected substring: not "data-lexical-code-line"
  2 failed

With an $exportDOM override that unwraps the wrapper instead, only the two tests with a later override fail, because the mark on the wrapper is dropped:

 FAIL  |unit| packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts > CodeLineNumbersExtension > HTML export > export keeps what a later LineBreakNode override does to the <br>
Expected: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br data-mark="true"><br data-mark="true"><span style="white-space: pre-wrap;">b</span><br data-mark="true"><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
Received: "<pre spellcheck="false" data-language="javascript"><span style="white-space: pre-wrap;">a</span><br><br><span style="white-space: pre-wrap;">b</span><br><br data-lexical-managed-linebreak="true"></pre><p><span style="white-space: pre-wrap;">z</span></p>"
      Tests  2 failed | 40 passed (42)

### After

pnpm vitest run --project unit packages/lexical-code-core/src/__tests__/unit/CodeLineNumbers.test.ts

 Test Files  1 passed (1)
      Tests  42 passed (42)

E2E_BROWSER=chromium pnpm exec playwright test --project=chromium packages/lexical-playground/__tests__/e2e/CodeBlockWordWrap.spec.mjs

  2 passed

The same with firefox and webkit. pnpm run tsc and pnpm run flow pass, and prettier and eslint are clean on the changed files. All of this ran headless on macOS.
zurfyx added a commit that referenced this pull request Oct 15, 2026
…at release, ship it in lexical, add a range view

## Description

`scripts/npm/update-changelog.mjs` wrote each release's CHANGELOG.md block
from `git log --oneline LATEST_RELEASE...HEAD~1`. It stripped every
character outside `[a-zA-Z0-9()\n \-,.#]`, so `[lexical][lexical-html]
Breaking Change:` became `lexicallexical-html Breaking Change`, `$insertList`
became `insertList`, and `Find & Replace` became `Find  Replace`. The
`HEAD~1` range dropped the newest commit, and the block had no categories,
links or migration notes.

This replaces it with the changesets added in the previous commit:

- `pnpm run update-changelog` (still called from `postversion` on the
  `latest` channel) now runs `scripts/changesets/release.mjs`: it validates
  the pending changesets, prepends a `## vX.Y.Z (date)` block (the heading
  shape Renovate and Dependabot slice on) with `### Breaking changes`,
  `### Deprecations`, `### Features`, `### Fixes`, `### Performance`,
  `### Documentation`, `### Other` (the `chore` category) and
  `### Contributors`, empty sections omitted, and deletes the consumed
  changesets. Each bullet is `**packages**: summary (#PR link)` with the
  entry's details, including `Migration:` code, reproduced verbatim. The PR
  number comes from the squash-merge subject of the commit that added the
  changeset; contributors from `@handle` lines, else that commit's author.
  Text is never filtered and nothing is dropped, since the input is the set
  of pending files rather than a git range.
- The release still picks its own version (Lexical does not run
  `changeset version`), but `increment-version` refuses a `latest` patch
  while a `[breaking]` changeset is pending, and `update-changelog` repeats
  the check. Prereleases (nightly, next, dev) leave changesets pending.
- `pnpm run changelog` previews the next block instead of printing `git log`.
- `pnpm run changelog:range -- --from X [--to Y] [--breaking] [--json]`
  prints every entry in (X, Y], oldest first, optionally only breaking
  changes and deprecations, optionally as JSON for tools and coding agents.
- `pnpm run release-notes -- --version X` prints a version's block for the
  GitHub release, under the hand-written intro.
- `lexical` now ships CHANGELOG.md: `prepare-release` copies the root file
  into `packages/lexical/` (gitignored) and `update-version` adds it to that
  package's `files`. Every app that uses Lexical installs `lexical`, so
  `node_modules/lexical/CHANGELOG.md` gives the full history to anyone
  upgrading from an installed version, offline.
- The maintainers guide describes the new release steps.

No library runtime code or public API changes.

## Test plan

### Before

The output of the old script, as committed in CHANGELOG.md:

```
$ grep -n 'lexicallexical-html\|Find  Replace\|fix insertList' CHANGELOG.md
20:- lexicallexical-html Breaking Change honor createDOM overrides in default DOM export (#9231) Bob Ippolito
47:- lexical-playground Bug Fix Fix Find  Replace offsets across decorators and slots (#9186) Monier Ayman
49:- lexical-website Documentation Update fix insertList argument in the commands guide (#9188) Sherry
```

### After

```
$ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts
 ✓ |scripts-unit| scripts/__tests__/unit/changesets.test.ts (19 tests) 22ms
 ✓ |scripts-unit| scripts/__tests__/unit/changelog.test.ts (17 tests) 2327ms
 Test Files  2 passed (2)
      Tests  36 passed (36)
```

With three temporary example changesets (not committed) in `.changeset/`:

```
$ pnpm run changelog
## v0.53.0 (2026-10-15)

### Breaking changes

- **lexical, @lexical/html**: Example: remove `ExampleNode.legacyMethod`

  Migration: call `$exampleHelper(node)` instead.

  ```ts
  // Before
  node.legacyMethod();
  // After
  $exampleHelper(node);
  ```

  Detect: calls to `.legacyMethod(`.

### Deprecations

- **@lexical/table**: Example: deprecate `$exampleTableHelper`

  Replacement: `$exampleTableHelperFrom`.

  Removal: no earlier than v0.60.0.

### Fixes

- **@lexical/list**: Example: keep `listStyleType` when a list item is split

### Contributors

@Example-contributor

$ node scripts/changesets/release.mjs --version 0.52.1
Refusing to release 0.52.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/tmp-breaking.md: Example: remove `ExampleNode.legacyMethod`
Run the release with the "minor" increment instead.

$ node scripts/npm/increment-version.mjs -i patch --channel latest
Refusing a patch release: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/tmp-breaking.md: Example: remove `ExampleNode.legacyMethod`
Run the "Create New Release Branch" workflow with the "minor" increment.
```

The same changesets in a throwaway clone, each committed with a
squash-merge style `(#NNNN)` subject, then the step `postversion` runs:

```
$ npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 3 changeset(s).
$ git status --short
 D .changeset/tmp-breaking.md
 D .changeset/tmp-deprecation.md
 D .changeset/tmp-fix.md
 M CHANGELOG.md
$ head -32 CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **lexical, @lexical/html**: Example: remove `ExampleNode.legacyMethod` ([#9992](#9992))

  Migration: call `$exampleHelper(node)` instead.
  ...

### Deprecations

- **@lexical/table**: Example: deprecate `$exampleTableHelper` ([#9991](#9991))
  ...

### Fixes

- **@lexical/list**: Example: keep `listStyleType` when a list item is split ([#9990](#9990))

### Contributors

@Example-contributor, Dev Example

## v0.52.0 (2026-09-27)
```

Stock `changeset version` also accepts the config in that clone (all
published packages to 0.53.0, `lexical-playground` left at 0.52.0):

```
$ changeset version
🦋 changeset v3.0.3
All files have been updated. Review them and commit at your leisure
$ node -e "...lexical, @lexical/yjs, lexical-playground versions"
0.53.0 0.53.0 0.52.0
```

Range view and release notes on the current CHANGELOG.md (the breaking
sections are backfilled in the next commit):

```
$ pnpm run changelog:range -- --from 0.51.0 --breaking
No breaking changes or deprecations after 0.51.0.
$ pnpm run release-notes -- --version 0.52.0 | head -1
- lexical Bug Fix Track explicit Shift state for iOS line breaks (#9242) Bob Ippolito
```

The `lexical` tarball includes the copied changelog:

```
$ cp CHANGELOG.md packages/lexical/ && (cd packages/lexical && pnpm pack --dry-run) | grep -A3 'Tarball Contents'
Tarball Contents
CHANGELOG.md
LICENSE
README.md
```

`pnpm run tsc-scripts`, `pnpm run tsc-test`, ESLint and Prettier pass on the
changed files. The release workflows themselves were not run.
zurfyx added a commit that referenced this pull request Oct 15, 2026
…md from them at release

## Description

CHANGELOG.md is built from `git log` subjects by `scripts/npm/update-changelog.mjs`.
That script strips every character outside `[a-zA-Z0-9()\n \-,.#]`
(`[lexical][lexical-html] Breaking Change:` becomes
`lexicallexical-html Breaking Change`, `$insertList` becomes `insertList`),
drops the newest commit (`HEAD~1`), and has no categories, links or
migration notes. Whether a change is breaking is only as reliable as the PR
title, and migration instructions exist only in hand-written GitHub release
notes. Someone upgrading across several 0.x minors, or a tool such as
Renovate, Dependabot, or a coding agent, has nothing consistent to read.

This adds changesets, in the layout of the changesets project and following
the conventions of facebook/astryx, as the source of each changelog entry.
No new dependency: the scripts use Node built-ins only.

Format and checks:

- `.changeset/config.json` has one `fixed` group with every published package
  (globs) and ignores the private ones, so it stays compatible with standard
  changesets tooling. `.changeset/README.md` documents the format.
- A changeset body starts with `[category] one-line summary`; categories, in
  changelog order: `breaking`, `deprecation`, `feature`, `fix`, `perf`,
  `docs`, `chore` (aliases accepted). While 0.x, `breaking` uses `minor`,
  everything else `patch`; `major` is rejected. `breaking` needs a
  `Migration:` paragraph (optional `Detect:`, `Codemod:`, `Verify:`); `deprecation`
  needs `Replacement:` and should have `Removal:`. Optional `@handle` and
  `PR: #123` lines go under the summary.
- `pnpm run check-changesets` (in `ci-check`, a hard failure) also rejects
  empty frontmatter (pointing at the `skip-changeset` label), frontmatter
  comments, duplicate packages, Markdown headings in the body, TODO
  placeholders, and a config that no longer covers every package.
- `pnpm run changeset:new -- --category fix --packages lexical --summary "..."`
  writes a valid file, with TODO lines for the required breaking or
  deprecation paragraphs.
- A `Changesets` workflow checks coverage on pull requests: a change to a
  published package's `src/` (tests, benches, mocks excluded), Flow types, or
  consumer-facing `package.json` fields (dependencies, exports, files, type,
  imports, typesVersions, browser, publishConfig, ...) needs a changeset
  naming that package; deleting a published package needs a `[breaking]` one.
  It runs the checker from the base revision, exempts release PRs only from
  this repository, honors a `skip-changeset` label, and starts in warning
  mode (`CHANGESET_COVERAGE: warn`: job summary plus an annotation with the
  file to add).

Release:

- `update-changelog` (run by `postversion` on `latest`) now runs
  `scripts/changesets/release.mjs`. It renders the pending changesets as
  `## vX.Y.Z (date)` (the heading Renovate and Dependabot slice on) with
  Breaking changes, Deprecations, Features, Fixes, Performance,
  Documentation, Other and Contributors, then `### All changes`: every commit
  since the previous release with its subject unchanged and its PR linked,
  the newest included and release bump commits excluded. It then deletes the
  consumed changesets.
- PRs come from a `PR:` line, the squash-merge subject of the commit that
  added the changeset (following renames, not copies), the first-parent
  `Merge pull request #N`, or, with `GITHUB_TOKEN` (now passed in
  `call-release.yml`), the GitHub API, which also gives contributor logins.
  Bots are not credited.
- It refuses to run while the previous stable release (newest tag or
  `LATEST_RELEASE`) has no section in CHANGELOG.md, i.e. its release PR is
  not merged, so a second run cannot consume the same changesets.
  `increment-version` and `update-changelog` refuse a `latest` patch while a
  `[breaking]` changeset is pending.
- `lexical` ships CHANGELOG.md (copied by `prepare-release`, gitignored). For
  a prerelease the copy also lists pending changesets as `## Unreleased`; the
  repository file is unchanged.
- `pnpm run changelog` previews the next section;
  `pnpm run changelog:range -- --from X [--to Y] [--breaking] [--json] [--changelog F]`
  prints a range, oldest first (strict arguments, exit 2 on bad input, a
  note naming versions `--breaking` cannot show);
  `pnpm run release-notes -- --version X` prints a section as a starting
  point for the GitHub release.

CONTRIBUTING.md, the PR template, AGENTS.md and the maintainers guide
describe all of this. The maintainers guide keeps the `[Breaking Change]`
title rule and adds the changeset rule beside it. No library runtime code
or public API changes.

## Test plan

### Before

The output of the old script, as committed in CHANGELOG.md on main:

```
$ grep -n 'lexicallexical-html\|Find  Replace\|fix insertList' CHANGELOG.md
20:- lexicallexical-html Breaking Change honor createDOM overrides in default DOM export (#9231) Bob Ippolito
47:- lexical-playground Bug Fix Fix Find  Replace offsets across decorators and slots (#9186) Monier Ayman
49:- lexical-website Documentation Update fix insertList argument in the commands guide (#9188) Sherry
```

### After

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

$ pnpm install --frozen-lockfile && git diff --stat origin/main -- pnpm-lock.yaml
(no lockfile change)
```

Format errors:

```
$ node scripts/changesets/check.mjs --dir demo-cs
Changeset check found 4 problem(s):

- demo-cs/bad.md: comments are not supported in the frontmatter ("# note"); list only "'package': bump" lines and put notes in the body.
- demo-cs/bad.md: "lexical" is listed more than once in the frontmatter.
- demo-cs/bad.md: Markdown headings ("## Details") are not allowed in a changeset; they would break the CHANGELOG.md structure. Use a paragraph or **bold** text instead.
- demo-cs/empty.md: the frontmatter lists no packages. Empty changesets are not used here: if the change has no effect on people who use Lexical, delete this file and ask a maintainer for the `skip-changeset` label instead.
```

Coverage on this commit alone (it changes `lexical`'s `files`, and its
changeset is in the next commit):

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)

Add a changeset, e.g. with

  pnpm run changeset:new -- --category fix --packages lexical --summary "..."
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

Range input checks:

```
$ pnpm run changelog:range -- --from latest
--from must be a version such as 0.40.0, got "latest".
usage: pnpm run changelog:range -- --from <version> [--to <version>] [--breaking] [--json] [--changelog <file>]
(exit 2)
$ pnpm run changelog:range -- --from 0.50.0 --bogus
Unknown option '--bogus'
(exit 2)
```

Release dry runs with the changesets from the next commit are in that
commit's message. `pnpm run tsc-scripts`, `pnpm run tsc-test`, ESLint and
Prettier pass. The workflows themselves only run on GitHub.
zurfyx added a commit that referenced this pull request Oct 15, 2026
…md from them at release

## Description

CHANGELOG.md is built from `git log` subjects by `scripts/npm/update-changelog.mjs`.
That script strips every character outside `[a-zA-Z0-9()\n \-,.#]`
(`[lexical][lexical-html] Breaking Change:` becomes
`lexicallexical-html Breaking Change`, `$insertList` becomes `insertList`),
drops the newest commit (`HEAD~1`), and has no categories, links or
migration notes. Whether a change is breaking is only as reliable as the PR
title, and migration instructions exist only in hand-written GitHub release
notes. Someone upgrading across several 0.x minors, or a tool such as
Renovate, Dependabot, or a coding agent, has nothing consistent to read.

This adds changesets, in the layout of the changesets project and following
the conventions of facebook/astryx, as the source of each changelog entry.
No new dependency: the scripts use Node built-ins only.

Format and checks:

- `.changeset/config.json` has one `fixed` group with every published package
  (globs) and ignores the private ones, so it stays compatible with standard
  changesets tooling. `.changeset/README.md` documents the format.
- A changeset body starts with `[category] one-line summary`; categories, in
  changelog order: `breaking`, `deprecation`, `feature`, `fix`, `perf`,
  `docs`, `chore` (aliases accepted). While 0.x, `breaking` uses `minor`,
  everything else `patch`; `major` is rejected. `breaking` needs
  `Migration:` and `Detect:` (optional `Codemod:`, `Verify:`); `deprecation`
  needs `Replacement:` and `Removal:` (a version, `no earlier than v0.NN`,
  or `not scheduled`). Optional `@handle` and `PR: #123` lines go under the
  summary.
- A non-breaking entry with a `Verify:` paragraph (a fix that changes
  observable output or behavior) is listed under `### Behavior changes`,
  right after the breaking changes, with no new category.
- `pnpm run check-changesets` (in `ci-check`, a hard failure) also rejects
  empty frontmatter (pointing at the `skip-changeset` label), frontmatter
  comments, duplicate packages, Markdown headings in the body, TODO
  placeholders, and a config that no longer covers every package.
- `pnpm run changeset:new -- --category fix --packages lexical --summary "..."`
  writes a valid file, with TODO lines for the required breaking or
  deprecation paragraphs.
- A `Changesets` workflow checks coverage on pull requests: a change to a
  published package's `src/` (tests, benches, mocks excluded), Flow types, or
  consumer-facing `package.json` fields (dependencies, exports, files, type,
  imports, typesVersions, browser, publishConfig, ...) needs a changeset
  naming that package; deleting a published package needs a `[breaking]` one.
  It runs the checker from the base revision, exempts release PRs only from
  this repository, honors a `skip-changeset` label, and starts in warning
  mode (`CHANGESET_COVERAGE: warn`: job summary plus an annotation with the
  file to add and a link that opens it prefilled on the pull request's
  branch, built from the event payload). It stays `warn` until the
  `skip-changeset` label exists.

Release:

- `update-changelog` (run by `postversion` on `latest`) now runs
  `scripts/changesets/release.mjs`. It renders the pending changesets as
  `## vX.Y.Z (date)` (the heading Renovate and Dependabot slice on) with
  Breaking changes, Behavior changes, Deprecations, Features, Fixes, Performance,
  Documentation, Other and Contributors, then `### All changes`: every commit
  since the previous release with its subject unchanged and its PR linked,
  the newest included and release bump commits excluded. It then deletes the
  consumed changesets.
- PRs come from a `PR:` line, the squash-merge subject of the commit that
  added the changeset (following renames, not copies), the first-parent
  `Merge pull request #N`, or, with `GITHUB_TOKEN` (now passed in
  `call-release.yml`), the GitHub API, which also gives contributor logins.
  Bots are not credited.
- It refuses to run while the previous stable release (newest tag or
  `LATEST_RELEASE`) has no section in CHANGELOG.md, i.e. its release PR is
  not merged, so a second run cannot consume the same changesets.
  `increment-version` and `update-changelog` refuse a `latest` patch while a
  `[breaking]` changeset is pending.
- `lexical` ships CHANGELOG.md (copied by `prepare-release`, gitignored). For
  a prerelease the copy also lists pending changesets as `## Unreleased`; the
  repository file is unchanged.
- `pnpm run changelog` previews the next section;
  `pnpm run changelog:range -- --from X [--to Y] [--breaking] [--json] [--changelog F]`
  prints a range, oldest first; `--breaking` keeps breaking changes,
  behavior changes and deprecations, and JSON marks behavior changes with
  `behavior: true` (strict arguments, exit 2 on bad input, a note naming
  versions `--breaking` cannot show);
  `pnpm run release-notes -- --version X` prints a section as a starting
  point for the GitHub release.

CONTRIBUTING.md, the PR template, AGENTS.md and the maintainers guide
describe all of this. The maintainers guide keeps the `[Breaking Change]`
title rule and adds the changeset rule beside it. No library runtime code
or public API changes.

## Test plan

### Before

The output of the old script, as committed in CHANGELOG.md on main:

```
$ grep -n 'lexicallexical-html\|Find  Replace\|fix insertList' CHANGELOG.md
20:- lexicallexical-html Breaking Change honor createDOM overrides in default DOM export (#9231) Bob Ippolito
47:- lexical-playground Bug Fix Fix Find  Replace offsets across decorators and slots (#9186) Monier Ayman
49:- lexical-website Documentation Update fix insertList argument in the commands guide (#9188) Sherry
```

### After

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

$ pnpm install --frozen-lockfile && git diff --stat origin/main -- pnpm-lock.yaml
(no lockfile change)
```

Format errors:

```
$ node scripts/changesets/check.mjs --dir demo-cs
Changeset check found 4 problem(s):

- demo-cs/bad.md: comments are not supported in the frontmatter ("# note"); list only "'package': bump" lines and put notes in the body.
- demo-cs/bad.md: "lexical" is listed more than once in the frontmatter.
- demo-cs/bad.md: Markdown headings ("## Details") are not allowed in a changeset; they would break the CHANGELOG.md structure. Use a paragraph or **bold** text instead.
- demo-cs/empty.md: the frontmatter lists no packages. Empty changesets are not used here: if the change has no effect on people who use Lexical, delete this file and ask a maintainer for the `skip-changeset` label instead.
```

Coverage on this commit alone (it changes `lexical`'s `files`, and its
changeset is in the next commit):

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)

Add a changeset, e.g. with

  pnpm run changeset:new -- --category fix --packages lexical --summary "..."
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

The same check as the Changesets workflow runs it, with the event values it
copies into the environment:

```
$ GITHUB_ACTIONS=true GITHUB_STEP_SUMMARY=summary.md HEAD_REPO=zurfyx/lexical HEAD_REF=zurfyx/upgrade-guide \
    PR_TITLE="[lexical] Chore: Ship CHANGELOG.md in lexical" node scripts/changesets/check.mjs --base origin/main --coverage warn
$ tail -3 summary.md
[Add the changeset in the browser](https://github.com/zurfyx/lexical/new/zurfyx/upgrade-guide?filename=.changeset%2Fship-changelog-md-in-lexical.md&value=---%0A'lexical'%3A%20patch%0A---%0A%0A%5Bchore%5D%20Ship%20CHANGELOG.md%20in%20lexical%0A) (opens a prefilled file on this pull request's branch; edit the summary before committing).

See "Changesets" in CONTRIBUTING.md.
```

Range input checks:

```
$ pnpm run changelog:range -- --from latest
--from must be a version such as 0.40.0, got "latest".
usage: pnpm run changelog:range -- --from <version> [--to <version>] [--breaking] [--json] [--changelog <file>]
(exit 2)
$ pnpm run changelog:range -- --from 0.50.0 --bogus
Unknown option '--bogus'
(exit 2)
```

Release dry runs with the changesets from the next commit are in that
commit's message. `pnpm run tsc-scripts`, `pnpm run tsc-test`, ESLint and
Prettier pass. The workflows themselves only run on GitHub.
zurfyx added a commit that referenced this pull request Oct 15, 2026
…md from them at release

## Description

CHANGELOG.md is built from `git log` subjects by `scripts/npm/update-changelog.mjs`.
That script strips every character outside `[a-zA-Z0-9()\n \-,.#]`
(`[lexical][lexical-html] Breaking Change:` becomes
`lexicallexical-html Breaking Change`, `$insertList` becomes `insertList`),
drops the newest commit (`HEAD~1`), and has no categories, links or
migration notes. Whether a change is breaking is only as reliable as the PR
title, and migration instructions exist only in hand-written GitHub release
notes. Someone upgrading across several 0.x minors, or a tool such as
Renovate, Dependabot, or a coding agent, has nothing consistent to read.

This adds changesets, in the layout of the changesets project and following
the conventions of facebook/astryx, as the source of each changelog entry.
No new dependency: the scripts use Node built-ins only.

Format and checks:

- `.changeset/config.json` has one `fixed` group with every published package
  (globs) and ignores the private ones, so it stays compatible with standard
  changesets tooling. `.changeset/README.md` documents the format.
- A changeset body starts with `[category] one-line summary`; categories, in
  changelog order: `breaking`, `deprecation`, `feature`, `fix`, `perf`,
  `docs`, `chore` (aliases accepted). While 0.x, `breaking` uses `minor`,
  everything else `patch`; `major` is rejected. `breaking` needs
  `Migration:` and `Detect:` (optional `Codemod:`, `Verify:`); `deprecation`
  needs `Replacement:` and `Removal:` (a version, `no earlier than v0.NN`,
  or `not scheduled`). Optional `@handle` and `PR: #123` lines go under the
  summary.
- A non-breaking entry with a `Verify:` paragraph (a fix that changes
  observable output or behavior) is listed under `### Behavior changes`,
  right after the breaking changes, with no new category.
- `pnpm run check-changesets` (in `ci-check`, a hard failure) also rejects
  empty frontmatter (pointing at the `skip-changeset` label), frontmatter
  comments, duplicate packages, Markdown headings in the body, TODO
  placeholders, and a config that no longer covers every package.
- `pnpm run changeset:new -- --category fix --packages lexical --summary "..."`
  writes a valid file, with TODO lines for the required breaking or
  deprecation paragraphs.
- A `Changesets` workflow checks coverage on pull requests: a change to a
  published package's `src/` (tests, benches, mocks excluded), Flow types, or
  consumer-facing `package.json` fields (dependencies, exports, files, type,
  imports, typesVersions, browser, publishConfig, ...) needs a changeset
  naming that package; deleting a published package needs a `[breaking]` one.
  It runs the checker from the base revision, exempts release PRs only from
  this repository, honors a `skip-changeset` label, and starts in warning
  mode (`CHANGESET_COVERAGE: warn`: job summary plus an annotation with the
  file to add and a link that opens it prefilled on the pull request's
  branch, built from the event payload). It stays `warn` until the
  `skip-changeset` label exists.

Release:

- `update-changelog` (run by `postversion` on `latest`) now runs
  `scripts/changesets/release.mjs`. It renders the pending changesets as
  `## vX.Y.Z (date)` (the heading Renovate and Dependabot slice on) with
  Breaking changes, Behavior changes, Deprecations, Features, Fixes, Performance,
  Documentation, Other and Contributors, then `### All changes`: every commit
  since the previous release with its subject unchanged and its PR linked,
  the newest included and release bump commits excluded. It then deletes the
  consumed changesets.
- PRs come from a `PR:` line, the squash-merge subject of the commit that
  added the changeset (following renames, not copies), the first-parent
  `Merge pull request #N`, or, with `GITHUB_TOKEN` (now passed in
  `call-release.yml`), the GitHub API, which also gives contributor logins.
  Bots are not credited.
- It refuses to run while the previous stable release (newest tag or
  `LATEST_RELEASE`) has no section in CHANGELOG.md, i.e. its release PR is
  not merged, so a second run cannot consume the same changesets.
  `increment-version` and `update-changelog` refuse a `latest` patch while a
  `[breaking]` changeset is pending.
- `lexical` ships CHANGELOG.md (copied by `prepare-release`, gitignored). For
  a prerelease the copy also lists pending changesets as `## Unreleased`; the
  repository file is unchanged.
- `pnpm run changelog` previews the next section;
  `pnpm run changelog:range -- --from X [--to Y] [--breaking] [--json] [--changelog F]`
  prints a range, oldest first; `--breaking` keeps breaking changes,
  behavior changes and deprecations, and JSON marks behavior changes with
  `behavior: true` (strict arguments, exit 2 on bad input, a note naming
  versions `--breaking` cannot show);
  `pnpm run release-notes -- --version X` prints a section as a starting
  point for the GitHub release.

CONTRIBUTING.md, the PR template, AGENTS.md and the maintainers guide
describe all of this. The maintainers guide keeps the `[Breaking Change]`
title rule and adds the changeset rule beside it. No library runtime code
or public API changes.

## Test plan

### Before

The output of the old script, as committed in CHANGELOG.md on main:

```
$ grep -n 'lexicallexical-html\|Find  Replace\|fix insertList' CHANGELOG.md
20:- lexicallexical-html Breaking Change honor createDOM overrides in default DOM export (#9231) Bob Ippolito
47:- lexical-playground Bug Fix Fix Find  Replace offsets across decorators and slots (#9186) Monier Ayman
49:- lexical-website Documentation Update fix insertList argument in the commands guide (#9188) Sherry
```

### After

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

$ pnpm install --frozen-lockfile && git diff --stat origin/main -- pnpm-lock.yaml
(no lockfile change)
```

Format errors:

```
$ node scripts/changesets/check.mjs --dir demo-cs
Changeset check found 4 problem(s):

- demo-cs/bad.md: comments are not supported in the frontmatter ("# note"); list only "'package': bump" lines and put notes in the body.
- demo-cs/bad.md: "lexical" is listed more than once in the frontmatter.
- demo-cs/bad.md: Markdown headings ("## Details") are not allowed in a changeset; they would break the CHANGELOG.md structure. Use a paragraph or **bold** text instead.
- demo-cs/empty.md: the frontmatter lists no packages. Empty changesets are not used here: if the change has no effect on people who use Lexical, delete this file and ask a maintainer for the `skip-changeset` label instead.
```

Coverage on this commit alone (it changes `lexical`'s `files`, and its
changeset is in the next commit):

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)

Add a changeset, e.g. with

  pnpm run changeset:new -- --category fix --packages lexical --summary "..."
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

The same check as the Changesets workflow runs it, with the event values it
copies into the environment:

```
$ GITHUB_ACTIONS=true GITHUB_STEP_SUMMARY=summary.md HEAD_REPO=zurfyx/lexical HEAD_REF=zurfyx/upgrade-guide \
    PR_TITLE="[lexical] Chore: Ship CHANGELOG.md in lexical" node scripts/changesets/check.mjs --base origin/main --coverage warn
$ tail -3 summary.md
[Add the changeset in the browser](https://github.com/zurfyx/lexical/new/zurfyx/upgrade-guide?filename=.changeset%2Fship-changelog-md-in-lexical.md&value=---%0A'lexical'%3A%20patch%0A---%0A%0A%5Bchore%5D%20Ship%20CHANGELOG.md%20in%20lexical%0A) (opens a prefilled file on this pull request's branch; edit the summary before committing).

See "Changesets" in CONTRIBUTING.md.
```

Range input checks:

```
$ pnpm run changelog:range -- --from latest
--from must be a version such as 0.40.0, got "latest".
usage: pnpm run changelog:range -- --from <version> [--to <version>] [--breaking] [--json] [--changelog <file>]
(exit 2)
$ pnpm run changelog:range -- --from 0.50.0 --bogus
Unknown option '--bogus'
(exit 2)
```

Release dry runs with the changesets from the next commit are in that
commit's message. `pnpm run tsc-scripts`, `pnpm run tsc-test`, ESLint and
Prettier pass. The workflows themselves only run on GitHub.

This branch was successfully deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants