Skip to content

[lexical-playground] Bug Fix: keep mention style and text formats in exported HTML - #8969

Closed
LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix/6453-mention-export-format-style
Closed

LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix/6453-mention-export-format-style

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

MentionNode.exportDOM() created a bare <span data-lexical-mention> from this.__text and ignored the node's __style and __format. Applying a font size from the toolbar dropdown to a selection containing a mention updates the editor state correctly (style: "font-size: 20px;"), but the mention is exported as an unstyled span — the symptom in #6453, visible in the playground's Tree View "Export DOM" panel. Text formats were dropped the same way.

The export now carries the inline style onto the span and wraps it in the same <b>/<i>/<s>/<u> elements TextNode.exportDOM uses. The mention element itself stays a <span> so the span[data-lexical-mention] import rule still matches it and mentions keep round-tripping.

Adds MentionHTML.test.ts: two tests for the reported symptom, plus two controls — the unchanged plain-mention export shape, and an export-import round trip confirming the format wrappers don't break mention recognition.

One adjacent bug I found and deliberately left alone: the mention import rule in MentionsExtension/index.tsx does not read ctx.get(ImportTextFormat) / ImportTextStyle the way the core #text rule does, so a bold mention pasted back in loses its bold. That is independent of this change — before it, there was nothing exported to lose — and it belongs in its own PR.

Fixes #6453

…exported HTML

MentionNode.exportDOM built a bare <span data-lexical-mention> from
this.__text, so the node's inline style (e.g. a font-size chosen from the
toolbar dropdown) and its text formats were dropped from the generated
HTML even though they were present in the editor state.

Carry the inline style onto the exported span and wrap it in the same
<b>/<i>/<s>/<u> elements TextNode.exportDOM uses. The mention element
itself stays a <span> so the span[data-lexical-mention] import rule still
matches it.
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@LeSingh1

Copy link
Copy Markdown
Contributor Author

Consolidated into #9060 with the other PRs that share this defect, per @etrepum's note on #9027 and @mayrang's on #9035. Same fix and same tests, one review.

@LeSingh1 LeSingh1 closed this Aug 10, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Mentions Format was not applied, the Font size style was not applied in html

1 participant