[Breaking Change][lexical][lexical-playground] Feature: Add a default delete handler for NodeSelection #7323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking Change
If you have any
$onDelete
handlers copied from the playground forKEY_DELETE_COMMAND
andKEY_BACKSPACE_COMMAND
, you can delete them all now. If you leave them in, it will have similar bugs as prior to this PR.The default
KEY_DELETE_COMMAND
andKEY_BACKSPACE_COMMAND
handlers now preventDefault and callDELETE_CHARACTER_COMMAND
for NodeSelection (in addition to the existing RangeSelection behavior).The
DELETE_CHARACTER_COMMAND
handler now handles NodeSelection by calling the newNodeSelection.deleteNodes()
method which places a new RangeSelection where the first selected node was (if any, and if it was the current selection) and then removes all of the selected nodes.Description
NodeSelection has no default handler for when the delete or backspace keys are pressed. This results in having every individual decorator node plugin register the same handler to incorrectly deal with this situation.
By centralizing the handler to a default location we can fix up the selection after a delete and remove a bunch of boilerplate code (while still having the option to override this behavior in the same way).
Closes #7319
Test plan
New e2e regression tests added to catch this specific behavior