WIP: [SuperEditor] Add the ability to add an empty paragraph when tapping a non-selectable node at the end of the document (Resolves #2395) #2396
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.
[SuperEditor] Add the ability to add an empty paragraph when tapping a non-selectable node at the end of the document .Resolves #2395
When tapping at a non-selectable node, the editor moves the selection to the nearest selectable node.
This PR adds the ability to add a new empty paragraph when the user taps at a non-selectable node at the end of the document.
This PR isn't complete. The goal is to decide if that's how we want to implement it. We talked about using a reaction for that, but this special handling of non-selectable nodes happens before issuing a selection change request. Also, checking if the node is selectable requires access to the document layout to get the component for the node. We don't have access to that in reactions.
This PR introduces a
SelectNearestSelectableNodeRequest
, that takes atargetNodeId
(the id of the non-selectable node that the user tapped), and the nearest selection.In the command, we can choose to add a new node if the node with
targetNodeId
is the last node of the document.Open question: How should we make this configurable? Create two commands, one that only changes the selection and other that adds an empty paragraph if the non-selectable node is the last in the document? Create a constructor parameter in
SelectNearestSelectableNodeCommand
to configure this? Another option?