Unique id for each mark?


#1

I defined my own mark type with an attribute called “markId”. Every time that I create such a mark with schema.marks.mytag.create(), I pass a new, unique markId as a value (unique = unique within the same document).

However, this does not work when I set two of my marks onto the same piece of text. (The MarkSpec is defined as exclusive:’’ so that this is possible.)

What happens is this: PM splits my mark into two marks with identical attributes, i.e. the markId is not unique any more.

What can I do to make sure that those markIds are really unique, i.e. there are never two marks with the same value for markId inside the same document?


#2

That’s how marks work—they add metadata to a piece of content, but their extent isn’t significant, and they will be applied to each separate node in that piece of content. Trying to use them differently is probably not going to go well.