Open dongtc opened 3 years ago
Right.. that makes sense. This type of information can currently not be properly represented in Yjs / Y.Text.
In my project, i have a temporary solution. The main changed code is as follows:
Meantime, i change the createTextNodesFromYText
and equalYTextPText
functions.
It seems hack but works fine, do you have a better suggest? @dmonad
Hi @dongtc ,
the approach might work, but it will break all existing documents because they use objects instead of arrays. I would accept a PR that is well tested and is backwards-compatible. I think it could be possible to use arrays as "attributes" when multiple marks with the same name are present.
Tanks for your suggestion, i will create a PR later. @dmonad
Describe the bug Prosemirror supports overlapping marks with same name(as long as they have different attributes):
https://prosemirror.net/docs/ref/#model.MarkSpec.excludes
But prosemirror-binding seems didn't handle it well, i have found the problem code line: https://github.com/yjs/y-prosemirror/blob/25cea84874eace50745fd2433847aabceef92b65/src/plugins/sync-plugin.js#L670
If a prosemirror text with the marks:
[{type: 'comment', attrs: {id: 1}}, {type: 'comment', attrs: {id: 2}}]
It will be convert to:
{comment: {id: 2}}
You can see lost a mark.