Repository navigation
[lexical][lexical-html] Bug Fix: restore the capitalization formats from text-transform on import - #8991
Closed
LeSingh1 wants to merge 1 commit into
Closed
[lexical][lexical-html] Bug Fix: restore the capitalization formats from text-transform on import#8991LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…rom text-transform on import ## Description Closes meta#8915 `TextNode.exportDOM` writes the three capitalization formats out as CSS: ```ts // Add text-transform styles for capitalization formats if (this.hasFormat('lowercase')) { element.style.textTransform = 'lowercase'; } else if (this.hasFormat('uppercase')) { element.style.textTransform = 'uppercase'; } else if (this.hasFormat('capitalize')) { element.style.textTransform = 'capitalize'; } ``` Nothing ever read `text-transform` back. `applyTextFormatFromStyle` (the legacy `<span>` / `<b>` / `<em>` … converters) reads `fontWeight`, `textDecoration`, `fontStyle` and `verticalAlign`; `readElementFormatStyle` / `styleFormatOverride` in the `@lexical/html` rule pipeline read the same four. So `IS_LOWERCASE` / `IS_UPPERCASE` / `IS_CAPITALIZE` were written on export and silently dropped on import — copy/paste between editors, and any `$generateHtmlFromNodes` -> `$generateNodesFromDOM` round trip, lost the format while every other text format survived. Read `text-transform` in both importers, mirroring how `vertical-align` is already handled — including the mutual exclusion, since only one of the three can apply. On the `@lexical/html` side, `text-transform: none` clears all three (the same "explicit non-decorating value clears the bit" rule that `font-weight: normal` and `vertical-align: baseline` already follow), and `text-transform` joins `FORMAT_BIT_STYLE_PROPS` so the property is owned by the format bit mask and does not also get materialized onto the node's inline style. ## Test plan New `packages/lexical-html/src/__tests__/unit/Issue8915Repro.test.ts`: for each of the three formats, one export assertion (passes before and after — it is the writer the readers are held to) plus a round trip through each of the two import pipelines. A fourth case pins that an unrelated `text-transform: none` alongside `font-weight: bold` neither sets a capitalization format nor disturbs the bold one. The test lives in its own `IssueNNNN Repro` file because `LexicalTextNode.test.tsx` is already being edited by meta#8924. ### Before ``` $ npx vitest run packages/lexical-html/src/__tests__/unit/Issue8915Repro.test.ts ✓ exportDOM writes text-transform for lowercase 11ms ✓ exportDOM writes text-transform for uppercase 1ms ✓ exportDOM writes text-transform for capitalize 1ms × $generateNodesFromDOM restores lowercase 19ms × $generateNodesFromDOM restores uppercase 7ms × $generateNodesFromDOM restores capitalize 6ms × $generateNodesFromDOMViaExtension restores lowercase 7ms × $generateNodesFromDOMViaExtension restores uppercase 6ms × $generateNodesFromDOMViaExtension restores capitalize 6ms ✓ an unrelated text-transform: none does not clear other formats 6ms AssertionError: expected false to be true // Object.is equality Tests 6 failed | 4 passed (10) ``` ### After ``` $ npx vitest run packages/lexical-html packages/lexical/src packages/lexical-clipboard Test Files 79 passed (79) Tests 1469 passed | 1 skipped (1470) $ npx vitest run packages/lexical-table packages/lexical-list packages/lexical-markdown packages/lexical-playground Test Files 40 passed (40) Tests 982 passed (982) ``` The real-world paste fixtures that carry `text-transform: none` (Slack, GitHub and Facebook payloads in `HTMLCopyAndPaste.test.ts`, `CodeBlock.test.ts`, `LexicalTableNode.test.tsx`) put it on block tags — `<p>`, `<ul>`, `<pre>`, `<table>` — not on the inline-format tags these converters handle, and they all still pass.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 01:28
|
@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. |
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
Closes #8915
TextNode.exportDOMwrites the three capitalization formats out as CSS:Nothing ever read
text-transformback.applyTextFormatFromStyle(the legacy<span>/<b>/<em>… converters) readsfontWeight,textDecoration,fontStyleandverticalAlign;readElementFormatStyle/styleFormatOverridein the@lexical/htmlrule pipeline read the same four.So
IS_LOWERCASE/IS_UPPERCASE/IS_CAPITALIZEwere written on export andsilently dropped on import — copy/paste between editors, and any
$generateHtmlFromNodes->$generateNodesFromDOMround trip, lost the formatwhile every other text format survived.
Read
text-transformin both importers, mirroring howvertical-alignisalready handled — including the mutual exclusion, since only one of the three
can apply. On the
@lexical/htmlside,text-transform: noneclears all three(the same "explicit non-decorating value clears the bit" rule that
font-weight: normalandvertical-align: baselinealready follow), andtext-transformjoinsFORMAT_BIT_STYLE_PROPSso the property is owned by theformat bit mask and does not also get materialized onto the node's inline
style.
Test plan
New
packages/lexical-html/src/__tests__/unit/Issue8915Repro.test.ts: for eachof the three formats, one export assertion (passes before and after — it is the
writer the readers are held to) plus a round trip through each of the two
import pipelines. A fourth case pins that an unrelated
text-transform: nonealongside
font-weight: boldneither sets a capitalization format nor disturbsthe bold one.
The test lives in its own
IssueNNNN Reprofile becauseLexicalTextNode.test.tsxis already being edited by #8924.Before
After
The real-world paste fixtures that carry
text-transform: none(Slack, GitHuband Facebook payloads in
HTMLCopyAndPaste.test.ts,CodeBlock.test.ts,LexicalTableNode.test.tsx) put it on block tags —<p>,<ul>,<pre>,<table>— not on the inline-format tags these converters handle, and they allstill pass.