Skip to content

feat(richtext-lexical): upgrade lexical from 0.35.0 to 0.41.0#15760

Open
GermanJablo wants to merge 4 commits intomainfrom
feat-upgrade-lexical-0.40.0
Open

feat(richtext-lexical): upgrade lexical from 0.35.0 to 0.41.0#15760
GermanJablo wants to merge 4 commits intomainfrom
feat-upgrade-lexical-0.40.0

Conversation

@GermanJablo
Copy link
Contributor

@GermanJablo GermanJablo commented Feb 25, 2026

Summary

Upgrades the lexical dependency from 0.35.0 to 0.41.0.

Keeping up with Lexical releases avoids accumulating too large a gap, which makes future upgrades risky and time-consuming. This upgrade also brings in the upstream normalizeMarkdown fix (facebook/lexical#7812), which means we can eventually drop our vendored copy of that function.

If you installed lexical manually, update it to 0.41.0. Installing lexical manually is not recommended, as it may break between updates, and our re-exported versions should be used. See the yellow banner box for details.

If you still encounter richtext-lexical errors, do the following, in this order:

  • Delete node_modules
  • Delete your lockfile (e.g. pnpm-lock.json)
  • Reinstall your dependencies (e.g. pnpm install)

Lexical Breaking Changes

The following Lexical releases contain breaking changes. We recommend reading them if you're using Lexical APIs directly (@payloadcms/richtext-lexical/lexical/*).

  • v0.41.0--lexical-indent-base-value CSS custom property is now only read from the editor root element, not from indented elements. Payload already handles this change internally — no action required.
  • v0.39.0ElementNode JSON serialization: textFormat and textStyle are now only serialized when necessary (when the node has no direct TextNode children). May affect code that reads these properties from serialized data.
  • v0.38.0 — Static transforms from superclasses are now always applied. Table selection handler priorities lowered from CRITICAL to HIGH.
  • v0.36.1DecoratorNode.decorate() return type widened to null | T. Collaboration context changes (not used by Payload).

None of these breaking changes require action from Payload users under normal usage.

Changes

  • Bump all @lexical/* and lexical from 0.35.0 to 0.41.0
  • Update lexicalTargetVersion constant
  • Move --lexical-indent-base-value CSS variable from .LexicalEditorTheme__indent to the .LexicalEditorTheme root selector (v0.41.0 breaking change)
  • Update textFormat test expectations for inline code paragraphs (v0.39.0 serialization change)
  • Update pnpm-lock.yaml

Previous Lexical Upgrades

Bump all @lexical/* and lexical dependencies to 0.40.0 and update
the lexicalTargetVersion constant.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

type: 'paragraph',
version: 1,
textFormat: 0,
textFormat: 16,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lexical v0.39.0, via facebook/lexical#7971, changed how ElementNode serializes textFormat and textStyle to JSON.
Now, Lexical computes textFormat from the children's format, so a paragraph containing only inline code text (format: 16) will have textFormat: 16 instead of 0. The property is also omitted entirely when it's not needed (e.g., when the element has direct TextNode children that already carry the format).
The inline code rendering is identical; only the serialized metadata on the parent paragraph changed.

Copy link
Member

Choose a reason for hiding this comment

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

The property is also omitted entirely when it's not needed (e.g., when the element has direct TextNode children that already carry the format)

Isn't this the case here, and we should be able to remove the textFormat property here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. The test is asking for it.
It seems the paragraph gets its formatting from its children in cases like this.

Move --lexical-indent-base-value CSS variable from indent class to
editor root element per v0.41.0 breaking change (#8132).
@GermanJablo GermanJablo changed the title feat(richtext-lexical): upgrade lexical from 0.35.0 to 0.40.0 feat(richtext-lexical): upgrade lexical from 0.35.0 to 0.41.0 Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants