Repository navigation
[lexical-react] Revert revert: Remove deprecated ContextMenu, consolidate menu rendering with backward-compatible menuRenderFn - #8199
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Playground Test ResultsTest 1: Slash Command Menu (
|
| Test | Result |
|---|---|
Slash commands (/) |
✅ PASS |
Emoji picker (:) |
✅ PASS |
| Emoji selection | ✅ PASS |
| Keyboard nav (ArrowDown) | ✅ PASS |
| Keyboard selection (Enter) | ✅ PASS |
| Escape dismissal | ✅ PASS |
Mentions (@) |
⏭️ Manual test needed |
| Context menu (right-click) | ⏭️ Pre-existing behavior, not a regression |
All 28 unit tests pass (pnpm run test-unit). Build, TypeScript, and lint all pass.
1b45c9a to
11350aa
Compare
Reapply "[lexical-react] [lexical-playground] Remove old ContextMenu, consolidate LexicalMenu render" (#7997) with backward compatibility: - Remove LexicalContextMenuPlugin (consolidated into LexicalNodeMenuPlugin) - Add default menu rendering in LexicalMenu when menuRenderFn is not provided - Make menuRenderFn optional on all plugin props for backward compatibility - Playground plugins use built-in default menu renderer instead of custom ones
Add 28 unit tests covering: - MenuOption class: key, ref, title, icon, setRefElement - MenuRenderFn type export validation - LexicalTypeaheadMenuPlugin export surface - LexicalNodeMenuPlugin export surface - Default menu rendering behavior
- MenuRenderFn: narrow matchingString from 'string | null' to 'string' (always called with empty string fallback, never null) - MenuOption: make title required 'string' (not optional, not JSX) for Flow invariant compatibility with www subclasses - MenuOption: remove icon from base class Flow type (www consumers use their own icon types like TintableIconSource, XDSSVGIconSource) - AutoEmbedOption: make title required, keep icon as React.MixedElement
708f6bc to
f39d079
Compare
|
I didn't do a super close look at the diff since an approval would trigger merge, do you want to look at this @ivailop7? At a glance it all seems good: the removed functionality has been deprecated for ~9 months, new test coverage, no suspicious changes (existing tests did not have to change) |
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
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page ## Description Depends on the changesets tooling in #9357. Past versions in CHANGELOG.md only list commits, so someone upgrading from an older version cannot find what broke, or how to migrate, without reading every GitHub release. Future versions get curated sections from changesets; this gives v0.23.0 to v0.52.0 the same sections. - Every version from v0.23.0 to v0.52.0 now starts with `### Breaking changes` (35 entries), `### Behavior changes` (43) and `### Deprecations` (29), each with packages and a PR link. The existing lines are kept, unchanged, under `### All changes` (the diff only adds lines). - Rule, stated in the preamble: a breaking change needs a code change (an API removed or renamed, a type that no longer checks, a call that now throws) and has `Detect:` and `Migration:`. A behavior change keeps building but behaves or renders differently and has `Verify:`. The entries come from a verified inventory of those releases, which marked each change as manual, mechanical, or runtime-only ("no type or build error points at it"). Runtime-only entries are behavior changes, except #7341 (now throws) and #8603 (a signature change), which stay breaking. - v0.50.0: the items its release notes list as "Behavior Changes to Watch" (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes; the listener return-type tightening (#8990), the new invariants (#6483) and the two items the release called breaking (#8938, #8995) stay breaking. Checked against the v0.50.0 release notes. - Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin` (#8199; present in the v0.41.0 tag, absent in v0.42.0). - Deprecations come from a pass over every `@deprecated` tag added between consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag and attributed with `git log -S`. Each has `Replacement:` and `Removal:`: the version that removed it, "no earlier than v0.53.0" for the ones #9316 removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`), and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed. - Entries that mixed a breaking change and a deprecation are split with no double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated aliases, so they are listed under Deprecations alone. - `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade all packages together, read CHANGELOG.md between your version and the target (also at `node_modules/lexical/CHANGELOG.md`) or print that range, and a copy-paste `AGENTS.md` snippet that points coding agents at the installed changelog. Nothing is installed automatically. - The repository CHANGELOG.md test checks every backfilled entry: `Detect:` and `Migration:` on breaking changes, `Verify:` on behavior changes, `Replacement:` and a valid `Removal:` on deprecations, a PR link on all. ## Test plan ### Before ``` $ pnpm run changelog:range -- --from 0.49.0 --breaking Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full. No breaking changes, behavior changes or deprecations recorded after 0.49.0. ``` ### After ``` $ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md 1412 0 CHANGELOG.md $ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### ' ## v0.50.0 (2026-09-02) ### Breaking changes ### Behavior changes ### Deprecations ## v0.51.0 (2026-09-17) ### Breaking changes ### Deprecations ## v0.52.0 (2026-09-27) ### Breaking changes ### Behavior changes ### Deprecations $ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])] $ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts Tests 63 passed (63) $ pnpm -C packages/lexical-website run docusaurus build [SUCCESS] Generated static files in "build". ```
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page ## Description Depends on the changesets tooling in #9357. Past versions in CHANGELOG.md only list commits, so someone upgrading from an older version cannot find what broke, or how to migrate, without reading every GitHub release. Future versions get curated sections from changesets; this gives v0.23.0 to v0.52.0 the same sections. - Every version from v0.23.0 to v0.52.0 now starts with `### Breaking changes` (35 entries), `### Behavior changes` (43) and `### Deprecations` (29), each with packages and a PR link. The existing lines are kept, unchanged, under `### All changes` (the diff only adds lines). - Rule, stated in the preamble: a breaking change needs a code change (an API removed or renamed, a type that no longer checks, a call that now throws) and has `Detect:` and `Migration:`. A behavior change keeps building but behaves or renders differently and has `Verify:`. The entries come from a verified inventory of those releases, which marked each change as manual, mechanical, or runtime-only ("no type or build error points at it"). Runtime-only entries are behavior changes, except #7341 (now throws) and #8603 (a signature change), which stay breaking. - v0.50.0: the items its release notes list as "Behavior Changes to Watch" (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes; the listener return-type tightening (#8990), the new invariants (#6483) and the two items the release called breaking (#8938, #8995) stay breaking. Checked against the v0.50.0 release notes. - Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin` (#8199; present in the v0.41.0 tag, absent in v0.42.0). - Deprecations come from a pass over every `@deprecated` tag added between consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag and attributed with `git log -S`. Each has `Replacement:` and `Removal:`: the version that removed it, "no earlier than v0.53.0" for the ones #9316 removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`), and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed. - Entries that mixed a breaking change and a deprecation are split with no double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated aliases, so they are listed under Deprecations alone. - `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade all packages together, read CHANGELOG.md between your version and the target (also at `node_modules/lexical/CHANGELOG.md`) or print that range, and a copy-paste `AGENTS.md` snippet that points coding agents at the installed changelog. Nothing is installed automatically. - The repository CHANGELOG.md test checks every backfilled entry: `Detect:` and `Migration:` on breaking changes, `Verify:` on behavior changes, `Replacement:` and a valid `Removal:` on deprecations, a PR link on all. ## Test plan ### Before ``` $ pnpm run changelog:range -- --from 0.49.0 --breaking Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full. No breaking changes, behavior changes or deprecations recorded after 0.49.0. ``` ### After ``` $ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md 1412 0 CHANGELOG.md $ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### ' ## v0.50.0 (2026-09-02) ### Breaking changes ### Behavior changes ### Deprecations ## v0.51.0 (2026-09-17) ### Breaking changes ### Deprecations ## v0.52.0 (2026-09-27) ### Breaking changes ### Behavior changes ### Deprecations $ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])] $ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts Tests 63 passed (63) $ pnpm -C packages/lexical-website run docusaurus build [SUCCESS] Generated static files in "build". ```
…havior changes and deprecations into CHANGELOG.md for v0.23 to v0.52, add an Upgrading page Depends on the changesets tooling in #9357. Past versions in CHANGELOG.md only list commits, so someone upgrading from an older version cannot find what broke, or how to migrate, without reading every GitHub release. Future versions get curated sections from changesets; this gives v0.23.0 to v0.52.0 the same sections. - Every version from v0.23.0 to v0.52.0 now starts with `### Breaking changes` (35 entries), `### Behavior changes` (43) and `### Deprecations` (29), each with packages and a PR link. The existing lines are kept, unchanged, under `### All changes` (the diff only adds lines). - Rule, stated in the preamble: a breaking change needs a code change (an API removed or renamed, a type that no longer checks, a call that now throws) and has `Detect:` and `Migration:`. A behavior change keeps building but behaves or renders differently and has `Verify:`. The entries come from a verified inventory of those releases, which marked each change as manual, mechanical, or runtime-only ("no type or build error points at it"). Runtime-only entries are behavior changes, except #7341 (now throws) and #8603 (a signature change), which stay breaking. - v0.50.0: the items its release notes list as "Behavior Changes to Watch" (#8765, #8908, #8884, #9059, #9061, #8940, #8283) are behavior changes; the listener return-type tightening (#8990), the new invariants (#6483) and the two items the release called breaking (#8938, #8995) stay breaking. Checked against the v0.50.0 release notes. - Added the v0.42.0 removal of `@lexical/react/LexicalContextMenuPlugin` (#8199; present in the v0.41.0 tag, absent in v0.42.0). - Deprecations come from a pass over every `@deprecated` tag added between consecutive tags v0.22.0 to v0.52.0, each checked against the previous tag and attributed with `git log -S`. Each has `Replacement:` and `Removal:`: the version that removed it, "no earlier than v0.53.0" for the ones #9316 removes after v0.52.0, otherwise "not scheduled". Skipped: tags that only moved (`trimTextContentFromAnchor`, deprecated before v0.23.0) or restated earlier ones (v0.46.0 `HorizontalRulePlugin`, v0.51.0 `getScrollParent`), and the v0.47.0 `applyFormatToDom` deprecation that v0.48.0 reversed. - Entries that mixed a breaking change and a deprecation are split with no double counting (#7357, #8360, #8661); #8350 and #8662 only deprecated aliases, so they are listed under Deprecations alone. - `docs/upgrading.md` ("Upgrading" in the sidebar) is a short page: upgrade all packages together, read CHANGELOG.md between your version and the target (also at `node_modules/lexical/CHANGELOG.md`) or print that range, and a copy-paste `AGENTS.md` snippet that points coding agents at the installed changelog. Nothing is installed automatically. - The repository CHANGELOG.md test checks every backfilled entry: `Detect:` and `Migration:` on breaking changes, `Verify:` on behavior changes, `Replacement:` and a valid `Removal:` on deprecations, a PR link on all. ``` $ pnpm run changelog:range -- --from 0.49.0 --breaking Note: v0.50.0, v0.51.0, v0.52.0 have no curated sections (the changelog only lists their commits), so --breaking cannot show what changed there. Run without --breaking to read them in full. No breaking changes, behavior changes or deprecations recorded after 0.49.0. ``` ``` $ git diff --numstat --diff-algorithm=patience HEAD~1 -- CHANGELOG.md 1412 0 CHANGELOG.md $ pnpm run changelog:range -- --from 0.49.0 --breaking | grep '^## \|^### ' $ pnpm run changelog:range -- --from 0.49.0 --to 0.50.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(8938, False), (8995, False), (8990, False), (6483, False)]), ('behavior', [(8765, True), (8908, True), (8884, True), (9059, True), (9061, True), (8940, True), (8283, True)]), ('deprecation', [(8918, False)])] $ pnpm run test-unit scripts/__tests__/unit/changelog.test.ts scripts/__tests__/unit/changesets.test.ts Tests 63 passed (63) $ pnpm -C packages/lexical-website run docusaurus build [SUCCESS] Generated static files in "build". ```
Summary
menuRenderFnis now optional onLexicalTypeaheadMenuPlugin,LexicalNodeMenuPlugin, andLexicalAutoEmbedPlugin. When omitted, a default consolidated renderer is used. Existing consumers passingmenuRenderFnare completely unaffected.LexicalContextMenuPlugin(LexicalNodeContextMenuPluginis the replacement since v0.32.0)MenuOptionclass now has optionaliconandtitleproperties for the default rendererMenuRenderFntype is re-exported from all plugin entry pointsPUNCTUATIONconstant kept for backward compatibilityBreaking Changes
LexicalContextMenuPluginis removed. UseLexicalNodeContextMenuPlugininstead (available since v0.32.0). See the playground ContextMenuPlugin for a migration example.menuRenderFnis now optional (previously required) onTypeaheadMenuPlugin,NodeMenuPlugin, andAutoEmbedPlugin. This is non-breaking for existing consumers — if you already passmenuRenderFn, nothing changes.Backward Compatibility
This PR was designed to be backward-compatible with existing consumers, including Meta's internal www codebase:
menuRenderFnwill continue to work unchanged — the prop is now optional, not removed.MenuRenderFntype remains exported from all entry points.PUNCTUATIONconstant is preserved.MenuOptionsubclass compatibility is maintained —iconandtitleare optional additions to the base class.LexicalContextMenuPlugin.menuRenderFnand are unaffected by this change.Test Plan
MenuOptionclass (key, ref, setRefElement, optional icon/title)MenuRenderFntype export validationLexicalMenudefault rendering (portal, items, selection, icon/title, empty state)LexicalMenucustom rendering viamenuRenderFn(selectedIndex, options, matchingString passthrough)LexicalTypeaheadMenuPluginwith and withoutmenuRenderFnLexicalNodeMenuPluginwith and withoutmenuRenderFnpnpm run ci-checkpasses (tsc, flow, prettier, lint)/) — menu renders with icons and titles, keyboard nav works, selection inserts node:) — menu renders with emoji icons + titles, selection inserts emoji