Merged typescript changes

This commit is contained in:
Knut Sveidqvist
2022-09-05 11:22:17 +02:00
parent 047b7023a2
commit 01106caa59
202 changed files with 8325 additions and 4777 deletions

View File

@@ -15,19 +15,19 @@ the `init` directive is the main method of configuration for Site and Current Le
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|
| Current Configuration| Configurations made by Implementors|
| Level of Configuration | Description |
| ---------------------- | ----------------------------------- |
| Global Configuration | Default Mermaid Configurations |
| Site Configuration | Configurations made by site owner |
| Current Configuration | Configurations made by Implementors |
# Limits to Modifying Configurations
**secure Array**
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| secure | Array of parameters excluded from init directive| Array | Required | Any parameters|
| 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.
@@ -43,6 +43,7 @@ Default values for the `secure array` consists of: ['secure', 'securityLevel', '
Implementors can only modify configurations using directives, and cannot change the `secure` array.
# Modifying Configurations and directives:
The Two types of directives: are `init` (or `initialize`) and `wrap`.
```note
@@ -52,12 +53,12 @@ All directives are enclosed in `%%{ }%%`
Older versions of mermaid will not parse directives because `%%` will comment out the directive. This makes the update backwards-compatible.
# Init
`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.
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| init | modifies configurations| Directive| Optional | Any parameters not included in the secure array|
| Parameter | Description | Type | Required | Values |
| --------- | ----------------------- | --------- | -------- | ----------------------------------------------- |
| init | modifies configurations | Directive | Optional | Any parameters not included in the secure array |
```note
init would be an argument-directive: `%%{init: { **insert argument here**}}%%`
@@ -73,6 +74,7 @@ When deployed within code, init is called before the graph/diagram description.
```
**for example**:
```mmd
%%{init: {"theme": "default", "logLevel": 1 }}%%
graph LR
@@ -84,11 +86,12 @@ When deployed within code, init is called before the graph/diagram description.
f-->g
g-->
```
# Wrap
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| wrap | a callable text-wrap function| Directive| Optional | %%{wrap}%%|
| Parameter | Description | Type | Required | Values |
| --------- | ----------------------------- | --------- | -------- | ---------- |
| wrap | a callable text-wrap function | Directive | Optional | %%{wrap}%% |
```note
Wrap is a function that is currently only deployable for sequence diagrams.
@@ -104,8 +107,8 @@ It is a non-argument directive and can be executed thusly:
![Image showing wrapped text](img/wrapped%20text.png)
# 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 set from the last mermaidAPI.initialize({...}) configuration.
@@ -115,31 +118,30 @@ There are two more functions in the mermaidAPI that can be called by site owners
**Notes**: Both `reset` and `globalReset` are only available to site owners, and as such implementors have to edit their configs using `init`.
# Additional Utils to mermaid
**memoize**: simple caching for computationally expensive functions, reducing rendering time by about 90%.
**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.
**memoize**: simple caching for computationally expensive functions, reducing rendering time by about 90%.
**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.
Example of **assignWithDepth**:
![Image showing assignWithDepth](img/assignWithDepth.png)
Example of **object.Assign**:
![Image showing object.assign without depth](img/object.assign%20without%20depth.png)
**calculateTextDimensions**, **calculateTextWidth** and **calculateTextHeight** - for measuring text dimensions, width and height.
**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.
# New API Requests Introduced in Version 8.6.0
## setSiteConfig
| Function | Description | Type | Values |Parameters|Returns|
| --------- | ------------------- | ------- | ------------------ | ------------------ | ------------------ |
| `setSiteConfig`|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|conf|siteConfig|
| Function | Description | Type | Values | Parameters | Returns |
| --------------- | ------------------------------------- | ----------- | --------------------------------------- | ---------- | ---------- |
| `setSiteConfig` | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array | conf | siteConfig |
```note
Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
@@ -151,9 +153,9 @@ Default value: will mirror Global Config
## getSiteConfig
| Function | Description | Type | Values |
| --------- | ------------------- | ------- | ------------------ |
| `getSiteConfig`|Returns the current `siteConfig` base configuration | Get Request | Returns Any Values in `siteConfig`|
| Function | Description | Type | Values |
| --------------- | --------------------------------------------------- | ----------- | ---------------------------------- |
| `getSiteConfig` | Returns the current `siteConfig` base configuration | Get Request | Returns Any Values in `siteConfig` |
```note
Returns any values in siteConfig.
@@ -161,9 +163,9 @@ Returns any values in siteConfig.
## setConfig
| Function | Description | Type | Values |Parameters|Returns|
| --------- | ------------------- | ------- | ------------------ |----------|-------|
| `setConfig`|Sets the `currentConfig` to desired values | Put Request| Any Values, those in secure array|conf|`currentConfig` merged with the sanitized conf|
| Function | Description | Type | Values | Parameters | Returns |
| ----------- | ------------------------------------------ | ----------- | --------------------------------- | ---------- | ---------------------------------------------- |
| `setConfig` | Sets the `currentConfig` to desired values | Put Request | Any Values, those in secure array | conf | `currentConfig` merged with the sanitized conf |
```note
Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
@@ -173,10 +175,9 @@ siteConfig value.
## getConfig
| Function | Description | Type | Return Values |
| --------- | ------------------- | ------- | ------------------ |
| `getConfig` |Obtains the `currentConfig` | Get Request | Any Values from `currentConfig`|
| Function | Description | Type | Return Values |
| ----------- | --------------------------- | ----------- | ------------------------------- |
| `getConfig` | Obtains the `currentConfig` | Get Request | Any Values from `currentConfig` |
```note
Returns any values in currentConfig.
@@ -184,9 +185,9 @@ Returns any values in currentConfig.
## sanitize
| Function | Description | Type | Values |
| --------- | ------------------- | ------- | ------------------ |
| `sanitize` |Sets the `siteConfig` to desired values. | Put Request(?) |None|
| Function | Description | Type | Values |
| ---------- | ---------------------------------------- | -------------- | ------ |
| `sanitize` | Sets the `siteConfig` to desired values. | Put Request(?) | None |
```note
modifies options in-place
@@ -195,15 +196,15 @@ Ensures options parameter does not attempt to override siteConfig secure keys.
## reset
| Function | Description | Type | Required | Values |Parameter|
| --------- | -------------------| ------- | -------- | ------------------ |---------|
| `reset`|Resets `currentConfig` to conf| Put Request | Required | None| conf|
| Function | Description | Type | Required | Values | Parameter |
| -------- | ------------------------------ | ----------- | -------- | ------ | --------- |
| `reset` | Resets `currentConfig` to conf | Put Request | Required | None | conf |
## conf
| Parameter | Description |Type | Required | Values|
| --- | --- | --- | --- | --- |
| `conf`| base set of values, which `currentConfig` could be reset to.| Dictionary | Required | Any Values, with respect to the secure Array|
| Parameter | Description | Type | Required | Values |
| --------- | ------------------------------------------------------------ | ---------- | -------- | -------------------------------------------- |
| `conf` | base set of values, which `currentConfig` could be reset to. | Dictionary | Required | Any Values, with respect to the secure Array |
```note
default: current siteConfig (optional, default `getSiteConfig()`)