installation.mdx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Installation
  2. `@excalidraw/mermaid-to-excalidraw` is published to npm. This library is used in [excalidraw](https://excalidraw.com) to transform mermaid syntax to Excalidraw diagrams.
  3. Using `npm`
  4. ```bash
  5. npm install @excalidraw/mermaid-to-excalidraw
  6. ```
  7. Using `yarn`
  8. ```bash
  9. yarn add @excalidraw/mermaid-to-excalidraw
  10. ```
  11. ## Usage
  12. Once the library is installed, its ready to use.
  13. ```js
  14. import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
  15. import { convertToExcalidrawElements} from "@excalidraw/excalidraw"
  16. try {
  17. const { elements, files } = await parseMermaid(diagramDefinition, {
  18. fontSize: DEFAULT_FONT_SIZE,
  19. });
  20. // currently the elements returned from the parser are in a "skeleton" format
  21. // which we need to convert to fully qualified excalidraw elements first
  22. const excalidrawElements = convertToExcalidrawElements(elements);
  23. // Render elements and files on Excalidraw
  24. } catch (e) {
  25. // Error handling
  26. }
  27. ```
  28. ## Playground
  29. Try it out [here](https://mermaid-to-excalidraw.vercel.app)