Access custom node attributes in Yjs Updates #814
Unanswered
carsonbird
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The context here is that I want to be able to listen for the creation of specific types of nodes from a Tiptap client, then access that node's custom attributes and use those to create a representation of that node in the database, separate from the storage of the Yjs doc itself.
So, I need to be able to access the custom attributes added to a node, like, for example, the uuid added to a node via the UniqueID Tiptap Pro extension (for in other cases as well).
I've been able figure out that I can listen for specific node creation events with the following code inside the Hocuspocus Server onChange hook:
Now, I can also see that when this "PARAGRAPH CREATED" is triggered, somewhere else in the
structs
array, there is astruct
that passes the following filters, which houses the respective attribute.However, I don't know how to correlate the creation of the "paragraph" node and this custom attribute, in the Yjs decoded update. Maybe it has something to do with the
parent
attribute in the Yjs struct, but I'm not sure. It's necessary to know because a client may create many of a type of node (like many paragraphs) at once, and I would need to know which custom attribute structs go with which created node.How does Tiptap/Hocuspocus/Yjs serialize the custom attributes on a node, and how can I listen for the creation of specific types of nodes, and access their attributes?
Beta Was this translation helpful? Give feedback.
All reactions