At first, because comment is not part of the doc, my plan is record selection range when comment and mapping them when transaction applied.
Then i found that because every mutation to the doc was map to ReplaceStep, when change node attrs, the mapping will behave as remove all its children and reinsert it. It looks like need something like SetAttrsStep to describe it, which can avoid position lose.
Or I can use mark as a replacement to record associaton between entity and doc. Marks on the doc wont lose ( in common ), just need to handle some special situation like mark union, lines splice or copypaste. but it looks will make pm doc huge, especially in mark union.
(inspired by remirror-extension-entity-reference but its not good enough to use directly here)
I'm writing a plugin about comment on text.
At first, because comment is not part of the doc, my plan is record selection range when comment and mapping them when transaction applied. Then i found that because every mutation to the doc was map to
ReplaceStep
, when change node attrs, the mapping will behave as remove all its children and reinsert it. It looks like need something likeSetAttrsStep
to describe it, which can avoid position lose.Or I can use mark as a replacement to record associaton between entity and doc. Marks on the doc wont lose ( in common ), just need to handle some special situation like mark union, lines splice or copypaste. but it looks will make pm doc huge, especially in mark union. (inspired by remirror-extension-entity-reference but its not good enough to use directly here)
I wonder which way is better to use?