Skip to content

Commit fc3efc4

Browse files
Merge pull request #4800 from syncfusion-content/903090-Mermaid
903090 - UG for Mermaid import and export support
2 parents 9a2890d + ec88430 commit fc3efc4

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

blazor/diagram/serialization.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,33 @@ The diagram provides support to save and load the diagram using file stream. The
134134
}
135135
```
136136

137-
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Serialization/SaveAndLoad)
137+
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/Serialization/SaveAndLoad)
138+
139+
## Importing and Exporting Mind Map and Flowchart Diagrams using Mermaid Syntax
140+
141+
The [SfDiagramComponent](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html) supports saving diagrams in Mermaid syntax format. Mermaid is a Markdown-inspired syntax that automatically generates diagrams. With this functionality, you can easily create mind maps and flowcharts from Mermaid syntax data, simplifying the visualization of complex ideas and processes without manual drawing. Additionally, you can export your mind maps and flowcharts to Mermaid syntax, allowing for easy sharing, editing, and use across different platforms.
142+
143+
### Save diagram as Mermaid syntax
144+
145+
The [SaveDiagramAsMermaid](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html#Syncfusion_Blazor_Diagram_SfDiagramComponent_SaveDiagramAsMermaid) method serializes the diagram into a Mermaid-compatible string format. This method is specifically designed for diagrams that utilize Flowchart and Mind map layouts. The following code illustrates how to save the diagram in Mermaid string format.
146+
147+
```cshtml
148+
SfDiagramComponent Diagram;
149+
//returns the serialized Mermaid string of the Diagram
150+
string data = Diagram.SaveDiagramAsMermaid();
151+
```
152+
153+
### Load diagram from Mermaid syntax
154+
155+
You can load a [diagram](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html) from the serialized Mermaid syntax data using the [LoadDiagramFromMermaidAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Diagram.SfDiagramComponent.html#Syncfusion_Blazor_Diagram_SfDiagramComponent_LoadDiagramFromMermaidAsync_System_String_) method. The following code illustrates how to load a diagram from a Mermaid string data.
156+
157+
```cshtml
158+
SfDiagramComponent Diagram;
159+
// Retrieves the serialized Mermaid string of the Diagram
160+
string data = Diagram.SaveDiagramAsMermaid();
161+
// Loads the Diagram from the saved Mermaid string
162+
await Diagram.LoadDiagramFromMermaidAsync(data);
163+
```
164+
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/Blazor-Diagram-Examples/tree/master/UG-Samples/MermaidSupport).
165+
166+
>**Note:** Mermaid syntax data serialization and deserialization are only supported for Flowchart and Mind map layouts. Please ensure that your diagram uses one of these layouts to successfully load the data.

0 commit comments

Comments
 (0)