Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

Conversation

angelosilvestre
Copy link
Collaborator

[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 a targetNodeId (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?

…a non-selectable node at the end of the document (Resolves #2395)
@angelosilvestre
Copy link
Collaborator Author

@matthew-carroll Can you take a look to see if we should use this approach?

@miguelcmedeiros
Copy link
Collaborator

@angelosilvestre for our use case, when a non-selectable node is tapped it shouldn't create an empty paragraph beneath or move to the nearest available selection. The current behavior of doing nothing in this situation is just fine.

The request in #2395 is about what happens when the empty area in the editor below the content is tapped. In that ticket I mentioned what happens when the last node is a non-selectable node since it's the reason for the ticket in the first place, but if the last node is selectable, the request would be to still add an empty paragraph at the end. Unless there's already one, and in this case, just move the selection there.

@angelosilvestre
Copy link
Collaborator Author

@miguelcmedeiros I guess I read the ticket too quickly. I'll update the PR as soon as possible.

@angelosilvestre
Copy link
Collaborator Author

I'm closing this PR in favor of #2397, because the implementation is completely different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SuperEditor] - Add empty paragraph at the end of document when tapping on the empty area below it
2 participants