yjs / y-prosemirror

ProseMirror editor binding for Yjs

Home Page:https://demos.yjs.dev/prosemirror/prosemirror.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request] Support multiple marks with same mark type.

vivaxy opened this issue · comments

Is your feature request related to a problem? Please describe.
ProseMirror marks can have attributes. We can custom the mark with excludes to coexist with the mark of the same type, but different attributes.

For example, the annotation feature allows users to comment on the same text. The mark is defined like:

marks: {
  annotation: {
    attrs: { id: { default: null } },
    excludes: '',
    parseDOM: [{ tag: 'annotation', getAttrs(dom) { Number(dom.getAttributes('data-id')) } }],
    toDOM(node) { return ['annotation', { dataId: node.attrs.id }, 0] }
  }
}

Suppose we have a doc ABC, and two users adding annotations at the same time:
User1: Add annotation to AB. yDoc is <annotation id="1"> -> A -> B -> </annotation> -> C.
User2: Add annotation to BC. yDoc is A -> <annotation id="2"> -> B -> C -> </annotation>.

After merging, yDoc is <annotation id="1"> -> A -> <annotation id="2"> -> B -> </annotation> -> C -> </annotation>. The yDoc data is confusing the closing position of annotations, resulting C to be left out of the annotations.

Describe the solution you'd like
Not sure right now.

Describe alternatives you've considered
N/A

Additional context
N/A

Similar to #34