Repository navigation
refactor(richtext-lexical): upgrade lexical to 0.50.0 (3.x) - #18148
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
| const [anchorCell, , table] = $getNodeTriplet(selection.anchor) | ||
| const [focusCell] = $getNodeTriplet(selection.focus) | ||
| const [map, anchor, focus] = $computeTableMap(table, anchorCell, focusCell) | ||
| const { maxColumn, maxRow, minColumn, minRow } = $computeTableCellRectBoundary(map, anchor, focus) |
There was a problem hiding this comment.
Adapted from Lexical #8853: count the full selection bounds, including intersecting merged cells.
| const currentSelectionCounts = $computeSelectionCount({ selection }) | ||
| updateSelectionCounts(currentSelectionCounts) | ||
|
|
||
| const isCollapsedTableSelection = selection.anchor.is(selection.focus) |
There was a problem hiding this comment.
Merge guard and the unmerge selection cleanup below copied from Lexical #8200.
| } | ||
| const rowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) | ||
| const isHeader = !tableCellNode.hasHeaderState(TableCellHeaderStates.ROW) | ||
| $setTableRowIsHeader(tableNode, rowIndex, isHeader) |
There was a problem hiding this comment.
Row/column header toggles adapted from Lexical #8815, using the upstream helpers.
| } | ||
| } | ||
| // Merged cells can make the grid column differ from the cell's index in its row. | ||
| const [, cellMap] = $computeTableMap(tableNode, tableCellNode, tableCellNode) |
There was a problem hiding this comment.
Copied from Lexical #9054: use the grid column so preceding merged cells do not shift the header toggle.
| @@ -1 +0,0 @@ | |||
| export * from '@lexical/react/LexicalContextMenuPlugin' | |||
|
🚀 This is included in version v3.90.0 |
Upgrades
lexicaland every installed@lexical/*package from0.41.0to0.50.0for Payload 3.x. Updates the dependency pins, lockfile, andlexicalTargetVersion.Also exposes the 15 React entry points added on main in #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
lexicalor@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/lexicaland@payloadcms/richtext-lexical/lexical/*. Payload supplies the matching versions; mixing versions can break the editor. This is the existing custom feature requirement.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, 0.43.0, 0.44.0, 0.45.0, 0.46.0, 0.47.0, 0.48.0, 0.49.0, 0.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.
hasFitNestedTablesmoves out of the table package into the playground.LexicalContextMenuPluginproxy and package export. Custom consumers must use@payloadcms/richtext-lexical/lexical/react/LexicalNodeContextMenuPluginand adapt to its node-context-menu API.$getReconciledDirectionnow inherits direction through shadow-root nodes.NormalizeTripleClickSelectionExtension.DOMSlotand the DOM rendering override APIs are generalized; playgroundAutocompleteNodeis replaced byVisibleLineBreakExtension.static importJSONwidens its parameter toSerializedLexicalNode & Record<string, unknown>. Overrides using serialized interfaces can fail TypeScript checks.UploadNode. Added$isUploadNodebefore reading or updating upload data.RootNodeinstead ofnull. Selection-capture handling is also generalized beyond decorators.insertNodespreserves leading line breaks, and managed line breaks receive a DOM marker.syncLexicalUpdateToYjsV2__EXPERIMENTALgains adirtyLeavesparameter.NodeSelectionincludes its children, instead of copying an empty shell.toggleLink,insertList,removeList, and ContentEditable’sPropsalias. Replacements are$toggleLink,$insertList,$removeList, andContentEditableProps.$config(). Direct staticimportJSON,importDOM,clone, andtransformimplementations change;__typebecomes readonly and automatic node construction needs zero-argument defaults. Custom static implementations remain supported.LexicalCommand<T>checks its payload type more strictly.LexicalCommand<unknown>is no longer a safe catch-all.MouseEvent. Removed the explicit types so Lexical infersFocusEvent.LexicalNode.replace(). Block converters also skip slot values.excludeFromCopy('clone'), not'html'.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