# Copying and Pasting Defining Nodes

**URL:** <https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203>\
**Category:** Uncategorized\
**Created:** [October 8, 2020, 5:44pm UTC](https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203 "2020-10-08T17:44:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nalanj](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/nalanj/32/1749_2.png) [@nalanj](https://discuss.prosemirror.net/u/nalanj)\
**Post date:** [October 8, 2020, 5:44pm UTC](https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203/1 "2020-10-08T17:44:28Z")

</div>

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:

```auto
    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?

---

<div class="post-metadata">

**Author:** ![nalanj](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/nalanj/32/1749_2.png) [@nalanj](https://discuss.prosemirror.net/u/nalanj)\
**Post date:** [October 8, 2020, 6:06pm UTC](https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203/2 "2020-10-08T18:06:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 26, 2020, 2:30pm UTC](https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203/3 "2020-10-26T14:30:32Z")

</div>

The clipboard code was, by accident I believe, not serializing attributes for ‘context’ nodes if the nodes have to required attributes. [This patch](https://github.com/ProseMirror/prosemirror-view/commit/1f59119350349a240fc78db4aa1d19d0d0c68530) should address that.

---

<div class="post-metadata">

**Author:** ![nalanj](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/nalanj/32/1749_2.png) [@nalanj](https://discuss.prosemirror.net/u/nalanj)\
**Post date:** [October 26, 2020, 2:43pm UTC](https://discuss.prosemirror.net/t/copying-and-pasting-defining-nodes/3203/4 "2020-10-26T14:43:36Z")

</div>

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.
