mermaid library

The JS interop library itself.

Classes

Config
FlowChartConfig
GnattConfig
LogLevel
Can be used for psassing allowed num values to Config.logLevel.
MermaidApi
Wrapper for methods calls so they can be called from MermaidApi. This more closely matches the docs for the mermaid javascript library. (Note: MermaidApi is used as name instead of mermaidAPI because of Dart naming conventions). In some cases we do not call the underlying mermaidAPI version but instead we call the mermaid version because of inconsistencies in mermaid 9.0.1 mermaidAPI object code and behavior.
SecurityLevel
Can be used for passing allowed strings to Config.securityLevel.
SequenceDiagramConfig
Theme
Can be used for passing allowed strings to Config.theme.

Properties

mermaidAPI MermaidApi
This is here to simply allow use of 'mermaidAPI.xyz()' as javascript docs will be showing.
getter/setter pair

Functions

mermaidApiGetConfig() Config
Calls mermaidAPI.getConfig() and returns the current configuration object.
mermaidApiInitialize(Config options) → void
Calls mermaidAPI.initialize
mermaidApiParse(String text) bool
Used to test diagram code before calling render(). Returns true if the diagram syntax is valid. If mermaidSetParseErrorHandler has been used to set a parseError() handler then this method will return false if the diagram syntax is invalid. (If no parseError() handler has been set then parse() will throw an exception in javascript as render() would with invalid syntax). NOTE: Note as of mermaid version 9.0.1 the behavior of parse() method has a BUG
mermaidApiRender(String idOfAScratchDivToCreate, String diagramDef, [void bindingCallback(String svgCode, void (Element element))?, Element? scratchElementWhereMermaidWillMakeSVG]) String
Used to render a graph and receive have the source for the created SVG file. The complete SVG file will be returned and sent to the bindingCallback if one is provided. The bindingCallback callback only needs to be used if you want to use the bindingCallback to allow mermaid to bind event handlers to the element within the DOM that you are placing the SVG file within. idOfAScratchDivToCreate is a NEVER BEFORE USED html element ID that can use used to create a scratch div (or iframe for sandbox mode). This element will BE REMOVED from the dom before this returns, so DO NOT pass in id's of existing elements. NOTE: This MUST BE a id that was NEVER passed into render() previously - re-using the same scratch ID will not work. The DART mermaidApi.render() wrapper function will automatically generate random IDs if '' or null is passed for the idOfAScratchDivToCreate parameter. diagramDef is the source for the diagram being rendered. bindingCallback is the callback that will be called with the SVG code and binding callback-callback. scratchElementWhereMermaidWillMakeSVG is a scratch div within the dom that mermaid can use. The idOfAScratchDivToCreate must STILL BE a unique ID when using the scratchElementWhereMermaidWillMakeSVG parameter. The underlying JS mermaid library is very peculiar behavior here that I cannot explain.
mermaidInit(Config? configObject, Object? selectorStringOrElementOrListOfElements) → void
This wraps the native mermaid.init() with an additional call to mermaid.Initialize() so the Config parameter is honored. (the native mermaid.init() always INGORES the configuration object, which can be confusing because mermaid docs don't always indicate that). If no selector is specified than all elements with class="mermaid" are targeted configObject a configuration object that will be sent to mermaidInitialize. selectorStringOrElementOrListOfElements A W3C selector String, or an Element, or an List
mermaidInitialize([Config? config]) → void
Initialize mermaid settings. Pass a configuration object as described in mermaid configation object documentation.
mermaidInitNative(Config? ingored, Object? selectorStringOrElementOrListOfElements) → void
mermaid.init By default, mermaid.init will be called when the document is ready, finding all elements with class="mermaid". If you are adding content after mermaid is loaded, or otherwise need finer-grained control of this behavior, you can call init yourself with:
mermaidRender(Object? selectorStringOrElementOrListOfElements) → void
Our wrapper function that calls JS mermaid.init() and can be used to render the specified mermaid element(s). selectorStringOrElementOrListOfElements A W3C selector String, or an Element, or an List
mermaidReset() Config
Resets all configuration and state information to defaults. Calls mermaidApi.reset()
mermaidSetParseErrorHandler(void parseError(String error, String hash)) → void
Used to set a handler to be called when invalid diagram syntax is encountered. The definition of the function should match void parseError(String err,String hash). NOTE: As of mermaid version 9.0.1 this method does not exists, but I have submitted a PR that adds this method. The reason for this is that we cannot (from dart interop) add a mermaid.parseError member when none previously existed. (from within javascript this was done simply as mermaid.parseError = function(err,hash) {})