Switch between block types

Hello friends, I love prosemirror.

I would like to have a button in the tooltip that changes the block type similar to the photo: 5HU9bjKpOg

The problem: I can’t find a method to switch from a list type block to other blocks and vice versa, I understand that the problem is that lists can be nested.

Question: How can I deal with the problem?


  • An alternative would be that when a user chooses the target block type, the application could change the current block type to a paragraph block (removing the indentations and others blocks types like h2), of the actual selection and then change to the block type the user chose. Is there a method to remove all indentations from a list? or How can I detect the number of indentations, to apply sinkListItem “n” times?
  • I see that tiptap can switch block types if the blocks in the selection are of the same type

Thanks for the attention

One thing to note is that the structure after the arrow in your first scenario is not possible in ProseMirror – lists are not just series of paragraphs with indentation, they are actual parent nodes for those paragraphs. So you can’t have a level 2 list without it having a top-level list as a parent.

But moving things out of lists is generally done with the liftListItem command or by building up a custom transaction using the lift method on the transaction.