[lexical-playground] Bug Fix: Export ParagraphNode as div role="paragraph" when it contains block DOM#7906
Merged
etrepum merged 1 commit intofacebook:mainfrom Oct 7, 2025
Merged
Conversation
…raph" when it contains block DOM
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
commented
Oct 6, 2025
| @@ -1,11 +1,3 @@ | |||
| /** | |||
Collaborator
Author
There was a problem hiding this comment.
This environment is not needed anymore now that we are using vitest
|
|
||
| return importMap; | ||
| } | ||
| function buildExportMap(): DOMExportOutputMap { |
Collaborator
Author
There was a problem hiding this comment.
This is the new functionality to override paragraph export
| ? undefined | ||
| : $prepopulatedRichText, | ||
| html: {import: buildImportMap()}, | ||
| html: buildHTMLConfig(), |
Collaborator
Author
There was a problem hiding this comment.
all of the import/export code was extracted to another file because some imports in App.tsx are not importable from node (excalidraw stuff)
zurfyx
approved these changes
Oct 7, 2025
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.
Description
Follow-up to #7900 which added
<figure>export to<img>nodes with caption.The HTML spec does not allow the p tag to contain block-level elements (mdn). figure and figcaption are block-level elements (as are some other things rendered by decorators that may end up inline). There's no way for us to say that the
<figure>node is actually not used inline in this case, nor is it possible to really attach any other sort of HTML caption to animgnode (the alt or title could be used, but is not advised by mdn)Using an element without Tag Omission such as the div element (mdn) in these cases will allow us to serialize the figure node inside of a logical paragraph
Test plan
Before
The symptom of this is that when you use a DOMParser that conforms to the HTML5 spec is that you will split
<p>tags at every<figure>or other block-level element.After
When a block-level child of a
<p>tag is detected in the playground's html export override for ParagraphNode, it will replace that<p>tag with<div role="paragraph">which avoids the issue.