You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document export as Mermaid and update export as code page (#164)
* Update export as code page and document export as Mermaid
* Fix typo
Co-authored-by: Farzad Yousefzadeh <[email protected]>
* Fix typo
* Link to GitLab support for Mermaid
* Fix broken link
---------
Co-authored-by: Farzad Yousefzadeh <[email protected]>
Copy file name to clipboardExpand all lines: docs/export-as-code.mdx
+41-20Lines changed: 41 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,33 +4,54 @@ title: Export as code
4
4
5
5
Exporting as code is useful if you want to use your machine with [XState](xstate/intro.mdx) inside your codebase or if you want to duplicate your machine without using **Fork**.
6
6
7
-
You can currently export your machine as JSON, JavaScript, and TypeScript code using the code panel in the right tool menu. You can also export as code from the **Export machine** dialog using the export icon button in the editor’s top bar.
7
+
Every feature of your state machine will be included in the code, except for colors and annotations.
8
8
9
-
## Export code from the code panel
9
+
## Export formats
10
10
11
-

11
+
You can currently export your machine as:
12
12
13
-
1. Open the <Codesize={18} /> **Code** panel from the right tool menu.
14
-
2. Use the JSON, JavaScript, or TypeScript buttons to display the code in your preferred format in the text area.
15
-
3. Use the **XState version 5 beta** toggle to toggle between code supported by XState version 4 and XState version 5 beta.
13
+
- JSON code for use with XState
14
+
- JavaScript code for use with XState
15
+
- TypeScript code for use with XState
16
+
-[Mermaid](https://mermaid.js.org) code and diagrams for use in GitHub, GitLab, and anywhere Mermaid is supported
17
+
18
+
:::new
19
+
20
+
You can now export to Mermaid code and diagrams.
21
+
22
+
:::
23
+
24
+
## How to export as code
25
+
26
+
You can export as code by:
27
+
- Using the <Codesize={18} /> **Code** panel in the right tool menu
28
+
- Using the <MoreHorizontalsize={18} /> menu alongside the machine name in the machines list
29
+
- Using the <Uploadsize={18} /> export icon button in the header
30
+
31
+
:::studio
32
+
33
+
You can also [import from code](import-from-code.mdx) in any of these locations.
34
+
35
+
:::
36
+
37
+
### Export to JSON, JavaScript, or TypeScript
38
+
39
+
1. Use one of the options above to open the **Export to code** modal or <Codesize={18} /> **Code** panel.
40
+
2. Use the dropdown menu to choose from JSON, JavaScript, or TypeScript.
41
+
3. Use the **XState version 5 beta** toggle to choose between code supported by XState version 4 and XState version 5 beta.
16
42
4. Use the **Copy** button to copy the code to your clipboard.
17
43
5. Paste into your code editor.
18
44
19
-
## Export code using the header export icon
20
-
21
-

45
+
### Export to Mermaid
22
46
23
-
1. Open the export **Code** modal using the <Uploadsize={18} /> export icon in the header.
24
-
2. Use the JSON, JavaScript, or TypeScript button to copy the code in your preferred format to your clipboard.
25
-
3. Use the **XState version 5 beta** toggle to toggle between code supported by XState version 4 and XState version 5 beta.
26
-
4. Paste into your code editor.
47
+
1. Use one of the options above to open the **Export to code** modal or <Codesize={18} /> **Code** panel.
48
+
2. Use the dropdown menu to choose Mermaid.
49
+
3. Use the **Copy** button to copy the code to your clipboard.
50
+
4. Use the **Preview** tab to preview the diagram and **Copy SVG** to copy the diagram SVG to your clipboard.
51
+
5. Paste into your code or graphics editor.
27
52
28
-
## Export code from the machine menu
53
+
:::tip
29
54
30
-

55
+
Wrap your Mermaid code in a fenced code block with the `mermaid` language identifier to [share your diagram on GitHub](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams) and [share your diagram on GitLab](https://handbook.gitlab.com/handbook/tools-and-tips/mermaid/).
31
56
32
-
1. Open the machine menu by clicking the <MoreHorizontalsize={18} /> ellipsis button to the right of the machine name.
33
-
2. Click the <ShareIconsize={18} /> **Export code** button in the menu to open the **Export machine** dialog.
34
-
3. Use the JSON, JavaScript, or TypeScript button to copy the code in your preferred format to your clipboard.
35
-
4. Use the **XState version 5 beta** toggle to toggle between code supported by XState version 4 and XState version 5 beta.
Copy file name to clipboardExpand all lines: versioned_docs/version-5/export-as-code.mdx
+41-20Lines changed: 41 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,33 +4,54 @@ title: Export as code
4
4
5
5
Exporting as code is useful if you want to use your machine with [XState](xstate.mdx) inside your codebase or if you want to duplicate your machine without using **Fork**.
6
6
7
-
You can currently export your machine as JSON, JavaScript, and TypeScript code using the code panel in the right tool menu. You can also export as code from the **Export machine** dialog using the export icon button in the editor’s top bar.
7
+
Every feature of your state machine will be included in the code, except for colors and annotations.
8
8
9
-
## Export code from the code panel
9
+
## Export formats
10
10
11
-

11
+
You can currently export your machine as:
12
12
13
-
1. Open the <Codesize={18} /> **Code** panel from the right tool menu.
14
-
2. Use the JSON, JavaScript, or TypeScript buttons to display the code in your preferred format in the text area.
15
-
3. Use the **XState version 5 beta** toggle to toggle between code supported by XState version 4 and XState version 5 beta.
16
-
4. Use the **Copy** button to copy the code to your clipboard.
17
-
5. Paste into your code editor.
13
+
- JSON code for use with XState
14
+
- JavaScript code for use with XState
15
+
- TypeScript code for use with XState
16
+
-[Mermaid](https://mermaid.js.org) code and diagrams for use in GitHub, GitLab, and anywhere Mermaid is supported
17
+
18
+
:::new
19
+
20
+
You can now export to Mermaid code and diagrams.
21
+
22
+
:::
23
+
24
+
## How to export as code
18
25
19
-
## Export code using the header export icon
26
+
You can export as code by:
27
+
- Using the <Codesize={18} /> **Code** panel in the right tool menu
28
+
- Using the <MoreHorizontalsize={18} /> menu alongside the machine name in the machines list
29
+
- Using the <Uploadsize={18} /> export icon button in the header
20
30
21
-

31
+
:::studio
22
32
23
-
1. Open the export **Code** modal using the <Uploadsize={18} /> export icon in the header.
24
-
2. Use the JSON, JavaScript, or TypeScript button to copy the code in your preferred format to your clipboard.
25
-
3. Use the **XState version 5 beta** toggle to toggle between code supported by XState version 4 and XState version 5 beta.
26
-
4. Paste into your code editor.
33
+
You can also [import from code](import-from-code.mdx) in any of these locations.
27
34
28
-
## Export code from the machine menu
35
+
:::
29
36
30
-

37
+
### Export to JSON, JavaScript, or TypeScript
31
38
32
-
1.Open the machine menu by clicking the <MoreHorizontalsize={18} /> ellipsis button to the right of the machine name.
33
-
2.Click the <ShareIconsize={18} /> **Export code** button in the menu to open the **Export machine** dialog.
34
-
3. Use the JSON, JavaScript, or TypeScript button to copy the code in your preferred format to your clipboard.
35
-
4. Use the **XState version 5 beta**toggle to toggle between code supported by XState version 4 and XState version 5 beta.
39
+
1.Use one of the options above to open the **Export to code** modal or <Codesize={18} /> **Code** panel.
40
+
2.Use the dropdown menu to choose from JSON, JavaScript, or TypeScript.
41
+
3. Use the **XState version 5 beta** toggle to choose between code supported by XState version 4 and XState version 5 beta.
42
+
4. Use the **Copy**button to copy the code to your clipboard.
36
43
5. Paste into your code editor.
44
+
45
+
### Export to Mermaid
46
+
47
+
1. Use one of the options above to open the **Export to code** modal or <Codesize={18} /> **Code** panel.
48
+
2. Use the dropdown menu to choose Mermaid.
49
+
3. Use the **Copy** button to copy the code to your clipboard.
50
+
4. Use the **Preview** tab to preview the diagram and **Copy SVG** to copy the diagram SVG to your clipboard.
51
+
5. Paste into your code or graphics editor.
52
+
53
+
:::tip
54
+
55
+
Wrap your Mermaid code in a fenced code block with the `mermaid` language identifier to [share your diagram on GitHub](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams) and [share your diagram on GitLab](https://handbook.gitlab.com/handbook/tools-and-tips/mermaid/).
0 commit comments