[lexical] Feature: ElementNode import/export support for data-lexical-indent#8536
Merged
etrepum merged 9 commits intoMay 21, 2026
Merged
Conversation
Adds failing tests that document setNodeIndentFromDOM's two failure modes:
parseInt cannot read the reconciler's `calc(N * var(--lexical-indent-base-value, 40px))`
inline style, and the hardcoded /40 divisor ignores a custom
`--lexical-indent-base-value`. The literal `${indent * 40}px` round-trip
that exportDOM produces still passes, so this test is added to document
the gap.
…k#7729) `setNodeIndentFromDOM` only recovered indent by dividing `padding-inline-start` by 40, which loses information whenever the inline style is the reconciler's `calc(N * var(--lexical-indent-base-value, 40px))` expression (live-DOM copy/paste) or uses a custom `--lexical-indent-base-value` whose pixel value doesn't divide cleanly by 40. Emit `data-lexical-indent="N"` from `ElementNode.exportDOM` whenever indent is non-zero, and prefer that attribute in `setNodeIndentFromDOM`. The padding-based heuristic remains as a fallback for HTML produced outside Lexical.
…facebook#7729 repro Switch Issue7729Repro.test.ts off the legacy `initializeUnitTest` harness and onto the modern `using editor = buildEditorFromExtensions(...)` pattern, and use `$insertGeneratedNodes` for the DOM import path instead of appending nodes to the root by hand.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- setUpEditor now declares RichTextExtension as a dependency of the test extension and takes the `$initialEditorState` as an argument, rather than composing it as a sibling root extension at every call site. - $importHtml is a pure `$` function and must be invoked inside `editor.update`, instead of opening its own update transaction. - Replace `ReturnType<typeof setUpEditor>` with an imported `LexicalEditor` type.
- $importHtml uses $getEditor and pastes with $selectAll(), so it replaces whatever was in the editor instead of requiring callers to root.clear() first. - Drop the editor argument from $importHtml — it's a $ function. - Replace `getFirstChildOrThrow<ParagraphNode>()` with `assert($isParagraphNode(para), ...)` so the type narrowing also doubles as an assertion that imports produced a ParagraphNode.
The tests only exercise the model and the HTML import/export paths, so the editor doesn't need to be mounted.
zurfyx
approved these changes
May 21, 2026
This was referenced May 27, 2026
Merged
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
Lexical currently only uses the padding-inline-start style to represent its indentation, but using it as a signal for the actual indentation is fragile if customized because it is based on display.
This changes the representation to use a data attribute on export so that the indentation can be reliably recovered on import regardless of CSS, with a fallback to the padding-inline-start heuristic.
Closes #7729
Test plan
New unit tests