Repository navigation
[Breaking Change][lexical-code] Bug Fix: move code block escape logic to KEY_ENTER_COMMAND listener - #8360
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @anikakpillai! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
etrepum
left a comment
There was a problem hiding this comment.
Generally speaking it's better if PRs add tests to demonstrate that they work as intended
|
Thanks for the review! I've updated the approach per your original suggestion on the issue. The escape logic is now moved out of |
etrepum
left a comment
There was a problem hiding this comment.
Your latest changes fail integrity checks (looks like type errors) and existing end-to-end tests
92bc514 to
79bf189
Compare
etrepum
left a comment
There was a problem hiding this comment.
This looks good, but I think we will have to think about the compatibility scenarios here since it is a breaking change, if you are using CodeNode in a legacy app that is not using CodeExtension then you will lose the functionality to exit the CodeNode by pressing return three times.
…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". ```
Breaking Changes
The "press enter three times to exit the CodeNode" logic has been moved from
CodeNode.insertNewAfterto aKEY_ENTER_COMMANDlistener registered byCodeExtension.Using
CodeNodewithoutCodeExtensionis now deprecated to allow this functionality to be moved to a command listener. There is a shim in the implementation that will provide backwards compatible behavior and log a warning (in dev) when this scenario is encountered, but you should expect that the node will eventually stop working correctly in a future version if your editor usesCodeNodewithoutCodeExtension.Description
When pasting text containing consecutive blank lines into a code block,
content after the blank lines incorrectly escapes the code block and
appears as top-level paragraphs.
The root cause was that the escape-to-paragraph logic in
CodeNode.insertNewAfterran on all content changes, including paste.Per maintainer feedback, this fix takes the preferred approach of moving
the escape logic out of
insertNewAfterentirely and into aKEY_ENTER_COMMANDlistener registered inCodeExtension. This ensuresthe escape behavior only triggers on keyboard input, not paste or other
programmatic changes.
Closes #8351
Test plan
Before
Paste text with consecutive blank lines into a code block — content
after the blank lines escapes to a top-level paragraph.
After
still correctly exits to a new paragraph
no escape with single blank line, no escape when cursor is not at end