Dynamic mark types

We are trying to implement collaborative highlighting (and annotations) on top of ProseMirror. Our current approach is to use one mark in our schema for highlights and we use it to mark characters the user has selected and attach an ID to that mark as a mark attribute. This works great until there are highlights which overlap. The question what to do then.

Our current approach is that we store in the mark attributes the list of IDs under that mark. So two partially overlapping highlights would be stored as three marks: one with just the first ID (of the first highlight), then one with two IDs (of both highlights), and then again one with just one ID (the second highlight). But the issue is that it seems tricky to implement this cutting of marks in a way that would work well in collaborative context where things are happening in parallel, but those mark cutting and replacing with combined mark has to be done in multiple steps, so it adds complexity.

One solution I see to this would be that we would have one mark type per highlight. For example, I would have a mark-<ID> mark type, and then each mark type would be used for one highlight. After this, all existing ProseMirror logic to maintain this mark would automatically work out.

But it seems this is not possible? Schema can define only a predefined set of mark types, with static names, and only _ wildcard, and not something like mark-_.

Have you seen the excludes option on mark specs? I think if you just set them to not exclude themselves, things should work as you hope.

Ohh. So simple. Thanks.