xml2ydoc
Parses a draw.io XML string and populates a Y.Doc with the result.
Signature
ts
function xml2ydoc(xml: string, doc: Y.Doc): Y.DocParameters
xml— a draw.io XML string. Supports both<mxfile>(multi-page) and<mxGraphModel>(single model) formats.doc— required — the externally providedY.Docto write into.
Return Value
The same Y.Doc that was passed in (for chaining).
Example
ts
import * as Y from 'yjs';
import { xml2ydoc } from 'y-mxgraph';
const doc = new Y.Doc();
const xmlStr = `<mxfile><diagram name="Page-1" id="abc">...</diagram></mxfile>`;
xml2ydoc(xmlStr, doc);