I’m adding a comment system (similar to Google Docs) to Prosemirror with Yjs and am currently tracking comment positions using marks. I saw this thread which recommends storing comment ranges separately.
Comments are usually not modeled as document nodes—rather, they are references to ranges, that are tracked separately, outside of the document
I agree this is a much clearner way to store comments, but I’m a little concerned about performance. If we have a long document with a lot of comments then any character typed in the first paragraph will offset all comments and therefore require significant changes with each update.
As an alternative, is it possible to store the comment position in an offset relative to a node? This way changes to other nodes won’t require comments to update. A couple questions.
Is there a recommended way to reference nodes outside of the prosemirror document? An index is the only thing I can think of but uncertain how easy that will be to update as the document changes.
Is there a way to attach metadata to each node in the document? I could store a unique id or even the comment positions within this.
this might not be completely related to your question, but I’ve already created an extension for Google Docs like commenting for Tiptap, which uses ProseMirror under the hood. Although I am using marks to keep track of the comments.
@sereneinserenade I’m using Tiptap and marks for comments as well. I’ll check out the comment extension you linked and it might give me some ideas. Thanks!
@ryanb if you’re using Yjs then you could save the Yjs cursors and store it independently of the document:
This is for decorations but the same could be used for threads too ( this way people could add threads to your document without being able to edit it for ex. )