Backspace after list

I’ve been reading with interest the post from back in 2015 where the basics ideas of finding a happy balance between familiar WYSIWYG expectations, and principled, schema-agnostic structured editing, were hashed out. The result is a really great achievement. There is a lot more to ProseMirror than meets the eye:

There is one place where the current behaviour, while perhaps logical, feels counterintuitive to me (| is the caret):

  * Hello
  |World

Hit backspace. I’d expect:

* Hello|World

But I get:

* Hello
* |World

Later in that thread, @marijn mentions “I’ve come to realize that having ‘auto splitting list items’ actually doesn’t interfere with the behavior I defined in any problematic way.” - Backspace and Enter (and Delete, I guess) - #11 by marijn

If I’m following correctly, this insight allowed the more familiar single enter to create a new list item, rather than two presses of enter. I’m wondering if there could also be “auto joining list items” to get the more familiar behaviour indicated above. There is a nice symmetry in that, with auto-splitting list items, a single backspace gets you the non-auto-splitting behaviour, while with auto-joining, a single enter would do the same.

Has such a thing been considered?

Any advice on attempting an implementation?

(I have a related question, where backspacing a blank paragraph between two of my custom block types is problematic, because they join together. Imagine a block type rendered with a border, such that, unlike bullet lists, it makes sense to have two adjacent to each other while retaining there separateness. I’ll save that for another post but I think the issue is closely related so I thought I’d mention it)

Thanks!

Implementing custom key behavior is generally done by defining a command function that first checks whether the situation you want to override applies, and if so performs the desired action and returns true, and binding that to the appropriate key with a higher precedence than the other handlers.

Automatically joining surrounding blocks when a paragraph between them is deleted is done because for things like lists and blockquotes people tend to expect it. It might make sense to have a node spec property that disables it—I’d be open to a pull request that adds that.

Do I take it that you don’t think auto-joining list items is a good idea? For the default behaviour I mean.

I’ll have a look into the PR you suggest.

I don’t entirely remember what reasoning the default joining behavior is based on, but that should definitely not change except when explicitly opted out of.

From the contributing guide:

If you want to make a change that … introduces a user-visible new feature, create an RFC first with your proposal.

Given you’ve proposed the PR in the first place, I wasn’t sure if I should do that or not.

This looks to be a pretty small change BTW unless I’m missing something (entirely likely!). Here’s my starting point:

No, this would be small enough to not bother with an RFC. What kind of nodes do you need this for, by the way? Would isolating maybe be applicable to them?

I don’t think so. I tried that first. I still want the double-enter behaviour to break out of the block, and I want to be able to backspace at the very start of the block, in some circumstances.

Makes sense.

I don’t think just completely turning off the deleteBarrier behavior is the way to go here, though—just the part that joins otherwise unaffected nodes after you delete an empty block.

Made the mistake of mixing two topics in one thread, so I’d just like to retrieve the original question. If I have…

  * Hello
  |World

…and I hit backspace. I’d expect

* Hello|World

but I get:

* Hello
* |World

Is this what you were referring to that “should definitely not change”. If so, can I respectfully ask why? It is very unusual behaviour.

It’s often useful to be able to move blocks into adjacent parent blocks. The way joinBackward is defined is that it’ll move the content after the cursor across one node boundary before the cursor, which, if a nested block node starts there, means moving into that.