ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.59k stars 335 forks source link

After deletion of expanded selection in list, list items remain and cannot be removed #1383

Closed Nantris closed 1 year ago

Nantris commented 1 year ago

It's possible to reproduce this issue with the example editor, starting with an initial state like this:

image

https://github.com/ProseMirror/prosemirror/assets/6835891/29ec9f3e-bd80-453c-88f9-fd0f37648c27

marijnh commented 1 year ago

What would you expect the editor to do in this case? The list item still has another child, so it can't be deleted. The paragraph also can't be removed, since it would violate the schema constraints on what a list item can hold.

Nantris commented 1 year ago

Thanks for your reply @marijnh. The most common behavior I've seen for editors in these cases is to lift the lists beneath the deleted list items up to the top level, or to the level where the selection started if it's not the top of the list.

But I guess that can't be achieved via a single transaction on a single node which may be against the ProseMirror way of doing things?

I noticed a number of odd behaviors and I wonder which of them are intentional design choices and which of them are bugs.

marijnh commented 1 year ago

The command that runs here (joinBackwards) knows nothing about lists or specific schemas and acts on arbitrary node structures in arbitrary schemas. As such, there's no hard-coded list logic in it and performing the behavior you are expecting (which doesn't sound all that obvious) is beyond it.