English
@eightkk/vue-weave / core / fromDrawio
Function: fromDrawio()
fromDrawio(
xml,options?):GraphInterchangeImport
Defined in: src/core/interchangeDrawio.ts:493
Read an uncompressed draw.io (diagrams.net) file into NetworkGraph nodes, edges, groups, positions and sizes. Accepts an mxfile (the first page, or options.page by zero-based index or name) or a bare mxGraphModel, as draw.io saves with compression turned off (File, Properties). Uses the DOM-free XML reader of fromMsProjectXml: declared entities are never expanded and nothing outside the text is loaded.
Vertex cells become nodes: the value (as text; HTML labels with html=1 lose their markup and keep line breaks) is split into label (first line) and detail (a label with line breaks that toDrawio wrote is kept whole), the style gives the shape (rhombus diamond, ellipse ellipse, shape=hexagon hexagon, rounded=1 rounded; other shapes are boxes with an unsupported-shape warning) and the tone (vwTone, or a fill colour that toDrawio writes), and the geometry the position and size. A vertex that contains other vertices is a group (container, swimlane or group cell) and its frame is not kept; child geometry relative to a container is made absolute. UserObject and object wrappers are read. Edge cells become edges with the cell ID, value (or the text of label cells on the edge) as label, endArrow and startArrow as markers, the edge style (orthogonal styles, curved=1, edgeStyle=none), flowAnimation and the waypoints. An edge that is not connected at both ends, or connected to a group, is left out with a warning.
Throws an Error for malformed XML, a root element other than mxfile or mxGraphModel, a missing page and a compressed page (read it with fromDrawioAsync), and a RangeError for an invalid page and past maxItems (which counts nodes, edges, groups and the label cells of edges).
Parameters
xml
string
options?
DrawioImportOptions = {}