Skip to content

[lexical][lexical-list] Feature: Add $setFormatFromDOM function and use it to import alignment for ListItem - #8460

Merged
etrepum merged 5 commits into
meta:mainfrom
levensta:import-alignment-li
May 5, 2026
Merged

etrepum merged 5 commits into
meta:mainfrom
levensta:import-alignment-li

Conversation

@levensta

@levensta levensta commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

A new util function $setFormatFromDOM has been added to the lexical and is used in all provided nodes to set format alignment during importDOM

Most elements provided by lexical set their alignment during HTML export and set the relevant format if alignment is present during importDOM. For list elements, alignment was lost importDOM; this PR fixes that

Closes #4243

Test plan

Before

Screen.Recording.2026-05-03.at.23.02.19.mov

After

Screen.Recording.2026-05-03.at.23.03.25.mov

@vercel

vercel Bot commented May 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 5, 2026 9:45am
lexical-playground Ready Ready Preview, Comment May 5, 2026 9:45am

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 May 3, 2026

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be good to introduce a $setFormatFromDOM helper here since this isn't the only place that does this check, also a unit test to confirm that it's doing the right thing (round-tripping alignment) would be good.

@levensta
levensta force-pushed the import-alignment-li branch from 63187ee to 4c5a211 Compare May 3, 2026 23:30
@levensta levensta changed the title [lexical-list] Feature: Import alignment for ListItem [lexical][lexical-list] Feature: Add $setFormatFromDOM function and use it to import alignment for ListItem May 3, 2026
@levensta

levensta commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

I added a couple of tests and also took into account the handling of inserting a list from Google Docs

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label May 5, 2026
@etrepum
etrepum added this pull request to the merge queue May 5, 2026
Merged via the queue into meta:main with commit e8930b4 May 5, 2026
42 checks passed
@etrepum etrepum mentioned this pull request May 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 3297cffd Deployed May 5, 2026 by vercel[bot]
Preview – lexical — 3297cffd Deployed May 5, 2026 by vercel[bot]
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: $generateHtmlFromNodes ignores alignment style in case of headings & lists

2 participants