Snapshotting ProseMirror nodes with attributes

Hey,

so as I’m messing around with the snapshotting feature I noticed my node attributes are not persisted in the snapshot.

Use the @ symbol in the toolbar to toggle a “makeMeRed” attribute to either a paragraph or blockquote. I wonder what I’m doing wrong here. The code is basically the same as in the prosemirror-versions demo.

As I debugged this a little further, it seems that this line y-prosemirror/src/plugins/sync-plugin.js at master · yjs/y-prosemirror · GitHub retrieves the attributes but in my case nothing is returned. Ah, well to be exact when I’m using an object as an attribute it marks it as deleted and the YXmlElement getAttributes doesn’t return it (curiously it takes snapshot as a parameter but doesn’t use it).

I’ve added console.logs to yjs/y-prosemirror in the demo which shows ‘makeMeRed’ is retrieved but always the current value of the said node. I recall Kevin saying that snapshots are not finished so perhaps this is one of those parts? Having written all this, I’m pretty sure it’s about that snapshot parameter not being used to retrieve the current value of the node attribute?

(Also as a sidenote, it seems the renderSnapshot plays a bit weird with the paragraphs inside a blockquote)

Where able to shed anymore light on this issue? I am working with versioning with ProseMirror and have run into the same issue.

Not really. I guess I could open a bug issue but not sure exactly is this a yjs or y-prosemirror thing. Definitely would need this fixed at some point as I as well need those attributes shown. Somebody did take a stab at it Maybe a Bug in snapshots · Issue #82 · yjs/y-prosemirror · GitHub but their demo was a bit lackluster.

For anyone coming across this in the future, this was implemented in Nov 2023.

1 Like