Implementing a document-field

Hi All,

I’m looking for a way to implement an document-field entity.

  • I’d like to be able to get a live list of all fields ordered by current position.
  • I’d like to be able to access any field on demand
  • I’d like to store metadata for each field
  • fields added\removed events
  • selection entered-to\left-from field events
  • I’d like to be able to define a field across several document hierarchies. e.g., a field may start in the middle of a paragraph and end in the middle of another paragraph.

This could potentially be implemented using a new node schema, but it will require some nontrivial modeling to achieve the cross-hierarchy requirement. It will also require constant scanning of the entire document, which seems a bit too heavy.

I thought that the natural implementation for these requirements would be to use decorations. However, @marijn recently remarked that decorations are primarily meant to map and store view decorations, and I am trying to use them for much more.

Are decorations the wrong choice for my use case? Are there any better options?

Thanks!