Repository navigation
feat(richtext-lexical): upgrade lexical from 0.35.0 to 0.41.0 - #15760
Conversation
Bump all @lexical/* and lexical dependencies to 0.40.0 and update the lexicalTargetVersion constant.
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
…ith new specifications
| type: 'paragraph', | ||
| version: 1, | ||
| textFormat: 0, | ||
| textFormat: 16, |
There was a problem hiding this comment.
Lexical v0.39.0, via meta/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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
|
🚀 This is included in version v3.79.0 |
## Context ### BREAKING CHANGES: The only listed breaking changes are in payload 3.79.0. Two of them. >- rename widget ComponentPath to Component for consistency ([#15780](payloadcms/payload#15780)) ([f7d0d04](payloadcms/payload@f7d0d04) - Renames `Widget.ComponentPath` to `Widget.Component` and types it as PayloadComponent`instead of`string` - This aligns dashboard widgets with every other component reference in (collections, globals, fields, admin components) - none of them _path_ in the property name, and all of them are typed as `PayloadComponent` - Enables new [typescript plugin](payloadcms/payload#15779) to work for widget paths (the plugin uses `PayloadComponent` contextual type detection - `string`-typed properties were invisible to it) > - **ui:** typo in CodeEditor export statement ([#15795](payloadcms/payload#15795)) ([c5b2a91](payloadcms/payload@c5b2a91)) >**Lexical Upgrade 0.35.0 → 0.41.0 (richtext-lexical)** — Upgrades the Lexical rich text editor dependency from v0.35.0 to v0.41.0. Includes upstream fixes like `normalizeMarkdown` ([meta/lexical#7812](meta/lexical#7812)). All Lexical breaking changes are handled internally by Payload — no action required for standard usage. If you installed `lexical` manually, update it to 0.41.0 (though using the re-exported versions from `@payloadcms/richtext-lexical/lexical/*` is recommended). [#15760](payloadcms/payload#15760) ### Anaylsis of codebase vs breaking changes Project does not currently define any custom dashboard widgets in payload.config.ts, we are using the default payload dashboard. codebase already correctly imports Lexical types via @payloadcms/richtext-lexical/lexical (which is the recommended pattern) CodeEditor, we are not importing or using the CodeEditor component # Changes Made Downgraded `next`: 15.5.9 → 15.4.11 Upgraded `lucide-react`: 0.378.0 → ^0.471.0 (latest) Upgraded `baseline-browser-mapping` (latest) Remove `lexical` dependency ### Further analysis after upgrade using gemini #### 1. Payload CMS Compatibility Gap Payload CMS 3.x relies on internal Next.js routing behaviors that were altered in version 15.5. Staying on `15.5.9` introduced: - **Build Failures**: Next.js 15.5's new strict TypeScript route validation rejects Payload's auto-generated API route types (specifically the `RouteHandlerConfig`). - **Admin UI Slowness**: Documented performance regressions in 15.5 cause the Payload Admin panel to experience massive load-time spikes (reported jumps from 2s to 30s+). OLD dev tested by espdesign ` ✓ Compiled /admin/[[...segments]] in 5.5s (6831 modules)` NEW dev tested by espdesign ` ✓ Compiled /admin/[[...segments]] in 9s (7912 modules - **HMR Instability**: Turbopack HMR in 15.5 frequently fails to find client modules in the manifest, leading to frequent "Module not found" errors during development. **Result**: Reverting to **15.4.11** restores the "Stable Zone" for Payload 3.x, ensuring fast Admin UI performance and successful production builds. #### 2. React 19 Peer Conflict The previous version of `lucide-react` was hard-coded to expect React 18 or older. - **Fix**: Upgrading to the latest version of `lucide-react` adds official support for **React 19**, resolving the peer dependency warning. Further changes: ``` `[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline- browser-mapping@latest -D ``` ### Migrations: No :) ``` [22:04:26] INFO: Migration DOWN statements generation complete. ✔ No schema changes detected. Would you like to create a blank migration file? … no ``` ## Test Plan Confirm on staging. Confirm on dev. --------- Co-authored-by: tadjh <[email protected]>
…d upgrade to lexical 0.45 (#17064) ## Summary Payload vendored a full copy of `@lexical/markdown` because, before lexical `0.42`, the published package transitively pulled in `@lexical/code` + `prismjs`, which broke type generation. Lexical `0.42` switched to `@lexical/code-core` (no prism), so the fork is no longer needed. - **Upgrade to lexical `0.45.0`** (all `@lexical/*` from `0.41.0`), add `@lexical/[email protected]` as a dependency, and delete the vendored copy. - **Make `@payloadcms/richtext-lexical/lexical/markdown` a pure passthrough** (`export * from '@lexical/markdown'`), consistent with every other `@lexical/*` proxy. Payload's `normalizeMarkdown` preprocessing moves into an internal `$convertFromMarkdownString` helper, so the public export behaves the same. - **Deduplicate transformers that never diverged from upstream** (text-format, quote, list) so they import directly from `@lexical/markdown`, and reduce the heading transformer to `{ ...HEADING, regExp }` so it tracks upstream. - **Prefix the intentional divergences with `PAYLOAD_`** (`PAYLOAD_HEADING`, `PAYLOAD_LINK`, `PAYLOAD_UPLOAD`, `PAYLOAD_HORIZONTAL_RULE`, `PAYLOAD_TABLE`); they handle Payload-specific nodes with no upstream equivalent. - **Add ESLint rule `payload/no-conflicting-lexical-markdown-imports`** that flags Lexical's `CODE` / `LINK` / `HEADING` transformers, the default transformer groups, and convert/register calls that omit an explicit transformer list, since these silently conflict with Payload's features. ## Related Supersedes #13708. ## Payload API Breaking Changes ### 1. `$convertFromMarkdownString` no longer merges adjacent lines by default If you call it directly, pass `shouldMergeAdjacentLines: true` (5th arg) to keep the old behavior: ```diff - $convertFromMarkdownString(markdown, transformers) + $convertFromMarkdownString(markdown, transformers, undefined, false, true) ``` ### 2. Markdown transformer defaults now match upstream lexical (not Payload's features) The vendored fork shipped a curated `TRANSFORMERS` set (no `CODE`, no `LINK`). Both `@payloadcms/richtext-lexical/lexical/markdown` (now a pure passthrough) and the default argument to `$convertFromMarkdownString` exported from `@payloadcms/richtext-lexical` now use lexical's `TRANSFORMERS`, which bundles `CODE`, `LINK`, and `HEADING` transformers that conflict with Payload's features. You are affected if you either: - imported a group (`TRANSFORMERS`, `ELEMENT_TRANSFORMERS`, ...) from `@payloadcms/richtext-lexical/lexical/markdown`, or - called `$convertFromMarkdownString(markdown)` from `@payloadcms/richtext-lexical` without passing a transformer list. Switch to the converters, which build the list from your editor's enabled features: ```diff - import { $convertFromMarkdownString, TRANSFORMERS } from '@payloadcms/richtext-lexical/lexical/markdown' - $convertFromMarkdownString(markdown, TRANSFORMERS) + import { convertMarkdownToLexical } from '@payloadcms/richtext-lexical' + convertMarkdownToLexical({ editorConfig, markdown }) ``` If you keep calling `$convertFromMarkdownString` directly, pass `editorConfig.features.markdownTransformers` as the second argument. Enable `payload/no-conflicting-lexical-markdown-imports` (included in `@payloadcms/eslint-config`) to catch imports and calls that rely on these mismatching defaults. ## Lexical Breaking Changes This PR also bumps every `@lexical/*` package from `0.41.0` to `0.45.0`. The releases below contain breaking changes. We recommend reading them if you use Lexical APIs directly (`@payloadcms/richtext-lexical/lexical/*`). None of them require action for typical Payload usage. - [v0.45.0](https://github.com/facebook/lexical/releases/tag/v0.45.0) - `registerRichText` / `registerPlainText` now strip empty inline elements (`NormalizeInlineElementsExtension`) and the triple-click selection normalization moved into `NormalizeTripleClickSelectionExtension`. Editors that bypass `registerRichText` / `registerPlainText` must register these extensions to keep the old behavior. - Backspace at the start of a non-empty block now preserves the current block's type instead of merging it into the previous block. - Markdown shortcuts (`*`, `_`, `~`) now fire on IME composition commit (fixes dropped shortcuts for Japanese / Korean / Chinese input). - **Whitespace-only markdown table cells now import as an empty paragraph** instead of a text node of padding spaces. No migration needed unless you assert on those padding spaces. - [v0.44.0](https://github.com/facebook/lexical/releases/tag/v0.44.0) - The "press Enter three times to exit a code block" logic moved from `CodeNode` into `CodeExtension`; using `CodeNode` without `CodeExtension` is deprecated (backwards-compatible shim with a dev-mode warning). - `@lexical/offset` `OffsetView` is deprecated; import `$createChildrenArray` from `lexical` instead. - [v0.43.0](https://github.com/facebook/lexical/releases/tag/v0.43.0) - `@lexical/react` nested editors use asynchronous parent editor delegation to restore pre-`0.42.0` behavior. - [v0.42.0](https://github.com/facebook/lexical/releases/tag/v0.42.0) - Prism highlighting was extracted from `@lexical/code` into `@lexical/code-prism`, with a prism-free `@lexical/code-core`. This is the change that lets Payload drop its vendored `@lexical/markdown` fork. - Markdown import was aligned with CommonMark (trailing-space flanking rules, backslash handling, tabs converted to `TabNode`). The whitespace-only table cell change noted above originates from these markdown import changes. - Editor listeners (`registerUpdateListener`, root/editable listeners) may now return an unregister callback that Lexical calls on teardown. Returning a non-function value (e.g. an accidental Promise) throws `unregister is not a function`; Payload's toolbar listener was updated accordingly. ## Previous Lexical Upgrades - [#15760](#15760) — 0.35.0 → 0.41.0 - [#13715](#13715) — 0.34.0 → 0.35.0 - [#13622](#13622) — 0.28.0 → 0.34.0 - [#11764](#11764) — 0.27.2 → 0.28.0 - [#11564](#11564) — 0.21.0 → 0.27.1 ## Pending / Blocked - [ ] Delete `normalizeMarkdown` and the internal `$convertFromMarkdownString` helper once [meta/lexical#8734](meta/lexical#8734) (nested code fence fix) merges and we upgrade to a release that includes it. Both carry a matching `TODO`. --------- Co-authored-by: German Jablonski <[email protected]>
Upgrades `lexical` and every installed `@lexical/*` package from `0.48.0` to `0.50.0` for Payload 4.x (`main`). Updates the dependency pins, lockfile, `lexicalTargetVersion`, and v4 migration guide. ## Breaking changes **No application changes or data migration are needed when using Payload's built-in rich text features.** If you maintain custom rich text features, check that they still compile and that custom content loads, copies, and pastes correctly. Lexical tightened some TypeScript types and changed how custom nodes are loaded and copied. Tests that inspect the editor's HTML may also need updated selectors or snapshots because Lexical adds some internal markup. **Do not install `lexical` or `@lexical/*` yourself for use with Payload.** Remove any direct dependencies you added for the editor and use Payload's re-exports from `@payloadcms/richtext-lexical/lexical` and `@payloadcms/richtext-lexical/lexical/*`. Payload supplies the matching versions; mixing versions can break the editor. This is the existing [custom feature requirement](https://payloadcms.com/docs/rich-text/custom-features). ## Breaking changes and Payload migrations Reviewed [0.49.0](https://github.com/facebook/lexical/releases/tag/v0.49.0) and [0.50.0](https://github.com/facebook/lexical/releases/tag/v0.50.0). Listed below are breaking API/type changes and behavior changes explicitly identified as breaking in the release notes. Deprecations and routine bug fixes are omitted. **Yes** means we had to change Payload code; **No** means no Payload migration was required. | Release | Breaking change | Required migration in Payload | Changes made | | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | 0.49 | [Built-in nodes adopt `$config()`](meta/lexical#8640). Direct static `importJSON`, `importDOM`, `clone`, and `transform` implementations change; `__type` becomes readonly and automatic node construction needs zero-argument defaults. Custom static implementations remain supported. | No | - | | 0.49 | [`LexicalCommand<T>` checks its payload type more strictly](meta/lexical#8877). `LexicalCommand<unknown>` is no longer a safe catch-all. | Yes | Focus and blur commands were incorrectly registered with `MouseEvent`. Removed the explicit types so Lexical infers `FocusEvent`. | | 0.50 | [Named-slot values cannot be replaced with `LexicalNode.replace()`](meta/lexical#8938). Block converters also [skip slot values](meta/lexical#8905). | No | - | | 0.50 | [Lexical JSON clipboard copying checks `excludeFromCopy('clone')`, not `'html'`](meta/lexical#8995). | No | - | Also updated the copied table action menu for merged-cell bounds, header toggles, and merge/unmerge selection, and fixed the upload alignment test’s image selector. The nested toolbar wheel test now hovers each toolbar before scrolling; its assertions are unchanged. Both affected e2e tests pass locally in Chromium on TanStack. Formatting and diff checks pass. ## Previous Lexical upgrades - [#17554](#17554) — 0.45.0 → 0.48.0 - [#17064](#17064) — 0.41.0 → 0.45.0 - [#15760](#15760) — 0.35.0 → 0.41.0
Upgrades `lexical` and every installed `@lexical/*` package from `0.41.0` to `0.50.0` for Payload 3.x. Updates the dependency pins, lockfile, and `lexicalTargetVersion`. Also exposes the 15 React entry points added on main in [#17554](#17554) through `@payloadcms/richtext-lexical/lexical/react/*`, so custom features can use these APIs through Payload. ## Breaking changes **No application changes or data migration are needed when using Payload's built-in rich text features.** If you maintain custom rich text features, check that they still compile and that custom content loads, copies, and pastes correctly. Lexical removed some older APIs, tightened TypeScript types, and changed how custom nodes are loaded and copied. Tests that inspect the editor's HTML may also need updated selectors or snapshots because Lexical adds some internal markup. **Do not install `lexical` or `@lexical/*` yourself for use with Payload.** Remove any direct dependencies you added for the editor and use Payload's re-exports from `@payloadcms/richtext-lexical/lexical` and `@payloadcms/richtext-lexical/lexical/*`. Payload supplies the matching versions; mixing versions can break the editor. This is the existing [custom feature requirement](https://payloadcms.com/docs/rich-text/custom-features). The 3.x Markdown implementation and converter defaults are preserved. This does not backport the v4 Markdown API changes. ## Breaking changes and Payload migrations Reviewed [0.42.0](https://github.com/facebook/lexical/releases/tag/v0.42.0), [0.43.0](https://github.com/facebook/lexical/releases/tag/v0.43.0), [0.44.0](https://github.com/facebook/lexical/releases/tag/v0.44.0), [0.45.0](https://github.com/facebook/lexical/releases/tag/v0.45.0), [0.46.0](https://github.com/facebook/lexical/releases/tag/v0.46.0), [0.47.0](https://github.com/facebook/lexical/releases/tag/v0.47.0), [0.48.0](https://github.com/facebook/lexical/releases/tag/v0.48.0), [0.49.0](https://github.com/facebook/lexical/releases/tag/v0.49.0), [0.50.0](https://github.com/facebook/lexical/releases/tag/v0.50.0). Listed below are breaking API/type changes and behavior changes explicitly identified as breaking in the release notes. Deprecations and routine bug fixes are omitted. **Yes** means we had to change Payload code; **No** means no Payload migration was required. | Release | Breaking change | Required migration in Payload | Changes made | | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 0.42 | [Experimental `hasFitNestedTables` moves out of the table package into the playground](meta/lexical#8210). | No | - | | 0.42 | [The deprecated context-menu plugin is removed](meta/lexical#8199). | Yes | Removed the invalid `LexicalContextMenuPlugin` proxy and package export. Custom consumers must use `@payloadcms/richtext-lexical/lexical/react/LexicalNodeContextMenuPlugin` and adapt to its node-context-menu API. | | 0.43 | [Nested editors delegate asynchronously to their parent](meta/lexical#8308), restoring the behavior from before 0.42.0. | No | - | | 0.45 | [`$getReconciledDirection` now inherits direction through shadow-root nodes](meta/lexical#8479). | No | - | | 0.45 | [Backspace at the start of a non-empty block preserves the current block type and formatting](meta/lexical#8493). | No | - | | 0.45 | [Moving nodes between parents adjusts selection offsets](meta/lexical#8501). | No | - | | 0.45 | [Markdown shortcuts can trigger when IME composition commits](meta/lexical#8503). | No | - | | 0.45 | [Rich/plain text automatically removes empty inline elements](meta/lexical#8497). | No | - | | 0.45 | [Triple-click selection normalization moves from core into rich/plain text registration](meta/lexical#8520). Editors bypassing that registration must add `NormalizeTripleClickSelectionExtension`. | No | - | | 0.45 | [`DOMSlot` and the DOM rendering override APIs are generalized](meta/lexical#8519); playground `AutocompleteNode` is replaced by `VisibleLineBreakExtension`. | No | - | | 0.46 | [`static importJSON` widens its parameter to `SerializedLexicalNode & Record<string, unknown>`](#17554). Overrides using serialized interfaces can fail TypeScript checks. | No | - | | 0.46 | [Node lookups and traversal no longer infer unchecked subclass types](meta/lexical#8661). Explicit unchecked traversal generics are deprecated. | Yes | Removed the upload drawer’s assumption that a node lookup returns `UploadNode`. Added `$isUploadNode` before reading or updating upload data. | | 0.46 | [DOM lookups of the editor root return `RootNode` instead of `null`](meta/lexical#8588). Selection-capture handling is also generalized beyond decorators. | No | - | | 0.46 | [`insertNodes` preserves leading line breaks, and managed line breaks receive a DOM marker](meta/lexical#8615). | No | - | | 0.46 | [Experimental DOM-import rules register through node extensions](meta/lexical#8662); the separate per-package import extensions become deprecated aliases. | No | - | | 0.46 | [Experimental named slots change the Yjs sync signature](meta/lexical#8603): `syncLexicalUpdateToYjsV2__EXPERIMENTAL` gains a `dirtyLeaves` parameter. | No | - | | 0.46 | [Copying an element through `NodeSelection` includes its children](meta/lexical#8603), instead of copying an empty shell. | No | - | | 0.46 | [Previously deprecated exports are removed](meta/lexical#8704): `toggleLink`, `insertList`, `removeList`, and ContentEditable’s `Props` alias. Replacements are `$toggleLink`, `$insertList`, `$removeList`, and `ContentEditableProps`. | No | - | | 0.47 | [React 17 support is removed](meta/lexical#8782); React 18 or later is required. | No | - | | 0.47 | [Segmented text temporarily switches to normal mode during IME composition while keeping its DOM](meta/lexical#8784). Subclasses must tolerate that temporary mode. | No | - | | 0.49 | [Built-in nodes adopt `$config()`](meta/lexical#8640). Direct static `importJSON`, `importDOM`, `clone`, and `transform` implementations change; `__type` becomes readonly and automatic node construction needs zero-argument defaults. Custom static implementations remain supported. | No | - | | 0.49 | [`LexicalCommand<T>` checks its payload type more strictly](meta/lexical#8877). `LexicalCommand<unknown>` is no longer a safe catch-all. | Yes | Focus and blur commands were incorrectly registered with `MouseEvent`. Removed the explicit types so Lexical infers `FocusEvent`. | | 0.50 | [Named-slot values cannot be replaced with `LexicalNode.replace()`](meta/lexical#8938). Block converters also [skip slot values](meta/lexical#8905). | No | - | | 0.50 | [Lexical JSON clipboard copying checks `excludeFromCopy('clone')`, not `'html'`](meta/lexical#8995). | No | - | Also updated the copied table action menu for merged-cell bounds, header toggles, and merge/unmerge selection, and fixed the upload alignment test’s image selector. Formatting and diff checks pass for the upload selector fix. Verified all 15 new entry points through source and published export maps with runtime imports and TypeScript checks. ESLint and formatting checks pass. ## Previous Lexical upgrades - [#15760](#15760) — 0.35.0 → 0.41.0 - [#13715](#13715) — 0.34.0 → 0.35.0 - [#13622](#13622) — 0.28.0 → 0.34.0
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
normalizeMarkdownfix (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:
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/*).--lexical-indent-base-valueCSS custom property is now only read from the editor root element, not from indented elements. Payload already handles this change internally — no action required.ElementNodeJSON serialization:textFormatandtextStyleare now only serialized when necessary (when the node has no direct TextNode children). May affect code that reads these properties from serialized data.DecoratorNode.decorate()return type widened tonull | T. Collaboration context changes (not used by Payload).None of these breaking changes require action from Payload users under normal usage.
Changes
@lexical/*andlexicalfrom 0.35.0 to 0.41.0lexicalTargetVersionconstant--lexical-indent-base-valueCSS variable from.LexicalEditorTheme__indentto the.LexicalEditorThemeroot selector (v0.41.0 breaking change)textFormattest expectations for inline code paragraphs (v0.39.0 serialization change)Previous Lexical Upgrades