Skip to content

[lexical-code-core] Bug Fix: normalize imported code content - #9272

Merged
etrepum merged 2 commits into
meta:mainfrom
maximilliangrand:codex/normalize-imported-code-paragraphs
Sep 30, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
maximilliangrand:codex/normalize-imported-code-paragraphs

Conversation

@maximilliangrand

@maximilliangrand maximilliangrand commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

HTML code imports can retain paragraphs, headings, links, and other nested nodes inside a CodeNode. Two imported paragraphs can become alpha\n\nbeta instead of adjacent code lines, and code editing helpers do not support those nested children.

Normalize all six code-import paths to CodeHighlightNode, TabNode, and LineBreakNode using the existing $plainifyCodeContent helper. Imported nodes supply their getTextContent() representation, with one line break between top-level siblings when either is block-level. This supports custom subclasses and configured node replacements without constructor checks; nested containers retain their own plain-text separators. Plain monospace DIV descendants retain their line boundaries.

Applies to the experimental HTML importer. Developed with Codex assistance and independently checked against current upstream.

Test plan

Before

Copied the final tests onto unmodified current main f0fefed7bc894b19837c7b921043427fa84ba3b9:

./node_modules/.bin/vitest --project unit --run packages/lexical-code-core/src/__tests__/unit/CodeContentImport.test.ts
 Test Files  1 failed (1)
      Tests  31 failed (31)
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-code-core/src/__tests__/browser/CodeContentImport.test.ts
 Test Files  3 failed (3)
      Tests  3 failed (3)

After

The same commands, both on this branch and with only the revised importer applied to that current-main checkout:

 Test Files  1 passed (1)
      Tests  31 passed (31)
 Test Files  3 passed (3)
      Tests  3 passed (3)

Tests assert the supported child types before highlighting can normalize them. Coverage includes all six import paths, leading/consecutive/trailing empty paragraphs, nested code/headings/links/lists/tables, custom text representations, configured paragraph replacements, decorators, CRLF, tabs, and hard line breaks.

Additional checks on this branch: 948 affected unit tests and 339 source tree-shaking tests pass; source/test TypeScript, changed-file ESLint/Prettier, and git diff --check pass. Browser tests dispatch native synthetic paste events to a mounted contenteditable in Chromium, Firefox, and WebKit on macOS and verify the rendered code DOM. The full playground end-to-end matrix was not run locally.

…lines

## Description

The experimental HTML importer turns `<pre><div>alpha</div><div>beta</div></pre>` into a CodeNode with two ParagraphNode children. Its text becomes `alpha\n\nbeta`, and the nested paragraphs do not match the flat code-line structure used by code editing and highlighting.

Normalize ordinary imported paragraphs into their existing inline children with explicit line breaks between lines. This preserves leading, consecutive and trailing empty paragraphs. Apply the same normalization at the PRE, multiline CODE, monospace DIV and GitHub code-table import boundaries.

The change is intentionally limited to runs of inline nodes and built-in paragraphs containing inline nodes. Runs containing other block structures or custom paragraph implementations retain their existing behavior. There are no new public APIs or dependencies, and the legacy importer is unchanged.

## Test plan

### Before

On unchanged `30772fe845a6fbd0efbd242bea9c3d701ea9e614`, with the new regression tests:

```sh
./node_modules/.bin/vitest --project unit --run packages/lexical-code-core/src/__tests__/unit/CodeParagraphImport.test.ts
```

```text
Test Files  1 failed (1)
     Tests  15 failed | 6 passed (21)
```

### After

The same command with this change:

```text
Test Files  1 passed (1)
     Tests  21 passed (21)
```

The tests cover the four import boundaries, empty lines, mixed inline/paragraph content, nested transparent HTML wrappers, tabs, and preservation of existing code/table/custom node objects.

```sh
./node_modules/.bin/vitest --project unit --run \
  packages/lexical-html/src/__tests__/unit \
  packages/lexical-code-core/src/__tests__/unit \
  packages/lexical-code-prism/src/__tests__/unit \
  packages/lexical-code-shiki/src/__tests__/unit \
  packages/lexical-clipboard/src/__tests__/unit
```

```text
Test Files  35 passed (35)
     Tests  419 passed (419)
```

Also passed:

```sh
./node_modules/.bin/eslint packages/lexical-code-core/src/CodeImportExtension.ts packages/lexical-code-core/src/__tests__/unit/CodeParagraphImport.test.ts
./node_modules/.bin/prettier --check packages/lexical-code-core/src/CodeImportExtension.ts packages/lexical-code-core/src/__tests__/unit/CodeParagraphImport.test.ts
./node_modules/.bin/tsc -p tsconfig.test.json --noEmit
git diff --check
```

Local validation used macOS arm64 and Node 26.7.0. The full monorepo, Windows and Linux matrices were not run locally.

Implemented with Codex assistance.
@vercel

vercel Bot commented Sep 29, 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 30, 2026 3:53pm UTC
lexical-playground Ready Ready Preview Sep 30, 2026 3:53pm UTC

Request Review

child =>
$isBlockLevel(child) &&
(!$isParagraphNode(child) ||
child.constructor !== ParagraphNode ||

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.

This is just nonsense, !$isParagraphNode(child) already covers every case of child.constructor !== ParagraphNode, but the child.constructor comparison is worse because it doesn't support subclasses or node replacement.

Comment on lines +37 to +39
function $flattenCodeParagraphs(children: LexicalNode[]): LexicalNode[] {
// Other block nodes can have their own separators or custom semantics.
// Only normalize runs of inlines and ordinary paragraphs of inlines.

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.

If the goal here is to normalize to exactly the constructs that CodeNode supports then it should do that, rather than handling only ParagraphNode.

## Description

Paragraph-only normalization can leave headings, links, nested code and custom blocks inside imported CodeNodes. Normalize each imported node's plain-text representation through the existing code tokenizer so all six import paths produce CodeHighlightNode, TabNode and LineBreakNode children. Preserve custom getTextContent implementations, add one line break at top-level block boundaries, and let nested containers retain their own text separators. Plain monospace DIV descendants retain their block boundaries.

## Test plan

### Before

With the updated unit tests on 0beca6a:

```sh
./node_modules/.bin/vitest --project unit --run packages/lexical-code-core/src/__tests__/unit/CodeContentImport.test.ts
```

```text
 Test Files  1 failed (1)
      Tests  28 failed | 3 passed (31)
```

```sh
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-code-core/src/__tests__/browser/CodeContentImport.test.ts
```

```text
 Test Files  3 failed (3)
      Tests  3 failed (3)
```

### After

The same unit and browser commands:

```text
 Test Files  1 passed (1)
      Tests  31 passed (31)
```

```text
 Test Files  3 passed (3)
      Tests  3 passed (3)
```

All 948 affected unit tests and 339 source tree-shaking tests pass. Source/test TypeScript checks, changed-file ESLint/Prettier and git diff --check pass. Browser tests dispatch native synthetic paste events to a mounted contenteditable in Chromium, Firefox and WebKit on macOS. The full playground end-to-end matrix was not run locally.
@maximilliangrand maximilliangrand changed the title [lexical-code-core] Bug Fix: normalize imported paragraphs into code lines [lexical-code-core] Bug Fix: normalize imported code content Sep 30, 2026
maximilliangrand added a commit to maximilliangrand/lexical that referenced this pull request Sep 30, 2026
…ion HTML import

## Description

The experimental HTML importer drops empty transparent blocks such as `<div><br></div>`. In the Gmail reproduction from meta#4830, pasting yields nine paragraphs instead of eleven. Preserve those authored blank boundaries at the root and in table cells, list items, and code content.

The default BR rule retains a sole placeholder only within its owning transparent block. A custom rule that discards the BR, including middleware that discards `$next()`'s result, remains authoritative. List segments are joined by position so a leading empty segment retains its separator. Code imports use the normalization in meta#9272, including when a blank appears beside nested code or a custom paragraph replacement.

This follow-up changes two production files and adds regression coverage; it adds no public API. Related to meta#4830 (thanks to @djheyson for the reproduction). meta#9271 addresses the default importer separately. Developed with Codex assistance.

## Test plan

### Before

Copied the final unit and browser tests onto the prerequisite at `a6328b61bbb00dabf3d894dfba63ef9754275f0f`:

```sh
./node_modules/.bin/vitest --project unit --run packages/lexical-html/src/__tests__/unit/EmptyBlockImportExtension.test.ts packages/lexical-html/src/__tests__/unit/EmptyBlockImportOverrides.test.ts
```

```text
 Test Files  2 failed (2)
      Tests  28 failed | 5 passed (33)
```

```sh
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-html/src/__tests__/browser/EmptyBlockImportExtension.test.ts
```

```text
 Test Files  3 failed (3)
      Tests  3 failed (3)
```

### After

The same unit command:

```text
 Test Files  2 passed (2)
      Tests  33 passed (33)
```

Gmail paste and the prerequisite's code-paste regression together in all three engines:

```sh
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-code-core/src/__tests__/browser/CodeContentImport.test.ts packages/lexical-html/src/__tests__/browser/EmptyBlockImportExtension.test.ts
```

```text
 Test Files  6 passed (6)
      Tests  6 passed (6)
```

All 981 affected tests pass across HTML, code-core, code-prism, code-shiki, list, table, rich-text, and clipboard. Test TypeScript, Flow (zero errors), changed-file ESLint/Prettier, and `git diff --check` pass.

Coverage includes leading/consecutive/trailing blanks, nested transparent blocks, table cells, list segments, all ordinary code import paths, exact blank-line counts beside nested code, custom deletion/replacement rules, paragraph replacements, and Gmail formatting/link preservation. Browser checks use native synthetic clipboard events dispatched to mounted contenteditables in Chromium, Firefox, and WebKit on macOS. The full playground end-to-end matrix was not run locally.
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Sep 30, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 30, 2026
Merged via the queue into meta:main with commit 4adcfb4 Sep 30, 2026
50 checks passed
maximilliangrand added a commit to maximilliangrand/lexical that referenced this pull request Oct 1, 2026
…ion HTML import

## Description

The experimental HTML importer drops empty transparent blocks such as `<div><br></div>`. In the Gmail reproduction from meta#4830, pasting produces nine paragraphs instead of eleven. Preserve these authored blank boundaries at the root and in table cells, list items, and code content.

The default BR rule retains a sole placeholder only within its owning transparent block. Custom rules that discard the BR, including middleware that discards `$next()`'s result, remain authoritative. List segments are joined by position so a leading empty segment retains its separator. Code imports use the normalization merged in meta#9272.

The change touches two production files and adds regression coverage without adding public API. Related to meta#4830 (thanks to @djheyson for the reproduction); meta#9271 addresses the default importer separately. Developed with Codex assistance.

## Test plan

### Before

Copied the three regression files onto unchanged upstream `7bfd3e4ef532f87bdace863afe3821a092693b51`, which includes meta#9272:

```sh
./node_modules/.bin/vitest --project unit --run packages/lexical-html/src/__tests__/unit/EmptyBlockImportExtension.test.ts packages/lexical-html/src/__tests__/unit/EmptyBlockImportOverrides.test.ts
```

```text
 Test Files  2 failed (2)
      Tests  28 failed | 5 passed (33)
```

```sh
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-html/src/__tests__/browser/EmptyBlockImportExtension.test.ts
```

```text
 Test Files  3 failed (3)
      Tests  3 failed (3)
```

### After

The same focused unit command:

```text
 Test Files  2 passed (2)
      Tests  33 passed (33)
```

Gmail paste and the merged code-paste regression together:

```sh
VITEST_BROWSER=chromium,firefox,webkit ./node_modules/.bin/vitest run --project browser packages/lexical-code-core/src/__tests__/browser/CodeContentImport.test.ts packages/lexical-html/src/__tests__/browser/EmptyBlockImportExtension.test.ts
```

```text
 Test Files  6 passed (6)
      Tests  6 passed (6)
```

All 988 affected unit tests pass across HTML, code-core, code-prism, code-shiki, list, table, rich-text, and clipboard. Test TypeScript, Flow (zero errors), changed-file ESLint/Prettier, and `git diff --check` pass.

Coverage includes leading/consecutive/trailing blanks, nested transparent blocks, table cells, list segments, ordinary code import paths, exact blank-line counts beside nested code, custom deletion/replacement rules, paragraph replacements, and Gmail formatting/link preservation. Unit fixtures use DOMParser to match the current test environment. Browser checks dispatch native synthetic clipboard events to mounted contenteditables in Chromium, Firefox, and WebKit on macOS. The full playground end-to-end matrix was not run locally.
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -7
3:### Breaking changes
28:### Features
36:### Fixes
98:### Performance
102:### Other
106:### Contributors
110:### All changes
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

Four fixes change observable output or behavior, so their changesets have
a `Verify:` paragraph and are listed under Behavior changes: #9303 (new
tabs get no `window.opener`), #9272 (imported code content is normalized),
#9261 (`$patchStyleText` styles the selection it is given), #9319 (editor
keys and namespaces are a counter without a DOM).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -8
3:### Breaking changes
28:### Behavior changes
54:### Features
62:### Fixes
108:### Performance
112:### Other
116:### Contributors
120:### All changes
$ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md
### Behavior changes

- **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303))

  This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged.

  Verify: pages opened from editor links that relied on `window.opener`.

$ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])]
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

Four fixes change observable output or behavior, so their changesets have
a `Verify:` paragraph and are listed under Behavior changes: #9303 (new
tabs get no `window.opener`), #9272 (imported code content is normalized),
#9261 (`$patchStyleText` styles the selection it is given), #9319 (editor
keys and namespaces are a counter without a DOM).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -8
3:### Breaking changes
28:### Behavior changes
54:### Features
62:### Fixes
108:### Performance
112:### Other
116:### Contributors
120:### All changes
$ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md
### Behavior changes

- **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303))

  This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged.

  Verify: pages opened from editor links that relied on `window.opener`.

$ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])]
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
@zurfyx zurfyx mentioned this pull request Oct 27, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — a6328b61 Deployed Sep 30, 2026 by vercel[bot]
Preview – lexical-playground — a6328b61 Deployed Sep 30, 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