13 KiB
Warning
THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
Please edit the corresponding file in /packages/mermaid/src/docs/config/setup/interfaces/mermaid.Mermaid.md.
Interface: Mermaid
mermaid.Mermaid
Properties
contentLoaded
• contentLoaded: () => void
Type declaration
▸ (): void
##contentLoaded Callback function that is called when page is loaded. This functions fetches configuration for mermaid rendering and calls init for rendering the mermaid diagrams on the page.
Returns
void
Defined in
packages/mermaid/src/mermaid.ts:451
detectType
• detectType: (text
: string
, config?
: MermaidConfig
) => string
Type declaration
▸ (text
, config?
): string
Detects the type of the graph text.
Takes into consideration the possible existence of an %%init
directive
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The text defining the graph. For example: mermaid %%{initialize: {"startOnLoad": true, logLevel: "fatal" }}%% graph LR a-->b b-->c c-->d d-->e e-->f f-->g g-->h |
config? |
MermaidConfig |
The mermaid config. |
Returns
string
A graph definition key
Defined in
packages/mermaid/src/mermaid.ts:453
init
• init: (config?
: MermaidConfig
, nodes?
: string
| HTMLElement
| NodeListOf
<HTMLElement
>, callback?
: (id
: string
) => unknown
) => Promise
<void
>
Deprecated
Use initialize and run instead.
Type declaration
▸ (config?
, nodes?
, callback?
): Promise
<void
>
Parameters
Name | Type |
---|---|
config? |
MermaidConfig |
nodes? |
string | HTMLElement | NodeListOf <HTMLElement > |
callback? |
(id : string ) => unknown |
Returns
Promise
<void
>
Defined in
packages/mermaid/src/mermaid.ts:446
initialize
• initialize: (config
: MermaidConfig
) => void
Type declaration
▸ (config
): void
Used to set configurations for mermaid. This function should be called before the run function.
Parameters
Name | Type | Description |
---|---|---|
config |
MermaidConfig |
Configuration object for mermaid. |
Returns
void
Defined in
packages/mermaid/src/mermaid.ts:450
mermaidAPI
• mermaidAPI: Readonly
<{ defaultConfig
: MermaidConfig
= configApi.defaultConfig; getConfig
: () => MermaidConfig
= configApi.getConfig; getDiagramFromText
: (text
: string
, metadata
: Pick
<DiagramMetadata
, "title"
>) => Promise
<Diagram
> ; getSiteConfig
: () => MermaidConfig
= configApi.getSiteConfig; globalReset
: () => void
; initialize
: (userOptions
: MermaidConfig
) => void
; parse
: (text
: string
, parseOptions
: ParseOptions
& { suppressErrors
: true
}) => Promise
<ParseResult
| false
>(text
: string
, parseOptions?
: ParseOptions
) => Promise
<ParseResult
> ; render
: (id
: string
, text
: string
, svgContainingElement?
: Element
, positions?
: Positions
) => Promise
<RenderResult
> ; reset
: () => void
; setConfig
: (conf
: MermaidConfig
) => MermaidConfig
= configApi.setConfig; updateSiteConfig
: (conf
: MermaidConfig
) => MermaidConfig
= configApi.updateSiteConfig }>
Deprecated
Use parse and render instead. Please open a discussion if your use case does not fit the new API.
Defined in
packages/mermaid/src/mermaid.ts:440
parse
• parse: (text
: string
, parseOptions?
: ParseOptions
) => Promise
<boolean
| void
| ParseResult
>
Type declaration
▸ (text
, parseOptions?
): Promise
<boolean
| void
| ParseResult
>
Parse the text and validate the syntax.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The mermaid diagram definition. |
parseOptions? |
ParseOptions |
Options for parsing. |
Returns
Promise
<boolean
| void
| ParseResult
>
If valid, Diagram otherwise false
if parseOptions.suppressErrors is true
.
See
Throws
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
Example
console.log(await mermaid.parse('flowchart \n a --> b'));
// { diagramType: 'flowchart-v2' }
console.log(await mermaid.parse('wrong \n a --> b', { suppressErrors: true }));
// false
console.log(await mermaid.parse('wrong \n a --> b', { suppressErrors: false }));
// throws Error
console.log(await mermaid.parse('wrong \n a --> b'));
// throws Error
Defined in
packages/mermaid/src/mermaid.ts:441
parseError
• Optional
parseError: ParseErrorFunction
Defined in
packages/mermaid/src/mermaid.ts:435
registerExternalDiagrams
• registerExternalDiagrams: (diagrams
: ExternalDiagramDefinition
[], opts
: { lazyLoad?
: boolean
= true }) => Promise
<void
>
Type declaration
▸ (diagrams
, opts?
): Promise
<void
>
Used to register external diagram types.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
diagrams |
ExternalDiagramDefinition [] |
undefined |
Array of ExternalDiagramDefinition. |
opts |
Object |
{} |
If opts.lazyLoad is false, the diagrams will be loaded immediately. |
opts.lazyLoad? |
boolean |
true |
- |
Returns
Promise
<void
>
Defined in
packages/mermaid/src/mermaid.ts:449
registerIconPacks
• registerIconPacks: (iconLoaders
: IconLoader
[]) => void
Type declaration
▸ (iconLoaders
): void
Parameters
Name | Type |
---|---|
iconLoaders |
IconLoader [] |
Returns
void
Defined in
packages/mermaid/src/mermaid.ts:454
registerLayoutLoaders
• registerLayoutLoaders: (loaders
: LayoutLoaderDefinition
[]) => void
Type declaration
▸ (loaders
): void
Parameters
Name | Type |
---|---|
loaders |
LayoutLoaderDefinition [] |
Returns
void
Defined in
packages/mermaid/src/mermaid.ts:448
render
• render: (id
: string
, text
: string
, svgContainingElement?
: Element
, positions?
: Positions
) => Promise
<RenderResult
>
Type declaration
▸ (id
, text
, svgContainingElement?
, positions?
): Promise
<RenderResult
>
Parameters
Name | Type |
---|---|
id |
string |
text |
string |
svgContainingElement? |
Element |
positions? |
Positions |
Returns
Promise
<RenderResult
>
Defined in
packages/mermaid/src/mermaid.ts:442
run
• run: (options
: RunOptions
) => Promise
<void
>
Type declaration
▸ (options?
): Promise
<void
>
run
Function that goes through the document to find the chart definitions in there and render them.
The function tags the processed attributes with the attribute data-processed and ignores found elements with the attribute already set. This way the init function can be triggered several times.
graph LR;
a(Find elements)-->b{Processed}
b-->|Yes|c(Leave element)
b-->|No |d(Transform)
graph LR;
a(Find elements)-->b{Processed}
b-->|Yes|c(Leave element)
b-->|No |d(Transform)
Renders the mermaid diagrams
Parameters
Name | Type | Description |
---|---|---|
options |
RunOptions |
Optional runtime configs |
Returns
Promise
<void
>
Defined in
packages/mermaid/src/mermaid.ts:447
setParseErrorHandler
• setParseErrorHandler: (parseErrorHandler
: (err
: any
, hash
: any
) => void
) => void
Type declaration
▸ (parseErrorHandler
): void
setParseErrorHandler Alternative to directly setting parseError using:
mermaid.parseError = function (err, hash) {
forExampleDisplayErrorInGui(err); // do something with the error
};
This is provided for environments where the mermaid object can't directly have a new member added to it (eg. dart interop wrapper). (Initially there is no parseError member of mermaid).
Parameters
Name | Type | Description |
---|---|---|
parseErrorHandler |
(err : any , hash : any ) => void |
New parseError() callback. |
Returns
void
Defined in
packages/mermaid/src/mermaid.ts:452
startOnLoad
• startOnLoad: boolean