Functions
Import these from @grafloria/engine.
Functions
debugLog
Emit a diagnostic. No-op unless {@link setDebugLogging} turned it on.
tsfunction debugLog(...args: unknown[]): void
importDrawio
Import a .drawio / mxGraph XML document.
Accepts plain <mxGraphModel> XML or a full <mxfile> (compressed or not). A multi-page file imports EVERY page: diagram is page 1 (back-compatible)
and pages[] — present only when the file has more than one <diagram> —
carries each page's own diagram, warnings, and (for a corrupt page) error. Never throws: unreadable input comes back as { error }.
tsasync function importDrawio(text: string): Promise<DrawioImportResult>
isComponentAdapter
Type guard to check if an object implements ComponentAdapter
tsfunction isComponentAdapter(obj: any): obj is ComponentAdapter
Parameters
obj: Object to check
Returns True if object implements ComponentAdapter interface
Example
typescriptif (isComponentAdapter(obj)) {
obj.registerComponent('test', TestComponent);
}
isDebugLogging
Whether diagnostics are on — use this to guard an expensive call site.
tsfunction isDebugLogging(): boolean
layoutArchitecture
Lay a diagram out as an architecture composition. Writes into the model.
tsfunction layoutArchitecture(diagram: DiagramModel, options: ArchitectureLayoutOptions = {}): ArchitectureLayoutResult
setDebugLogging
Turn diagnostic logging on or off. Off by default, and off is the only state a consumer ever sees unless they ask for otherwise.
tsfunction setDebugLogging(on: boolean): void
stripHtmlToText
value="<b>Start</b><br>here" must become "Start here", not carry markup
into the label canon. Block/line-break boundaries turn into single spaces so
words do not fuse.
Entities are decoded a SECOND time here, after the tags are gone. The XML
reader already decoded one level — but with html=1 (draw.io's default) the
value is an HTML FRAGMENT, so an author's literal & was double-encoded on
save (&amp;) and one decode still leaves & in the label.
tsfunction stripHtmlToText(value: string): string
Was this page helpful?