How to replace a node type with an incompatible node type?

Hi devs :man_technologist:

I have two nodes of this type:


  attrs: {
    level: {
      default: 1,
  content: 'inline*',
  group: 'block',
  parseDOM: [
    { tag: 'h1', attrs: { level: 1 } },    
    { tag: 'h2', attrs: { level: 2 } },
    { tag: 'h3', attrs: { level: 3 } },
    { tag: 'h4', attrs: { level: 4 } },
    { tag: 'h5', attrs: { level: 5 } },
    { tag: 'h6', attrs: { level: 6 } },

  toDOM(node) {
    return [
      'h' + node.attrs.level,


import { 
  listItem as listItemSchema, 
  orderedList as orderedListSchema, 
  bulletList as bulletListSchema,
} from 'prosemirror-schema-list';

const listItem = {
  content: 'paragraph block*',

const orderedList = {
  content: 'listItem+',
  group: 'block',

const bulletList = {
  content: 'listItem+',
  group: 'block',

My problem: I can’t change the heading type of node with the list type because their schemas are incompatible. I need to reset the type and then to make it the listItem type by wrapping it in some kind of sheet. What’s the best experience to solve this problem? How to reset the heading type and insert this in the list like the paragraph in one step? Is it possible? I’m afraid that in the future I’ll have many nodes, and I can’t manually interfere with every possible transformation, because there will be so many variations of them.

I don’t really understand what this means. Are you trying to do something like wrapInList?

I have a node with the heading type. I need to insert this node in, for example, the bulletList type. This type accepts only the listItem type but I have a node with the heading type. I need to replace the type of my node from heading to listItem and then insert this. Is it possible in one step? Replace the type and insert the node in list?

Now wrapInList returns false if I try to insert a node of the heading type in some list. It means that I must have a node with the paragraph type but I need to have this option, to have possibility to convert the header to a list item directly.

Transform.replace will do a lot of rewrapping and cleanup when given content that doesn’t fit at the given position. Maybe that already provides what you need here.