[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 cla@meta.com. 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.
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