2020-07-09 13:12:07 +02:00
# Version 8.6.0 Changes
2020-07-13 23:45:55 +02:00
2020-07-20 18:30:05 +02:00
**Edit this Page** [![N|Solid ](./img/GitHub-Mark-32px.png )](https://github.com/mermaid-js/mermaid/blob/develop/docs/8.6.0_docs.md)
2020-07-09 13:12:07 +02:00
2020-07-13 23:45:55 +02:00
## [New Mermaid Live-Editor Beta](https://mermaid-js.github.io/docs/mermaid-live-editor-beta/#/edit/eyJjb2RlIjoiJSV7aW5pdDoge1widGhlbWVcIjogXCJmb3Jlc3RcIiwgXCJsb2dMZXZlbFwiOiAxIH19JSVcbmdyYXBoIFREXG4gIEFbQ2hyaXN0bWFzXSAtLT58R2V0IG1vbmV5fCBCKEdvIHNob3BwaW5nKVxuICBCIC0tPiBDe0xldCBtZSB0aGlua31cbiAgQyAtLT58T25lfCBEW0xhcHRvcF1cbiAgQyAtLT58VHdvfCBFW2lQaG9uZV1cbiAgQyAtLT58VGhyZWV8IEZbZmE6ZmEtY2FyIENhcl1cblx0XHQiLCJtZXJtYWlkIjp7InRoZW1lIjoiZGFyayJ9fQ)
2020-07-13 23:42:57 +02:00
2020-07-13 23:45:55 +02:00
## [CDN](https://unpkg.com/mermaid/)
2020-07-09 14:28:47 +02:00
2020-07-26 06:36:12 +02:00
With 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.
2020-07-09 13:12:07 +02:00
2020-07-26 06:36:12 +02:00
`directives` allow for a diagram specific overriding of `config` , as it has been discussed in [Configurations ](./Setup.md ).
This allows site users to input modifications to `config` alongside diagram definitions, when creating diagrams on a private webpage that supports mermaid.
**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.**
the `init` directive is the main method of configuration for Site and Current Levels.
2020-07-09 13:12:07 +02:00
The three levels of are Configuration, Global, Site and Current.
| Level of Configuration | Description |
| --- | --- |
| Global Configuration| Default Mermaid Configurations|
| Site Configuration| Configurations made by site owner|
2020-07-09 14:14:20 +02:00
| Current Configuration| Configurations made by Implementors|
2020-07-09 13:12:07 +02:00
# Limits to Modifying Configurations
2020-07-29 01:42:08 +02:00
**secure Array**
2020-07-09 13:12:07 +02:00
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| secure | Array of parameters excluded from init directive| Array | Required | Any parameters|
The 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.
2020-07-09 14:15:47 +02:00
**Notes**: secure arrays work like nesting dolls, with the Global Configurations’ secure array being 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.
# Secure Arrays
2020-07-09 13:12:07 +02:00
Site owners can add to the **secure** array using this command:
mermaidAPI.initialize( { startOnLoad: true, secure: ['parameter1', 'parameter2'] } );
2020-07-26 06:36:12 +02:00
default values for the `secure array` consists of: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize']. These default values are immutable.
2020-07-09 13:12:07 +02:00
2020-07-26 06:36:12 +02:00
Implementors can only modify configurations using directives, but cannot change the `secure` array.
2020-07-09 14:14:20 +02:00
2020-07-09 13:12:07 +02:00
# Modifying Configurations and directives:
2020-07-26 06:36:12 +02:00
The Two types of directives: are `init` or `initialize` and `wrap` .
2020-07-09 13:46:55 +02:00
2020-07-24 03:33:11 +02:00
**Notes**: All directives are enclosed in `%%{ }%%.`
2020-07-09 13:12:07 +02:00
2020-07-26 06:36:12 +02:00
Older versions of mermaid will not parse directives because `%%` will comment out the directive. This makes the update backward compatible.
2020-07-09 13:12:07 +02:00
# Init
2020-07-26 06:36:12 +02:00
`init` , or `initialize` : the init or initialize directive gives the user the ability to overwrite and change the values for configuration parameters, with respect to the secure array that is in effect.
2020-07-09 13:12:07 +02:00
2020-07-09 15:10:07 +02:00
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| init | modifies configurations| Directive| Optional | Any parameters not included in the secure array|
2020-07-13 16:39:52 +02:00
**Notes:**
2020-07-09 15:10:07 +02:00
2020-07-24 03:33:11 +02:00
init would be an argument-directive: `%%{init: { **insert argument here**}}%%`
2020-07-09 15:10:07 +02:00
The json object that is passed as {**argument** } must be valid, quoted json or it will be ignored.
**for example** :
2020-07-13 23:46:47 +02:00
2020-07-24 03:33:11 +02:00
`%%{init: {"theme": default, "logLevel": 1 }}%%`
2020-07-09 13:12:07 +02:00
2020-07-09 15:10:07 +02:00
Configurations that are passed through init cannot change the parameters in secure arrays of higher levels. In the event of a conflict, mermaid will give priority to secure arrays and parse the request, without changing the values of the parameters in conflict.
2020-07-09 13:12:07 +02:00
When deployed within code, init is called before the graph/diagram description.
**for example**:
2020-07-24 03:33:11 +02:00
```
2020-07-09 13:12:07 +02:00
%%{init: {"theme": "default", "logLevel": 1 }}%%
graph LR
a-->b
b-->c
c-->d
d-->e
e-->f
f-->g
g-->
2020-07-24 03:33:11 +02:00
```
2020-07-09 13:12:07 +02:00
# Wrap
2020-07-09 15:10:07 +02:00
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| wrap | a callable text-wrap function| Directive| Optional | %%{wrap}%%|
**Notes:**
2020-07-09 13:12:07 +02:00
Wrap is a function that is currently only deployable for sequence diagrams.
2020-07-09 15:10:07 +02:00
wrap respects manually added < br \> so if the user wants to break up their text , they have full control over those breaks by adding their own < br \> tags .
2020-07-09 13:12:07 +02:00
It is a non-argument directive and can be executed thusly:
2020-07-09 14:23:30 +02:00
2020-07-24 03:33:11 +02:00
`%%{wrap}%%` .
2020-07-09 13:46:55 +02:00
2020-07-09 14:25:15 +02:00
**an example of text wrapping in a sequence diagram**:
2020-07-09 13:46:55 +02:00
2020-07-13 23:42:57 +02:00
![Image showing wrapped text ](./img/wrapped%20text.png )
2020-07-09 13:46:55 +02:00
2020-07-09 13:12:07 +02:00
# Resetting Configurations:
There are two more functions in the mermaidAPI that can be called by site owners: **reset** and **globalReset** .
**reset**: resets the configuration to whatever the last configuration was. This can be done to undo more recent changes to the last mermaidAPI.initialize({...}) configuration.
**globalReset** will reset both the current configuration AND the site configuration back to the global defaults.
**Notes**: both reset and globalReset are only available to site owners, as such implementors would have to edit their configs with init.
# Additional Utils to mermaid
• **memoize** : simple caching for computationally expensive functions. It reduces the rendering time for computationally intensive diagrams by about 90%.
• **assignWithDepth** - this is 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.
2020-07-09 13:46:55 +02:00
2020-07-09 13:12:07 +02:00
Example of **assignWithDepth** :
2020-07-13 23:42:57 +02:00
![Image showing assignWithDepth ](./img/assignWithDepth.png )
2020-07-09 13:46:55 +02:00
2020-07-09 13:12:07 +02:00
Example of **object.Assign** :
2020-07-09 13:46:55 +02:00
2020-07-13 23:42:57 +02:00
![Image showing object.assign without depth ](./img/object.assign%20without%20depth.png )
2020-07-09 13:46:55 +02:00
2020-07-09 13:12:07 +02:00
• **calculateTextDimensions, calculateTextWidth,** and **calculateTextHeight** - for measuring text dimensions, width and height.
**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.
2020-07-15 04:27:00 +02:00
# New API Requests Introduced in Version 8.6.0
## setSiteConfig
2020-07-15 04:33:06 +02:00
| Function | Description | Type | Values |Parameters|Returns|
| --------- | ------------------- | ------- | ------------------ | ------------------ | ------------------ |
| setSiteConfig|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|conf|siteConfig|
2020-07-15 04:27:00 +02:00
**Notes:
Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
to the defaultConfig
Note: currentConfig is set in this function
2020-07-15 04:37:05 +02:00
Default value: At default, will mirror Global Config**
2020-07-15 04:27:00 +02:00
## getSiteConfig
| Function | Description | Type | Values |
| --------- | ------------------- | ------- | ------------------ |
| setSiteConfig|Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig|
**Notes :
2020-07-15 04:37:05 +02:00
Returns any values in siteConfig.**
2020-07-15 04:27:00 +02:00
## setConfig
2020-07-15 04:37:05 +02:00
| Function | Description | Type | Values |Parameters|Returns|
| --------- | ------------------- | ------- | ------------------ |----------|-------|
| setSiteConfig|Sets the siteConfig to desired values | Put Request| Any Values, those in secure array|conf|currentConfig merged with the sanitized conf|
2020-07-15 04:27:00 +02:00
**Notes :
Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
values found in conf with key found in siteConfig.secure will be replaced with the corresponding
2020-07-15 04:33:06 +02:00
siteConfig value.**
2020-07-15 04:27:00 +02:00
## getConfig
| Function | Description | Type | Return Values |
| --------- | ------------------- | ------- | ------------------ |
| getConfig |Obtains the currentConfig | Get Request | Any Values from currentConfig|
**Notes :
2020-07-15 04:33:06 +02:00
Returns any values in currentConfig.**
2020-07-15 04:27:00 +02:00
## sanitize
2020-07-15 04:33:06 +02:00
| Function | Description | Type | Values |
2020-07-15 04:27:00 +02:00
| --------- | ------------------- | ------- | ------------------ |
2020-07-15 04:33:06 +02:00
| sanitize |Sets the siteConfig to desired values. | Put Request(?) |None|
2020-07-15 04:27:00 +02:00
2020-07-15 04:33:06 +02:00
**Note: modifies options in-place
Ensures options parameter does not attempt to override siteConfig secure keys.**
2020-07-15 04:27:00 +02:00
## reset
2020-07-15 04:33:06 +02:00
| Function | Description | Type | Required | Values |Parameter|
| --------- | -------------------| ------- | -------- | ------------------ |---------|
| reset|Resets currentConfig to conf| Put Request | Required | None| conf|
2020-07-15 04:27:00 +02:00
2020-07-15 04:33:06 +02:00
## conf
2020-07-15 04:27:00 +02:00
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| conf| base set of values, which currentConfig coul be reset to.| Dictionary | Required | Any Values, with respect to the secure Array|
**Notes :
2020-07-15 04:37:05 +02:00
default: current siteConfig (optional, default `getSiteConfig()` )**
2020-07-15 04:27:00 +02:00
2020-07-15 04:37:05 +02:00
## For more information, read [Setup ](https://mermaid-js.github.io/mermaid/#/Setup ).