Class ProseMirrorConverter

java.lang.Object
net.carcdr.yprosemirror.ProseMirrorConverter

public final class ProseMirrorConverter extends Object
Converts ProseMirror documents to Y-CRDT structures.

This class provides utilities for converting ProseMirror nodes, fragments, and documents into their Y-CRDT XML equivalents (YXmlFragment, YXmlElement, YXmlText).

Mapping Strategy:

  • ProseMirror Node → YXmlElement (node type becomes XML tag)
  • ProseMirror Fragment → YXmlFragment (container for nodes)
  • Text content → YXmlText (with marks as formatting attributes)
  • Node attributes → XML element attributes

Usage Example:


 // Convert a ProseMirror document to Y-CRDT
 YDoc ydoc = ProseMirrorConverter.prosemirrorToYDoc(pmNode, schema);

 // Or convert to an existing YXmlFragment
 try (YDoc ydoc = new YDoc();
      YXmlFragment fragment = ydoc.getXmlFragment("prosemirror")) {
     ProseMirrorConverter.nodeToYXml(pmNode, fragment, schema);
 }
 
Since:
0.1.0
See Also: