Skip to content

[lexical-markdown] Bug Fix: Preserve headings when typing list shortcuts - #8879

Merged
etrepum merged 3 commits into
facebook:mainfrom
StevenPDang:issue-5646
Jul 27, 2026
Merged

[lexical-markdown] Bug Fix: Preserve headings when typing list shortcuts#8879
etrepum merged 3 commits into
facebook:mainfrom
StevenPDang:issue-5646

Conversation

@StevenPDang

@StevenPDang StevenPDang commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

This PR prevents Markdown list shortcuts from replacing an existing HeadingNode when a list marker is typed at the beginning of the heading. Previously, markers such as 1. matched the list transformer based only on the block’s leading text, replacing the heading with a ListNode/ListItemNode and recording the transformation in history.

List shortcut replacement now checks whether the source block is a heading. When it is, the transformer declines the replacement, preserving both the HeadingNode and the typed marker as normal heading text.

What changed

packages/lexical-markdown/src/MarkdownTransformers.ts — updates the shared list replacement function to skip shortcut
driven transformations when the parent block is a HeadingNode. Markdown import behavior is unchanged.

packages/lexical-markdown/src/tests/unit/LexicalMarkdown.test.ts — adds parameterized regression coverage for the
ordered marker 1. and unordered markers - , * , and + . Each case verifies directly that the block remains a
HeadingNode and retains the complete typed text.

Backwards compatibility

No public APIs, types, transformer signatures, or serialized formats are changed.

Markdown import behavior remains unchanged. Shortcut behavior for paragraphs and other non-heading blocks is
preserved.

Test plan

  pnpm run test-unit packages/lexical-markdown/src/__tests__/unit/LexicalMarkdown.test.ts — 416 pass
  prettier — clean
  eslint — clean
  git diff --check — clean

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Jul 26, 2026 10:57pm
lexical-playground Ready Ready Preview Jul 26, 2026 10:57pm

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 Jul 26, 2026
@StevenPDang
StevenPDang marked this pull request as ready for review July 26, 2026 17:23
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Jul 26, 2026
Comment thread packages/lexical-markdown/src/MarkdownTransformers.ts Outdated
Co-authored-by: Bob Ippolito <bob@redivi.com>
@etrepum
etrepum added this pull request to the merge queue Jul 27, 2026
Merged via the queue into facebook:main with commit dd5c41b Jul 27, 2026
46 checks passed
@StevenPDang
StevenPDang deleted the issue-5646 branch July 27, 2026 15:05
@etrepum etrepum mentioned this pull request Jul 29, 2026
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