ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.73k stars 337 forks source link

Which way is better to associate comment to prosemirror doc? #1290

Closed BlueCat0 closed 2 years ago

BlueCat0 commented 2 years ago

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 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 wonder which way is better to use?

marijnh commented 2 years ago

Please use the forum for questions, this here is the bug tracker.