mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Add documentation for exposed detectType function
This commit is contained in:
parent
8ebd550e0b
commit
878c9f1d9d
@ -247,6 +247,23 @@ The example below show an outline of how this could be used. The example just lo
|
||||
</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
|
||||
|
||||
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>
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
|
||||
|
Loading…
x
Reference in New Issue
Block a user