quick-start.mdx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Quick Start
  2. import {
  3. PackageManagerTabs
  4. // @ts-ignore
  5. } from '@theme';
  6. :::info
  7. To quickly experience FlowGram.AI, you can directly [open it in CodeSandbox](https://codesandbox.io/p/github/louisyoungx/flowgram-demo/main).
  8. :::
  9. Choose a way to start:
  10. - Option 1: Use the official template scaffolding to build a new project (⭐️ Recommended for a quick start).
  11. - Option 2: Integrate into an existing project by installing the editor package.
  12. ## Option 1: Create a FlowGram.AI Application via the Official Template
  13. 1. Use the FlowGram CLI to set up a runnable demo.
  14. <PackageManagerTabs command={{
  15. npm: "npx @flowgram.ai/create-app@latest",
  16. pnpm: "pnpm dlx @flowgram.ai/create-app@latest",
  17. yarn: "yarn dlx @flowgram.ai/create-app@latest",
  18. bun: "bunx @flowgram.ai/create-app@latest",
  19. }} />
  20. 2. Select a template when prompted (it is recommended to choose `Free Layout Demo` for a quick start).
  21. ```text
  22. - Free Layout Demo # Best practice for free layout (⭐️ Recommended)
  23. - Free Layout Demo Simple # Basic usage of free layout
  24. - Fixed Layout Demo # Best practice for fixed layout
  25. - Fixed Layout Demo Simple # Basic usage of fixed layout
  26. ```
  27. <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, minmax(320px, 1fr))', gap: 16, marginTop: 12 }}>
  28. <div>
  29. <p><strong>Free Layout Demo</strong> [View Online Demo](/examples/free-layout/free-layout-simple.html)</p>
  30. <img src="/examples/example-free-layout.png" alt="Free Layout Preview" style={{ width: '100%', borderRadius: 8 }} />
  31. </div>
  32. <div>
  33. <p><strong>Fixed Layout Demo</strong> [View Online Demo](/examples/fixed-layout/fixed-layout-simple.html)</p>
  34. <img src="/examples/example-fixed-layout.png" alt="Fixed Layout Preview" style={{ width: '100%', borderRadius: 8 }} />
  35. </div>
  36. <div>
  37. <p><strong>Free Layout Demo Simple</strong> [View Online Demo](/examples/free-layout/free-layout-simple.html)</p>
  38. <img src="/examples/example-free-layout-simple.png" alt="Free Layout Simple Preview" style={{ width: '100%', borderRadius: 8 }} />
  39. </div>
  40. <div>
  41. <p><strong>Fixed Layout Demo Simple</strong> [View Online Demo](/examples/fixed-layout/fixed-layout-simple.html)</p>
  42. <img src="/examples/example-fixed-layout-simple.png" alt="Fixed Layout Simple Preview" style={{ width: '100%', borderRadius: 8 }} />
  43. </div>
  44. </div>
  45. 3. Check the installed directory name.
  46. - For a project created with the Free Layout Demo template, the directory name is `demo-free-layout`.
  47. - For a project created with the Free Layout Demo Simple template, the directory name is `demo-free-layout-simple`.
  48. - For a project created with the Fixed Layout Demo template, the directory name is `demo-fixed-layout`.
  49. - For a project created with the Fixed Layout Demo Simple template, the directory name is `demo-fixed-layout-simple`.
  50. 4. Enter the project directory.
  51. ```sh
  52. cd [project-name]
  53. ```
  54. 5. Install dependencies.
  55. <PackageManagerTabs command={{
  56. npm: "npm install",
  57. pnpm: "pnpm install",
  58. yarn: "yarn install",
  59. bun: "bun install",
  60. }} />
  61. 6. Start the development server.
  62. <PackageManagerTabs command={{
  63. npm: "npm run dev",
  64. pnpm: "pnpm dev",
  65. yarn: "yarn dev",
  66. bun: "bun dev",
  67. }} />
  68. ## Option 2: Install the Editor Package Directly
  69. :::tip
  70. This method is suitable for developers who have some familiarity with the FlowGram project.
  71. If you are new to FlowGram, we recommend choosing Option 1 first to familiarize yourself with the project, and then gradually integrate the required code into your existing project.
  72. :::
  73. If you need to add the package to an existing project, choose a layout type:
  74. <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
  75. <div>
  76. <strong>Free Layout</strong>
  77. <p>Nodes can be dragged freely on the canvas, and edges can be used to connect nodes to establish logical relationships between them.</p>
  78. <p>Next: [Create a Free Layout Canvas](/guide/getting-started/free-layout)</p>
  79. <img src="/free-layout/free-layout-demo.gif" alt="Free Layout Demo" style={{ width: '100%', borderRadius: 8 }} />
  80. </div>
  81. <div>
  82. <strong>Fixed Layout</strong>
  83. <p>The position of nodes in the graph represents the logical relationship between them.</p>
  84. <p>Next: [Create a Fixed Layout Canvas](/guide/getting-started/fixed-layout)</p>
  85. <img src="/fixed-layout/fixed-layout-demo.gif" alt="Fixed Layout Demo" style={{ width: '100%', borderRadius: 8 }} />
  86. </div>
  87. </div>