MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / wrapWithMxFile

Function wrapWithMxFile

frontend/lib/utils.ts:115–133  ·  view source on GitHub ↗
(xml: string)

Source from the content-addressed store, hash-verified

113 * @returns Full mxfile-wrapped XML string
114 */
115export function wrapWithMxFile(xml: string): string {
116 if (!xml) {
117 return `<mxfile><diagram name="Page-1" id="page-1"><mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`
118 }
119
120 // Already has full structure
121 if (xml.includes("<mxfile")) {
122 return xml
123 }
124
125 // Has mxGraphModel but not mxfile
126 if (xml.includes("<mxGraphModel")) {
127 return `<mxfile><diagram name="Page-1" id="page-1">${xml}</diagram></mxfile>`
128 }
129
130 // Just <root> content - extract inner content and wrap fully
131 const rootContent = xml.replace(/<\/?root>/g, "").trim()
132 return `<mxfile><diagram name="Page-1" id="page-1"><mxGraphModel><root>${rootContent}</root></mxGraphModel></diagram></mxfile>`
133}
134
135/**
136 * Replace nodes in a Draw.io XML diagram

Callers 2

onToolCallFunction · 0.90
AutoFigureProviderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected