yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
322 stars 111 forks source link

Does not support marks on non-TextNodes #47

Open ascott18 opened 3 years ago

ascott18 commented 3 years ago

Checklist

Describe the bug

This plugin fundamentally does not support marks on nodes that are not text nodes. For example, Tiptap's image node, which is an inline, non-text node: https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/nodes/Image.js.

To Reproduce

  1. Apply a mark to an inline node. For example, apply a hyperlink (https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/marks/Link.js) to an image (https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/nodes/Image.js)
  2. Be the editor of the document. Observe that the JSON version of the prosemirror doc does contain the expected mark, and that the HTML is rendered with the correct <a></a> wrapping the image node.
  3. Be a realtime collaborator on the same document, OR reload the document using the serialized ydoc. Observe that the hyperlink on the image is missing because the mark is not serialized into the ydoc.

Expected behavior

Marks on custom nodes are handled just as attributes on custom nodes are handled.

BrianHung commented 2 years ago

If anyone wants to tackle this in a PR, two main functions to address are createTypeFromElementNode and createNodeFromYElement.

Particularly, serialize the marks of a node as Y.XmlElement attributes using setAttribute while differentiating them somehow from node.attrs, then deserializing them and passing Mark[] as argument to schema.node.

alexharri commented 2 years ago

The lack of support for marks on custom nodes is currently causing issues in an editor that I'm building. Would love to see this feature.

Judging from the title, #63 sounds like it should resolve the issue. Is there something preventing us from taking #63 in @dmonad? I would love to help if I can.

rebolyte commented 1 year ago

Same here, this has become a blocker on one of my projects as well. Can #63 be merged?

devalberg commented 1 year ago

Any updates on this @dmonad?

martinboksa commented 1 year ago

Any updates, please? @dmonad

icode commented 1 year ago

The same problem, custom nodes cannot support marks

pointnet commented 1 year ago

Same problem here, any updates?

hoebbelsB commented 2 months ago

+1