mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-03 22:29:38 +02:00
Add documentation for exposed detectType function
This commit is contained in:
@@ -247,6 +247,23 @@ The example below show an outline of how this could be used. The example just lo
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To determine the type of diagram present in a given text, you can utilize the `mermaid.detectType` function, as demonstrated in the example below.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
const graphDefinition = `sequenceDiagram
|
||||||
|
Pumbaa->>Timon:I ate like a pig.
|
||||||
|
Timon->>Pumbaa:Pumbaa, you ARE a pig.`;
|
||||||
|
try {
|
||||||
|
const type = mermaid.detectType(graphDefinition);
|
||||||
|
console.log(type); // 'sequence'
|
||||||
|
} catch (error) {
|
||||||
|
// UnknownDiagramError
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
### Binding events
|
### Binding events
|
||||||
|
|
||||||
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
|
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
|
||||||
|
@@ -244,6 +244,23 @@ The example below show an outline of how this could be used. The example just lo
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To determine the type of diagram present in a given text, you can utilize the `mermaid.detectType` function, as demonstrated in the example below.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
const graphDefinition = `sequenceDiagram
|
||||||
|
Pumbaa->>Timon:I ate like a pig.
|
||||||
|
Timon->>Pumbaa:Pumbaa, you ARE a pig.`;
|
||||||
|
try {
|
||||||
|
const type = mermaid.detectType(graphDefinition);
|
||||||
|
console.log(type); // 'sequence'
|
||||||
|
} catch (error) {
|
||||||
|
// UnknownDiagramError
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
### Binding events
|
### Binding events
|
||||||
|
|
||||||
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
|
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
|
||||||
|
Reference in New Issue
Block a user