How I can attach attribute with dynamic value when new paragraph is inserted?

The recommended way to do this is to add an attribute with a default value of null to your paragraph node type, and register a plugin with an appendTransaction function that scans the document and assigns a new ID to each document with a duplicate or missing ID.

6 Likes