Prevent JSX kind mismatches from crashing the editor - #963
Merged
Merged
Conversation
Closed
petyosi
force-pushed
the
petyosi/jsx-kind-mismatch-policy
branch
from
August 27, 2026 10:13
63d68ce to
a5f5763
Compare
|
🎉 This PR is included in version 4.2.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Valid one-line MDX can parse a component as inline content even when its descriptor declares a flow component. The generic JSX editor previously used the descriptor to create a block nested editor, which placed phrasing nodes directly under a Lexical root and crashed the editor.
Fixes #962.
What changes
The JSX plugin now uses the parsed MDAST node type as the default content model, so valid source imports and edits without a Lexical invariant failure.
Consumers can set kindMismatchPolicy to normalize when descriptors should be authoritative for lossless conversions, or error when every mismatch should be rejected through onError. Reconciliation runs before Lexical construction, follows import-visitor ownership, and also applies to direct MDAST tree imports.
The change includes documentation and regression coverage for nested edits, both mismatch directions, wildcard descriptors, built-in HTML ownership, direct imports, and unsupported normalization shapes.
Limits
Normalization does not split surrounding paragraphs or flatten multiple or non-paragraph blocks. Those cases produce a recoverable error because conversion could change or discard content.