Copying and Pasting Defining Nodes

I have a basic checklist implementation, but when I copy and paste elements the attributes aren’t coming along, and I’m not completely sure why. Here’s my rough implementation:

    check_item: {                                           
      attrs: {                                              
        checked: { default: false }                         
      },                                                    
      defining: true,                                       
      draggable: true,                                      
      parseDOM: [{ tag: "div.checkItem" }],                 
      content: "paragraph block*",                          
      toDOM: node => {                                      
        const classes = ["checkItem"];                      
        if (node.attrs.checked) {                           
          classes.push("checked");                          
        }                                                   
        return ["div", { class: classes.join(" ") }, 0];    
      }                                                     
    }                                                                                                        

My understanding was that parseDOM would be used to handle the attributes, but while testing getAttrs was never called when copying and pasting. Has anyone seen issues like this?

To clarify a tiny bit, after a bit more testing. If I add a getAttrs function to parseDOM and Ctrl-Click so that I end up selecting the check item, rather than the inner paragraph, I see a call to getAttrs. If I only select the inner paragraph, though, I don’t see a call to getAttrs and end up with no attributes for that defining node carrying over to the pasted copy.

The clipboard code was, by accident I believe, not serializing attributes for ‘context’ nodes if the nodes have to required attributes. This patch should address that.

Awesome, thank you @marijn. I wasn’t sure if the way it was working was intended or not.

I just installed the updated version and tested, and attributes are definitely copying now.