[lexical-markdown] Bug Fix: nest heading inside quote when typing > # SOME HEADER#8240
[lexical-markdown] Bug Fix: nest heading inside quote when typing > # SOME HEADER#8240achaljhawar wants to merge 11 commits intofacebook:mainfrom
> # SOME HEADER#8240Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
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.
packages/lexical-markdown/src/__tests__/unit/MarkdownTransformers.test.ts
Outdated
Show resolved
Hide resolved
c94dc89 to
7804c17
Compare
etrepum
left a comment
There was a problem hiding this comment.
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.
|
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. |
|
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). |
Description
Typing
> # SOME HEADERcreated 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