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

Can't delete a text node at the top of a document above a block node #484

Closed
ericandrewlewis opened this issue Nov 2, 2016 · 7 comments
Closed

Comments

@ericandrewlewis
Copy link
Collaborator

ericandrewlewis commented Nov 2, 2016

If a document begins with a text node above a block node, it's hard to delete the text node.

eg. pressing forward-delete while the selection is in the text node results in the block node below being deleted. Pressing delete in the text node does nothing. Pressing delete with the block node selected deletes the block node.

Here's an awkward screen recording showing the behavior:

1

@marijnh
Copy link
Member

marijnh commented Nov 2, 2016

You can do esc/ctrl-click to select the textblock, and then delete it, but I agree that's not terribly obvious. Do you have any suggestions of what might be obvious ways to do this?

@ericandrewlewis
Copy link
Collaborator Author

I think when a text block is empty, a forward-delete could delete the text block itself rather than the block after it. What do you think?

@marijnh
Copy link
Member

marijnh commented Nov 3, 2016

But then how would people go about deleting the block node? When it's a leaf node, it is automatically selected when you arrow onto it, so that wouldn't be too hard, but if it's, for example, a table (see this issue), you'll need to be able to delete it from the outside somehow.

@marijnh
Copy link
Member

marijnh commented Nov 10, 2016

Does having backspace in such a node (and, conversely, delete in an empty textblock at the bottom of the document) delete this node seem like a workable idea? It might not be the very first thing people try, but it is relatively close at hand, and that is an action that does not currently have any meaning, so it won't conflict with another piece of functionality.

@kiejo
Copy link
Contributor

kiejo commented Nov 11, 2016

I think when a text block is empty, a forward-delete could delete the text block itself rather than the block after it.

I agree. This is what I have implemented for our editor and it works really well when the empty paragraph is followed by block node types like lists, blockquotes, tables, or code blocks.
In my daily usage I have noticed that in these cases I almost never want to join the block node into the empty paragraph nor do I want to delete the block node below.

But then how would people go about deleting the block node?

I think that for lists, blockquotes, tables, and code blocks the most obvious thing for the user to do is to select the content of the block node and to press backspace/delete. After this first step they end up with an empty block node (e.g. empty code block) and they can then press backspace again to delete the whole node. This is currently working well for lists, blockquotes, and code blocks.
For tables this does not work yet, so I would suggest two possible solutions:

  1. Mimic the behavior of the other block types: Pressing backspace in the first cell of a table, which has a single row only containing empty cells, should delete the whole table node.
  2. Selecting the whole content of a table and pressing backspace/delete should directly delete the whole table node.

When it's a leaf node, it is automatically selected when you arrow onto it, so that wouldn't be too hard

I like this behavior and it works well for our use cases.

Does having backspace in such a node (and, conversely, delete in an empty textblock at the bottom of the document) delete this node seem like a workable idea?

I would only have backspace delete such a node if it is completely empty as I would expect the user to first select and delete all content of the node if he wants to delete the whole node.

@marijnh
Copy link
Member

marijnh commented Nov 11, 2016

I would only have backspace delete such a node if it is completely empty

Yes, of course, only when empty.

@marijnh
Copy link
Member

marijnh commented Nov 30, 2016

The behavior I introduced isn't ideal either (see #498), so I've reverted it.

Searching around shows that other WYSIWYG editors have a similar problem (apparently, in Google Docs, it is flat out impossible to delete a paragraph above a table). We do have node-select-and-delete as a relatively straightforward solution. If you feel that is too obscure, you can add an extra control to your app, or you can propose a specific other solution. I'm closing this until a new proposal comes up.

@marijnh marijnh closed this as completed Nov 30, 2016
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

No branches or pull requests

3 participants