CodeMermaid Flowchart
CodeMermaid is a flowchart rendering component based on Mermaid, supporting dynamic rendering of Mermaid diagrams.
Basic Usage
Use the content property to pass in a Mermaid syntax string.
Slot - Custom Toolbar
Supports slot definitions. When customizing the toolbar, you need to handle theme color adaptation yourself. There are two types of toolbars:
- Hover toolbar
- Fullscreen toolbar
WARNING
When configuring theme and mermaidConfig individually, all components must have the same configuration. Because Mermaid uses globally unified rendering configuration and cannot be configured individually during rendering, otherwise it will cause inconsistent rendering configurations. Unless you are rendering asynchronously, tab switching types can be changed.
Props
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| content | string | Yes | — | Mermaid syntax content |
| disabledZoom | string | No | [] | wheel: Disable wheel zoomfullscreenWheel: Disable wheel zoom in fullscreen modeclickMove: Disable click drag zoomfullscreenClickMove: Disable click drag zoom in fullscreen modeall: Disable all |
| theme | string | No | base | Mermaid theme, supports default, forest, dark, neutral, base |
| fullscreenMode | string | No | page | Fullscreen mode, supports web (web fullscreen) and page (page fullscreen) |
| mermaidConfig | MermaidConfig | No | {} | Mermaid config object, see Mermaid Config |
Slots
| Slot Name | Description | Slot Parameters |
|---|---|---|
| fullscreen-toolbar | Fullscreen toolbar | isCodeView: Currently showing code(true) or mermaid chart(false)isCopied: Copy status, 1s interval before next copyonCopy: Copy code functiontoggleView: Toggle between code and mermaid chartzoomIn: Zoom inzoomOut: Zoom outresetZoom: Reset to defaulttoggleFullscreen: Toggle fullscreendownloadPng: Download image |
| toolbar | Normal toolbar | Same parameters as above |
Ref
| Method Name | Description | Parameters |
|---|---|---|
| toggleView | Toggle code/chart view | - |
| zoomIn | Zoom in | - |
| zoomOut | Zoom out | - |
| resetZoom | Reset zoom | - |
| toggleFullscreen | Toggle fullscreen | - |
| downloadPng | Download PNG image | - |
| onCopy | Copy code | - |