collab/mermaid/docs/config/8.6.0_docs.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/8.6.0_docs.md](../../packages/mermaid/src/docs/config/8.6.0_docs.md).
6dd74de6
6dd74de7# Version 8.6.0 Changes
6dd74de8
6dd74de9## [New Mermaid Live-Editor Beta](https://mermaid-js.github.io/docs/mermaid-live-editor-beta/#/edit/eyJjb2RlIjoiJSV7aW5pdDoge1widGhlbWVcIjogXCJmb3Jlc3RcIiwgXCJsb2dMZXZlbFwiOiAxIH19JSVcbmdyYXBoIFREXG4gIEFbQ2hyaXN0bWFzXSAtLT58R2V0IG1vbmV5fCBCKEdvIHNob3BwaW5nKVxuICBCIC0tPiBDe0xldCBtZSB0aGlua31cbiAgQyAtLT58T25lfCBEW0xhcHRvcF1cbiAgQyAtLT58VHdvfCBFW2lQaG9uZV1cbiAgQyAtLT58VGhyZWV8IEZbZmE6ZmEtY2FyIENhcl1cblx0XHQiLCJtZXJtYWlkIjp7InRoZW1lIjoiZGFyayJ9fQ)
6dd74de10
6dd74de11## [CDN](https://www.jsdelivr.com/package/npm/mermaid)
6dd74de12
6dd74de13With version 8.6.0 comes the release of directives for mermaid, a new system for modifying configurations, with the aim of establishing centralized, sane defaults and simple implementation.
6dd74de14
6dd74de15`directives` allow for a single-use overwriting of `config`, as it has been discussed in [Configurations](../config/configuration.md).
6dd74de16This allows site Diagram Authors to instantiate temporary modifications to `config` through the use of [Directives](directives.md), which are parsed before rendering diagram definitions. This allows the Diagram Authors to alter the appearance of the diagrams.
6dd74de17
6dd74de18**A likely application for this is in the creation of diagrams/charts inside company/organizational webpages, that rely on mermaid for diagram and chart rendering.**
6dd74de19
6dd74de20the `init` directive is the main method of configuration for Site and Current Levels.
6dd74de21
6dd74de22The three levels of are Configuration, Global, Site and Current.
6dd74de23
6dd74de24| Level of Configuration | Description |
6dd74de25| ---------------------- | ----------------------------------- |
6dd74de26| Global Configuration | Default Mermaid Configurations |
6dd74de27| Site Configuration | Configurations made by site owner |
6dd74de28| Current Configuration | Configurations made by Implementors |
6dd74de29
6dd74de30# Limits to Modifying Configurations
6dd74de31
6dd74de32**secure Array**
6dd74de33
6dd74de34| Parameter | Description | Type | Required | Values |
6dd74de35| --------- | ------------------------------------------------ | ----- | -------- | -------------- |
6dd74de36| secure | Array of parameters excluded from init directive | Array | Required | Any parameters |
6dd74de37
6dd74de38The modifiable parts of the Configuration are limited by the secure array, which is an array of immutable parameters, this array can be expanded by site owners.
6dd74de39
6dd74de40**Notes**: secure arrays work like nesting dolls, with the Global Configurations’ secure array holding the default and immutable list of immutable parameters, or the smallest doll, to which site owners may add to, but implementors may not modify it.
6dd74de41
6dd74de42# Secure Arrays
6dd74de43
6dd74de44Site owners can add to the **secure** array using this command:
6dd74de45mermaidAPI.initialize( { startOnLoad: true, secure: \['parameter1', 'parameter2'] } );
6dd74de46
6dd74de47Default values for the `secure array` consists of: \['secure', 'securityLevel', 'startOnLoad', 'maxTextSize']. These default values are immutable.
6dd74de48
6dd74de49Implementors can only modify configurations using directives, and cannot change the `secure` array.
6dd74de50
6dd74de51# Modifying Configurations and directives:
6dd74de52
6dd74de53The Two types of directives: are `init` (or `initialize`) and `wrap`.
6dd74de54
6dd74de55> **Note**
6dd74de56> All directives are enclosed in `%%{ }%%`
6dd74de57
6dd74de58Older versions of mermaid will not parse directives because `%%` will comment out the directive. This makes the update backwards-compatible.
6dd74de59
6dd74de60# Init
6dd74de61
6dd74de62`init`, or `initialize`: this directive gives the user the ability to overwrite and change the values for any configuration parameters not set in the secure array.
6dd74de63
6dd74de64| Parameter | Description | Type | Required | Values |
6dd74de65| --------- | ----------------------- | --------- | -------- | ----------------------------------------------- |
6dd74de66| init | modifies configurations | Directive | Optional | Any parameters not included in the secure array |
6dd74de67
6dd74de68> **Note**
6dd74de69> init would be an argument-directive: `%%{init: { **insert argument here**}}%%`
6dd74de70>
6dd74de71> The json object that is passed as {**argument** } must be valid, quoted json or it will be ignored.
6dd74de72> **for example**:
6dd74de73>
6dd74de74> `%%{init: {"theme": "default", "logLevel": 1 }}%%`
6dd74de75>
6dd74de76> Configurations that are passed through init cannot change the parameters in a secure array at a higher level. In the event of a collision, mermaid will give priority to secure arrays and parse the request without changing the values of those parameters in conflict.
6dd74de77>
6dd74de78> When deployed within code, init is called before the graph/diagram description.
6dd74de79
6dd74de80**for example**:
6dd74de81
6dd74de82```mermaid-example
6dd74de83%%{init: {"theme": "default", "logLevel": 1 }}%%
6dd74de84 graph LR
6dd74de85 a-->b
6dd74de86 b-->c
6dd74de87 c-->d
6dd74de88 d-->e
6dd74de89 e-->f
6dd74de90 f-->g
6dd74de91 g-->
6dd74de92```
6dd74de93
6dd74de94```mermaid
6dd74de95%%{init: {"theme": "default", "logLevel": 1 }}%%
6dd74de96 graph LR
6dd74de97 a-->b
6dd74de98 b-->c
6dd74de99 c-->d
6dd74de100 d-->e
6dd74de101 e-->f
6dd74de102 f-->g
6dd74de103 g-->
6dd74de104```
6dd74de105
6dd74de106# Wrap
6dd74de107
6dd74de108| Parameter | Description | Type | Required | Values |
6dd74de109| --------- | ----------------------------- | --------- | -------- | ---------- |
6dd74de110| wrap | a callable text-wrap function | Directive | Optional | %%{wrap}%% |
6dd74de111
6dd74de112> **Note**
6dd74de113> Wrap is a function that is currently only deployable for sequence diagrams.
6dd74de114>
6dd74de115> `Wrap respects a manually added <br>, so if the user wants to break up their text, they have full control over line breaks by adding <br> tags.`
6dd74de116>
6dd74de117> It is a non-argument directive and can be executed thusly:
6dd74de118>
6dd74de119> `%%{wrap}%%` .
6dd74de120
6dd74de121**An example of text wrapping in a sequence diagram**:
6dd74de122
6dd74de123!\[Image showing wrapped text]\(img/wrapped text.png)
6dd74de124
6dd74de125# Resetting Configurations:
6dd74de126
6dd74de127There are two more functions in the mermaidAPI that can be called by site owners: **reset** and **globalReset**.
6dd74de128
6dd74de129**reset**: resets the configuration to whatever the last configuration was. This can be done to undo more recent changes set from the last mermaidAPI.initialize({...}) configuration.
6dd74de130
6dd74de131**globalReset** will reset both the current configuration AND the site configuration back to the global defaults.
6dd74de132
6dd74de133**Notes**: Both `reset` and `globalReset` are only available to site owners, and as such implementors have to edit their configs using `init`.
6dd74de134
6dd74de135# Additional Utils to mermaid
6dd74de136
6dd74de137• **memoize**: simple caching for computationally expensive functions, reducing rendering time by about 90%.
6dd74de138
6dd74de139• **assignWithDepth** - an improvement on previous functions with config.js and `Object.assign`. The purpose of this function is to provide a sane mechanism for merging objects, similar to `object.assign`, but with depth.
6dd74de140
6dd74de141Example of **assignWithDepth**:
6dd74de142
6dd74de143![Image showing assignWithDepth](img/assignWithDepth.png)
6dd74de144
6dd74de145Example of **object.Assign**:
6dd74de146
6dd74de147!\[Image showing object.assign without depth]\(img/object.assign without depth.png)
6dd74de148
6dd74de149• **calculateTextDimensions**, **calculateTextWidth**, and **calculateTextHeight** - for measuring text dimensions, width and height.
6dd74de150
6dd74de151**Notes**: For more information on usage, parameters, and return info for these new functions take a look at the jsdocs for them in the utils package.
6dd74de152
6dd74de153# New API Requests Introduced in Version 8.6.0
6dd74de154
6dd74de155## setSiteConfig
6dd74de156
6dd74de157| Function | Description | Type | Values | Parameters | Returns |
6dd74de158| --------------- | ------------------------------------- | ----------- | --------------------------------------- | ---------- | ---------- |
6dd74de159| `setSiteConfig` | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array | conf | siteConfig |
6dd74de160
6dd74de161> **Note**
6dd74de162> Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
6dd74de163> the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
6dd74de164> to the defaultConfig
6dd74de165> Note: currentConfig is set in this function。
6dd74de166> Default value: will mirror Global Config
6dd74de167
6dd74de168## getSiteConfig
6dd74de169
6dd74de170| Function | Description | Type | Values |
6dd74de171| --------------- | --------------------------------------------------- | ----------- | ---------------------------------- |
6dd74de172| `getSiteConfig` | Returns the current `siteConfig` base configuration | Get Request | Returns Any Values in `siteConfig` |
6dd74de173
6dd74de174> **Note**
6dd74de175> Returns any values in siteConfig.
6dd74de176
6dd74de177## setConfig
6dd74de178
6dd74de179| Function | Description | Type | Values | Parameters | Returns |
6dd74de180| ----------- | ------------------------------------------ | ----------- | --------------------------------- | ---------- | ---------------------------------------------- |
6dd74de181| `setConfig` | Sets the `currentConfig` to desired values | Put Request | Any Values, those in secure array | conf | `currentConfig` merged with the sanitized conf |
6dd74de182
6dd74de183> **Note**
6dd74de184> Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
6dd74de185> values found in conf with key found in siteConfig.secure will be replaced with the corresponding
6dd74de186> siteConfig value.
6dd74de187
6dd74de188## getConfig
6dd74de189
6dd74de190| Function | Description | Type | Return Values |
6dd74de191| ----------- | --------------------------- | ----------- | ------------------------------- |
6dd74de192| `getConfig` | Obtains the `currentConfig` | Get Request | Any Values from `currentConfig` |
6dd74de193
6dd74de194> **Note**
6dd74de195> Returns any values in currentConfig.
6dd74de196
6dd74de197## sanitize
6dd74de198
6dd74de199| Function | Description | Type | Values |
6dd74de200| ---------- | ---------------------------------------- | -------------- | ------ |
6dd74de201| `sanitize` | Sets the `siteConfig` to desired values. | Put Request(?) | None |
6dd74de202
6dd74de203> **Note**
6dd74de204> modifies options in-place
6dd74de205> Ensures options parameter does not attempt to override siteConfig secure keys.
6dd74de206
6dd74de207## reset
6dd74de208
6dd74de209| Function | Description | Type | Required | Values | Parameter |
6dd74de210| -------- | ------------------------------ | ----------- | -------- | ------ | --------- |
6dd74de211| `reset` | Resets `currentConfig` to conf | Put Request | Required | None | conf |
6dd74de212
6dd74de213## conf
6dd74de214
6dd74de215| Parameter | Description | Type | Required | Values |
6dd74de216| --------- | ------------------------------------------------------------ | ---------- | -------- | -------------------------------------------- |
6dd74de217| `conf` | base set of values, which `currentConfig` could be reset to. | Dictionary | Required | Any Values, with respect to the secure Array |
6dd74de218
6dd74de219> **Note**
6dd74de220> default: current siteConfig (optional, default `getSiteConfig()`)
6dd74de221
6dd74de222## For more information, read [Setup](./setup/README.md).