LiveMarkdown.Avalonia.DrawIo
0.1.1
dotnet add package LiveMarkdown.Avalonia.DrawIo --version 0.1.1
NuGet\Install-Package LiveMarkdown.Avalonia.DrawIo -Version 0.1.1
<PackageReference Include="LiveMarkdown.Avalonia.DrawIo" Version="0.1.1" />
<PackageVersion Include="LiveMarkdown.Avalonia.DrawIo" Version="0.1.1" />
<PackageReference Include="LiveMarkdown.Avalonia.DrawIo" />
paket add LiveMarkdown.Avalonia.DrawIo --version 0.1.1
#r "nuget: LiveMarkdown.Avalonia.DrawIo, 0.1.1"
#:package LiveMarkdown.Avalonia.DrawIo@0.1.1
#addin nuget:?package=LiveMarkdown.Avalonia.DrawIo&version=0.1.1
#tool nuget:?package=LiveMarkdown.Avalonia.DrawIo&version=0.1.1
LiveMarkdown.Avalonia.DrawIo
LiveMarkdown.Avalonia.DrawIo is the draw.io extension for LiveMarkdown.Avalonia. It natively renders draw.io (mxGraph) diagrams, written in Markdown code fences, as Avalonia controls without a JavaScript runtime or WebView.
The draw.io XML is parsed in C# and drawn directly via DrawingContext, using
the geometry and style information embedded in the diagram.
About
This repository is the draw.io (mxGraph) rendering extension for
LiveMarkdown.Avalonia.
It plugs into the LiveMarkdown pipeline (UseDrawIo()), registers a
DrawIoBlockNode, and draws the diagram natively with Avalonia β no
JavaScript runtime and no WebView.
| Package | Description |
|---|---|
LiveMarkdown.Avalonia |
Core Markdown renderer for Avalonia (required dependency). |
LiveMarkdown.Avalonia.DrawIo (this repo) |
Extension that renders ```drawio fenced blocks as native draw.io diagrams. |
- π Core project: https://github.com/DearVa/LiveMarkdown.Avalonia
- π draw.io: https://www.drawio.com/
Features
- π Markdown integration β Detects
```drawiofences and renders the embedded draw.io XML. - π§© Native rendering β No JS / WebView required. Runs on pure C# + Avalonia only.
- π Multi-format input β Supports both plain
<mxGraphModel>XML and the default<mxfile>wrapper, including the compressed (base64 + deflate)<diagram>payload. - π¨ Shape support β Rectangles, rounded rectangles, ellipses, and a broad set of basic preset shapes: rhombus, hexagon, parallelogram, trapezoid, step, cylinder, cloud, actor, internal storage, document, manual input, card, note, callout, double/single arrow, double ellipse, line, process, loop limit, off-page connector, tape, delay, cube, display, data storage, terminator, predefined process, sequential data, multi-document, stored data, manual operation, merge/storage, OR/AND/XOR gates, cross, star, octagon, pentagon, tee, folder β plus generic polygons (
mxgraph.basic.polygon/polyCoordswith optional quadratic curves). - π·οΈ Rich labels β HTML labels with
<b>/<i>/<span style="color:β¦">/<br>markup,%Placeholder%attribute substitution,fontStylebits (bold/italic/underline),whiteSpace=wrapword wrapping, vertical text (horizontal=0) and label background. - β¨ Shape effects β
rotation,flipH/flipV,gradientColor,opacity/fillOpacity/strokeOpacity,shadow,glass, and customdashPattern. - β‘οΈ Edges β Orthogonal / ER / elbow routing,
rounded=1corners,curved=1smoothing,jumpStyle=arcintersection jumps, edge labels, and a broad marker vocabulary (classic/block/open/oval/diamond/async/box/dash/cross/circle/circlePlus/doubleBlockand the ER markersERone/ERmandOne/ERmany/ERoneToMany/ERzeroToOne/ERzeroToMany), withstartFill/endFillandstartSize/endSize. - ποΈ Pages, layers and visibility β Selects a page via
PageIndex; honours hidden cells (visible="0"), collapsed containers and layer assignment. - πΌοΈ Image cells β Renders
shape=image/image=data:image/...cells from inline data URIs. - π§© Generic stencil engine β A native port of draw.io's
mxStencilXML grammar (save/restore,path/move/line/quad/curve/arc/rect/roundrect/ellipse,fill/stroke/fillstroke, style keys). Register any stencil set viaDrawIoStencil.RegisterStencilSet(xml)and the presenter renders it instead of the rectangle fallback. A subset ofmxgraph.flowchart.*(terminator, predefined process, decision, document, database, manual input/operation, preparation, off-page reference, internal storage, delay, display, stored data, loop limit, sequential data, sort) is bundled and auto-registered. - π Streaming support β Shows the source text while the fence is open, and switches to the rendered diagram once it is closed.
Installation
dotnet add package LiveMarkdown.Avalonia.DrawIo
The LiveMarkdown.Avalonia
core package is required (this package depends on it).
Adding to LiveMarkdown
To enable draw.io, perform the following three steps.
1. Register the extension in the pipeline
using LiveMarkdown.Avalonia;
MarkdownRenderer.ConfigurePipeline += pipeline => pipeline
.UseDrawIo();
2. Register the node factory
MarkdownNode.Edit(builder => builder
.Register<DrawIoBlockNode>()
);
3. Load the styles
<Application.Styles>
<StyleInclude Source="avares://LiveMarkdown.Avalonia/Styles.axaml"/>
<StyleInclude Source="avares://LiveMarkdown.Avalonia.DrawIo/Styles.axaml"/>
</Application.Styles>
Usage
Paste the draw.io XML (via Extras β Edit Diagramβ¦ in draw.io) inside a
```drawio fence.
```drawio
<mxfile>
<diagram name="Page-1" id="abc">
<mxGraphModel dx="1422" dy="798" grid="1" gridSize="10" ...>
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="2" value="Hello" style="rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="120" y="80" width="120" height="60" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
```
Customization
DrawIoPresenter exposes styleable properties through the selector
md|DrawIoPresenter.
| Property | Description |
|---|---|
Text |
The draw.io XML string to render. |
Foreground |
Default color for labels and outlines that do not specify a color. |
FontFamily / FontSize |
Font for text in the diagram. |
BackgroundBrush |
Background of the whole diagram (transparent by default). |
Scale |
Zoom/scale applied when rendering the diagram. |
PageIndex |
Zero-based index of the page to render in a multi-page <mxfile>. |
Limitations
- Only the first
<diagram>page of an<mxfile>is rendered. - A set of basic shapes is supported (see Features); exotic preset stencils
(e.g.
mxgraph.aws4.*,mxgraph.flowchart.*) fall back to a plain rectangle. - Edge routing uses the stored waypoints plus a simple orthogonal route; rounded/curved routing and other edge styles are not re-computed.
- Image cells, sketch/comic (rough.js) styles, and the full gradient/shadow option set are not rendered.
See TODO.md for the full list of unsupported features.
Building & Releasing
# Build
dotnet build LiveMarkdown.Avalonia.DrawIo.csproj -c Release
# Produce NuGet packages (nupkg + snupkg) in ./artifacts
dotnet pack LiveMarkdown.Avalonia.DrawIo.csproj -c Release -o ./artifacts
Releases are automated with GitHub Actions:
.github/workflows/ci.ymlbuilds (with-warnaserror) and packs on every push / PR tomain..github/workflows/release.ymlruns when av*.*.*tag is pushed (e.g.git tag v1.0.0 && git push origin v1.0.0). It builds, packs, creates a GitHub Release, and publishes the package to NuGet.org using Trusted Publishing (OIDC) β no long-lived API key is stored in the repository. SetNUGET_USER(the nuget.org account name) as a repository variable/secret and create the matching Trusted Publishing policy on nuget.org. Seedocs/nuget-trusted-publishing.mdfor the full setup.
To publish manually (local, with your own API key):
dotnet pack LiveMarkdown.Avalonia.DrawIo.csproj -c Release -o ./artifacts
dotnet nuget push "artifacts/*.nupkg" --api-key <YOUR_API_KEY> --source https://api.nuget.org/v3/index.json
License
Apache-2.0
References
- LiveMarkdown.Avalonia (core, the host renderer): https://github.com/DearVa/LiveMarkdown.Avalonia
- Official draw.io: https://www.drawio.com/
- draw.io mxGraph XML reference: https://www.drawio.com/doc/faq/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia (>= 12.1.4)
- LiveMarkdown.Avalonia (>= 2.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See https://github.com/ajkfds/LiveMarkdown.Avalonia.DrawIo/blob/main/README.md and TODO.md for the supported feature set.