Interface: Mermaid β
Defined in: packages/mermaid/src/mermaid.ts:433
Properties β
contentLoaded() β
contentLoaded: () =>
void
Defined in: packages/mermaid/src/mermaid.ts:451
##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
detectType() β
detectType: (
text,config?) =>string
Defined in: packages/mermaid/src/mermaid.ts:453
Detects the type of the graph text.
Takes into consideration the possible existence of an %%init directive
Parameters β
text β
string
The text defining the graph. For example:
Code:
%%{initialize: {"startOnLoad": true, logLevel: "fatal" }}%%
graph LR
a-->b
b-->c
c-->d
d-->e
e-->f
f-->g
g-->h
config? β
The mermaid config.
Returns β
string
A graph definition key
getRegisteredDiagramsMetadata() β
getRegisteredDiagramsMetadata: () =>
Pick<ExternalDiagramDefinition,"id">[]
Defined in: packages/mermaid/src/mermaid.ts:455
Gets the metadata for all registered diagrams. Currently only the id is returned.
Returns β
Pick<ExternalDiagramDefinition, "id">[]
An array of objects with the id of the diagram.
init() β
init: (
config?,nodes?,callback?) =>Promise<void>
Defined in: packages/mermaid/src/mermaid.ts:446
init β
Parameters β
config? β
Deprecated, please set configuration in initialize.
nodes? β
Default: .mermaid. One of the following:
- A DOM Node
- An array of DOM nodes (as would come from a jQuery selector)
- A W3C selector, a la
.mermaid
string | HTMLElement | NodeListOf<HTMLElement>
callback? β
(id) => unknown
Called once for each rendered diagram's id.
Returns β
Promise<void>
Deprecated β
Use initialize and run instead.
Renders the mermaid diagrams
Deprecated β
Use initialize and run instead.
initialize() β
initialize: (
config) =>void
Defined in: packages/mermaid/src/mermaid.ts:450
Used to set configurations for mermaid. This function should be called before the run function.
Parameters β
config β
Configuration object for mermaid.
Returns β
void
mermaidAPI β
mermaidAPI:
Readonly<{defaultConfig:MermaidConfig;getConfig: () =>MermaidConfig;getDiagramFromText: (text,metadata) =>Promise<Diagram>;getSiteConfig: () =>MermaidConfig;globalReset: () =>void;initialize: (userOptions) =>void;parse: {(text,parseOptions):Promise<false|ParseResult>; (text,parseOptions?):Promise<ParseResult>; };render: (id,text,svgContainingElement?) =>Promise<RenderResult>;reset: () =>void;setConfig: (conf) =>MermaidConfig;updateSiteConfig: (conf) =>MermaidConfig; }>
Defined in: packages/mermaid/src/mermaid.ts:440
Internal
Deprecated β
Use parse and render instead. Please open a discussion if your use case does not fit the new API.
parse() β
parse: {(
text,parseOptions):Promise<false|ParseResult>; (text,parseOptions?):Promise<ParseResult>; }
Defined in: packages/mermaid/src/mermaid.ts:441
Call Signature β
(
text,parseOptions):Promise<false|ParseResult>
Parse the text and validate the syntax.
Parameters β
text β
string
The mermaid diagram definition.
parseOptions β
ParseOptions & object
Options for parsing.
Returns β
Promise<false | ParseResult>
An object with the diagramType set to type of the diagram if valid. Otherwise false if parseOptions.suppressErrors is true.
See β
Throws β
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
Call Signature β
(
text,parseOptions?):Promise<ParseResult>
Parse the text and validate the syntax.
Parameters β
text β
string
The mermaid diagram definition.
parseOptions? β
Options for parsing.
Returns β
Promise<ParseResult>
An object with the diagramType set to type of the diagram if valid. Otherwise false if parseOptions.suppressErrors is true.
See β
Throws β
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
parseError? β
optionalparseError:ParseErrorFunction
Defined in: packages/mermaid/src/mermaid.ts:435
registerExternalDiagrams() β
registerExternalDiagrams: (
diagrams,opts) =>Promise<void>
Defined in: packages/mermaid/src/mermaid.ts:449
Used to register external diagram types.
Parameters β
diagrams β
Array of ExternalDiagramDefinition.
opts β
If opts.lazyLoad is false, the diagrams will be loaded immediately.
lazyLoad? β
boolean = true
Returns β
Promise<void>
registerIconPacks() β
registerIconPacks: (
iconLoaders) =>void
Defined in: packages/mermaid/src/mermaid.ts:454
Parameters β
iconLoaders β
Returns β
void
registerLayoutLoaders() β
registerLayoutLoaders: (
loaders) =>void
Defined in: packages/mermaid/src/mermaid.ts:448
Parameters β
loaders β
Returns β
void
render() β
render: (
id,text,svgContainingElement?) =>Promise<RenderResult>
Defined in: packages/mermaid/src/mermaid.ts:442
Renders the diagram, holding the diagram config scope for exactly as long as the render. Leaving it set would make getConfig() report the last diagram's appearance as the global answer for every caller between renders.
Parameters β
id β
string
text β
string
svgContainingElement? β
Element
Returns β
Promise<RenderResult>
run() β
run: (
options) =>Promise<void>
Defined in: packages/mermaid/src/mermaid.ts:447
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.
Code:
graph LR;
a(Find elements)-->b{Processed}
b-->|Yes|c(Leave element)
b-->|No |d(Transform)
Renders the mermaid diagrams
Parameters β
options β
RunOptions = ...
Optional runtime configs
Returns β
Promise<void>
setParseErrorHandler() β
setParseErrorHandler: (
parseErrorHandler) =>void
Defined in: packages/mermaid/src/mermaid.ts:452
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 β
parseErrorHandler β
(err, hash) => void
New parseError() callback.
Returns β
void
startOnLoad β
startOnLoad:
boolean
Defined in: packages/mermaid/src/mermaid.ts:434