transformPasted 's result ignored?

I’m trying to transform a slice that’s being pasted by modifying the node type, but that seems to be ignored.

Does the following make sense or am I using this incorrectly?

      new Plugin({
	props: {
          transformPasted(slice) {
            const result = new Slice(
              slice.content,
              slice.openStart,
              slice.openEnd
            )
            // Is this how I should be transforming the slice to change its node type?
            result.content.firstChild.type = schema.nodes.heading;
            return result;
          }
	}
      }),

Based on this description “Fired when something is pasted or dragged into the editor. The given slice represents the pasted content, and your handler can return a modified version to manipulate it before it is inserted into the document.”, it doesn’t seem like I need to mutate the state via a Transform, right?

The nodes should not be mutated so try using node.copy(...)

You should be able to find examples around the web or here on this forum. If not, I can help more.

Yeah, I bet that’s the problem. I tried a few variations based on some answers below:

but still don’t am not getting this quite right:

          transformPasted(slice) {
            const content = slice.content.textBetween(1, slice.content.size);
            const nodes = slice.content.content.map((node, i) => i > 0 ? node : schema.nodes.heading.create({
	      ...node.attrs, copyPasteData: undefined
            }, node.content));

            const result = new Slice(
              Fragment.fromArray(nodes),
              slice.openStart,
              slice.openEnd
            )

            return result;
          }

Any thoughts on what might be going wrong?