I would like to give users a function to change the counter-style of the document’s headings.
My documents are fairly long and use an industry-specific style of numbering headings (A., I., 1., …). Some users would like to change that, e.g. to (I., 1., a), …).
I wonder though how to store and render such configuration. I can see two different approaches:
- Store the global data in the document’s
attrs
. - Store the data for each individual heading in the heading’s
attrs
.
The first approach requires storing data in the doc
node which seems possible, but not encouraged. The next problem then would be to access that data when rendering the nodes. If I am not mistaken, doc
is not available to NodeSpec.toDOM()
With the second approach the data would be available via node.attrs
but storing the information in every heading when storing it once would be enough seems suboptimal. Also, changing a counter-style would require a transaction on every node which seems equally bad.
I also looked into Plugins, but I don’t see how one could be designed to augment the toDOM
method.
What would be a suitable approach?