Skip to content

fix: respect nonconsecutive heading levels in markdown shortcuts - #993

Merged
petyosi merged 1 commit into
mdx-editor:mainfrom
huyanxius:fix/nonconsecutive-heading-shortcuts-20261012
Oct 13, 2026
Merged

petyosi merged 1 commit into
mdx-editor:mainfrom
huyanxius:fix/nonconsecutive-heading-shortcuts-20261012

Conversation

@huyanxius

@huyanxius huyanxius commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Respect each explicitly allowed heading level in Markdown shortcuts. With allowedHeadingLevels: [2, 4], typing ### currently creates an h3 because the transformer matches the entire min/max range.

  • Build the heading matcher from the configured levels and preserve the captured marker used to choose the heading tag.
  • Skip the heading transformer for an empty allowlist.
  • Add root, nested-editor, and table-cell registration coverage, plus real Lexical shortcut-transform tests.
  • Add a minimal Ladle example and Playwright typing cases for all six heading levels.

This addresses the remaining nonconsecutive-level behavior after #952.

Regression evidence

On unchanged main (122347c), the Lexical shortcut test with [2, 4] fails after inserting a space after ###: the resulting node is heading, but should remain paragraph. The other five heading-level cases pass. All six pass with this change.

The focused suite also checks default, contiguous, nonconsecutive, unsorted, repeated, single-level, and empty configurations, including the marker capture used for the resulting heading level.

Verification

Passed locally:

  • npm run lint
  • npm run typecheck
  • npm run test:once: 154 passed, 1 skipped, 1 todo
  • Focused shortcut suite: 33 passed
  • npm run test:lexical-versions: 24 packages at 0.48.0
  • npm run build
  • npm run build:docs:api
  • npm exec ladle -- build: all examples built
  • Prettier check on changed files and git diff --check

The local environment could not install/start the matched browsers. The unchanged existing workflow has now completed on the fork for this exact head (5d9ca7d3b1ceb093f855bc2c4a4238eb3f6cd15d): CI run.

  • All four jobs passed: Test, Browser compatibility, Build JS, and Build Docs.
  • Chromium, Firefox, and WebKit: 114/114 cases passed, including the 18 new heading-level cases; retries remain disabled.
  • Packed React 18 and React 19 declarations, bundle, styles, runtime, and public-ref output passed.
  • The cross-version Markdown replay (0.35 input → packed 0.48 output → published 4.0.4/0.35 reader) passed.

This fork validation is separate from upstream CI approval. The PR remains draft.

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants