Skip to content

[lexical-markdown] Bug Fix: nest heading inside quote when typing > # SOME HEADER#8240

Open
achaljhawar wants to merge 11 commits intofacebook:mainfrom
achaljhawar:fix/blockquote-heading-nesting
Open

[lexical-markdown] Bug Fix: nest heading inside quote when typing > # SOME HEADER#8240
achaljhawar wants to merge 11 commits intofacebook:mainfrom
achaljhawar:fix/blockquote-heading-nesting

Conversation

@achaljhawar
Copy link
Copy Markdown
Contributor

Description

Typing > # SOME HEADER created a heading but dropped the block quote. The heading transformer was replacing the QuoteNode instead of nesting inside it. Fixed createBlockNode to nest inside non-paragraph parents.

Closes #7407

Before

Lexical.Playground.10.mp4

After

Lexical.Playground.11.mp4

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 28, 2026 5:47am
lexical-playground Ready Ready Preview, Comment Mar 28, 2026 5:47am

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 Mar 19, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 19, 2026
Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current lexical document model (at least as implemented by the playground) doesn't really support blocks that contain blocks, except in cases where there's a shadow root in between or there's some special code to support it (ListItem -> ListItemNode). There might be other implications of allowing nesting here, it might be best to have this behavior as an option that defaults to false until all of the potential issues (unrelated to markdown export/import specifically) can be evaluated.

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of an awkward way to do it, I would expect these to be distinct transformers that are exported separately and could be used to build an alternate transformers array. Ideally there would be some way to pass options down through to these transformers but that would require a larger refactor of the markdown API to use extensions.

I'm also not sure that it's worth adding this complexity just to support nesting these two types of nodes specifically, certainly not with this specific approach. There is also very likely going to be other problems to fix when using a document that nests these blocks because I believe that there are places in lexical's model that assume blocks aren't nested like this.

@achaljhawar
Copy link
Copy Markdown
Contributor Author

Hey @etrepum, I looked into the block nesting concern. Core selection/insertion algorithms find HeadingNode as the leaf block before reaching QuoteNode, so they all work correctly. The only issue is the playground toolbar showing "Quote" instead of the heading tag. Let me know if you'd rather I rework this or just close it.

@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Mar 28, 2026

I'll take another look at this next week, my primary concern here is that it's only a partial solution because this structure isn't well supported by the editor and violates some of the assumptions about how elements can typically be nested (block nodes that are not shadow roots can typically only contain inline nodes).

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.

Bug: Markdown block quotes containing headers dropping quote

2 participants