Hierarchical Attributes Support

Hi all, we are doing a Scripting Editor, based on Prosemirror. In order to keep some metadata around the Semantic Nodes, we thought of saving those in ProseMirror Attributes. So my questions:

Q1: Is that the normal approach for saving metadata in the ProseMirror document model?

Q2: Do ProseMirror Attributes support hierarchical JSON structures? i.e.

heading: { content: “text*”, attrs: { level: {default: 1}, some_custom_array : [ {“ArrayKey1” : “MyArrayVal1”}, {“ArrayKey1”: “MyArrayVal2”}], some_nested_value : {“Key1”: {“NestedKey1” : “MyNesterVal1”}} } }

Yes, storing additional data in attributes is what they are for. Attribute values may be anything that’s JSON-serializeable (to make sure toJSON/fromJSON continue to work on the nodes).

Hi Marijn,

great! Thank you very much. We will use attributes, then, to store our metadata…

Hi Marijn,

we started using the Attrs with hierarchical json and it does work very nice! The PM engine is just great and a really nicely designed thing! We are inspired by it :slight_smile: