chore: more revision fixes

This commit is contained in:
Emerson Bottero
2022-10-27 19:58:39 -03:00
parent 289ac52900
commit ec5568b943
16 changed files with 133 additions and 165 deletions

View File

@@ -1,18 +0,0 @@
version: 2
updates:
- package-ecosystem: npm
open-pull-requests-limit: 10
directory: /
target-branch: develop
versioning-strategy: increase
schedule:
interval: weekly
day: monday
time: '07:00'
- package-ecosystem: github-actions
directory: /
target-branch: develop
schedule:
interval: weekly
day: monday
time: '07:00'

View File

@@ -1,5 +1,8 @@
name: Build and Deploy Docs
on: [push]
on:
push:
branches:
- master
permissions:
contents: write
jobs:

View File

@@ -1,22 +1,5 @@
// import { deflate } from 'pako';
// import { fromUint8Array } from 'js-base64';
import shiki from 'shiki';
// const serializeState = (state: State, serde: SerdeType = 'pako'): string => {
// if (serdes[serde] === undefined) {
// throw new Error(`Unknown serde type: ${serde}`);
// }
// const json = JSON.stringify(state);
// const serialized = serdes[serde].serialize(json);
// return `${serde}:${serialized}`;
// };
// const serialize = (state: string): string => {
// const data = new TextEncoder().encode(state);
// const compressed = deflate(data, { level: 9 });
// return fromUint8Array(compressed, true);
// };
const MermaidExample = async (md) => {
const fence = md.renderer.rules.fence.bind(md.renderer.rules);
@@ -34,10 +17,6 @@ const MermaidExample = async (md) => {
code =
'<h5>Code:</h5>' +
`<div class="language-mermaid">` +
// TODO: compute edit link!
// `<a class="edit" href="https://mermaid.live/edit#pako:${serialize(
// token.content
// )}" target=”_blank”>✒️</a>` +
`<button class="copy"></button><span class="lang">mermaid</span>` +
code +
'</div>';

View File

@@ -32,9 +32,10 @@ statement
In the extract of the grammar above, it is defined that a call to the setTitle method in the data object will be done when parsing and the title keyword is encountered.
```note
Make sure that the `parseError` function for the parser is defined and calling `mermaid.parseError`. This way a common way of detecting parse errors is provided for the end-user.
```
> **Note**\
> Make sure that the `parseError` function for the parser is defined and calling `mermaid.parseError`. This way a common way of detecting parse errors is provided for the end-user.
>
> >
For more info look in the example diagram type:

View File

@@ -52,9 +52,10 @@ Implementors can only modify configurations using directives, and cannot change
The Two types of directives: are `init` (or `initialize`) and `wrap`.
```note
All directives are enclosed in `%%{ }%%`
```
> **Note**\
> 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.
@@ -66,18 +67,19 @@ Older versions of mermaid will not parse directives because `%%` will comment ou
| --------- | ----------------------- | --------- | -------- | ----------------------------------------------- |
| init | modifies configurations | Directive | Optional | Any parameters not included in the secure array |
```note
init would be an argument-directive: `%%{init: { **insert argument here**}}%%`
The json object that is passed as {**argument** } must be valid, quoted json or it will be ignored.
**for example**:
`%%{init: {"theme": "default", "logLevel": 1 }}%%`
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.
When deployed within code, init is called before the graph/diagram description.
```
> **Note**\
> init would be an argument-directive: `%%{init: { **insert argument here**}}%%`
>
> The json object that is passed as {**argument** } must be valid, quoted json or it will be ignored.
> **for example**:
>
> `%%{init: {"theme": "default", "logLevel": 1 }}%%`
>
> 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.
>
> When deployed within code, init is called before the graph/diagram description.
>
> >
**for example**:
@@ -111,15 +113,16 @@ When deployed within code, init is called before the graph/diagram description.
| --------- | ----------------------------- | --------- | -------- | ---------- |
| wrap | a callable text-wrap function | Directive | Optional | %%{wrap}%% |
```note
Wrap is a function that is currently only deployable for sequence diagrams.
`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.`
It is a non-argument directive and can be executed thusly:
`%%{wrap}%%` .
```
> **Note**\
> Wrap is a function that is currently only deployable for sequence diagrams.
>
> `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.`
>
> It is a non-argument directive and can be executed thusly:
>
> `%%{wrap}%%` .
>
> >
**An example of text wrapping in a sequence diagram**:
@@ -161,13 +164,14 @@ Example of **object.Assign**:
| --------------- | ------------------------------------- | ----------- | --------------------------------------- | ---------- | ---------- |
| `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
the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
to the defaultConfig
Note: currentConfig is set in this function。
Default value: will mirror Global Config
```
> **Note**\
> 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。
> Default value: will mirror Global Config
>
> >
## getSiteConfig
@@ -175,9 +179,10 @@ Default value: will mirror Global Config
| --------------- | --------------------------------------------------- | ----------- | ---------------------------------- |
| `getSiteConfig` | Returns the current `siteConfig` base configuration | Get Request | Returns Any Values in `siteConfig` |
```note
Returns any values in siteConfig.
```
> **Note**\
> Returns any values in siteConfig.
>
> >
## setConfig
@@ -185,11 +190,12 @@ Returns any values in siteConfig.
| ----------- | ------------------------------------------ | ----------- | --------------------------------- | ---------- | ---------------------------------------------- |
| `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
values found in conf with key found in siteConfig.secure will be replaced with the corresponding
siteConfig value.
```
> **Note**\
> 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
> siteConfig value.
>
> >
## getConfig
@@ -197,9 +203,10 @@ siteConfig value.
| ----------- | --------------------------- | ----------- | ------------------------------- |
| `getConfig` | Obtains the `currentConfig` | Get Request | Any Values from `currentConfig` |
```note
Returns any values in currentConfig.
```
> **Note**\
> Returns any values in currentConfig.
>
> >
## sanitize
@@ -207,10 +214,11 @@ Returns any values in currentConfig.
| ---------- | ---------------------------------------- | -------------- | ------ |
| `sanitize` | Sets the `siteConfig` to desired values. | Put Request(?) | None |
```note
modifies options in-place
Ensures options parameter does not attempt to override siteConfig secure keys.
```
> **Note**\
> modifies options in-place
> Ensures options parameter does not attempt to override siteConfig secure keys.
>
> >
## reset
@@ -224,8 +232,9 @@ Ensures options parameter does not attempt to override siteConfig secure keys.
| --------- | ------------------------------------------------------------ | ---------- | -------- | -------------------------------------------- |
| `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()`)
```
> **Note**\
> default: current siteConfig (optional, default `getSiteConfig()`)
>
> >
## For more information, read [Setup](setup/README).

View File

@@ -14,7 +14,7 @@
#### Defined in
[config.ts:7](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L7)
config.ts:7
## Functions
@@ -36,7 +36,7 @@ Pushes in a directive to the configuration
#### Defined in
[config.ts:191](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L191)
config.ts:191
---
@@ -60,7 +60,7 @@ The currentConfig
#### Defined in
[config.ts:136](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L136)
config.ts:136
---
@@ -84,7 +84,7 @@ The siteConfig
#### Defined in
[config.ts:96](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L96)
config.ts:96
---
@@ -118,7 +118,7 @@ The siteConfig
#### Defined in
[config.ts:223](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L223)
config.ts:223
---
@@ -147,7 +147,7 @@ options in-place
#### Defined in
[config.ts:151](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L151)
config.ts:151
---
@@ -167,7 +167,7 @@ options in-place
#### Defined in
[config.ts:75](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L75)
config.ts:75
---
@@ -199,7 +199,7 @@ The currentConfig merged with the sanitized conf
#### Defined in
[config.ts:113](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L113)
config.ts:113
---
@@ -232,7 +232,7 @@ The new siteConfig
#### Defined in
[config.ts:61](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L61)
config.ts:61
---
@@ -253,7 +253,7 @@ The new siteConfig
#### Defined in
[config.ts:14](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L14)
config.ts:14
---
@@ -273,4 +273,4 @@ The new siteConfig
#### Defined in
[config.ts:79](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/config.ts#L79)
config.ts:79

View File

@@ -14,7 +14,7 @@
#### Defined in
[defaultConfig.ts:1869](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/defaultConfig.ts#L1869)
defaultConfig.ts:1869
---
@@ -39,7 +39,7 @@ mermaid.initialize({ flowchart: { htmlLabels: false } });
```html
<script>
var config = {
const config = {
startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
securityLevel: 'loose',
@@ -53,4 +53,4 @@ A description of each option follows below.
#### Defined in
[defaultConfig.ts:33](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/defaultConfig.ts#L33)
defaultConfig.ts:33

View File

@@ -20,7 +20,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
#### Defined in
[mermaidAPI.ts:485](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/mermaidAPI.ts#L485)
mermaidAPI.ts:485
## Functions
@@ -40,7 +40,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
#### Defined in
[mermaidAPI.ts:72](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/mermaidAPI.ts#L72)
mermaidAPI.ts:72
---
@@ -60,4 +60,4 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
#### Defined in
[mermaidAPI.ts:46](https://github.com/emersonbottero/mermaid/blob/455839c0/packages/mermaid/src/mermaidAPI.ts#L46)
mermaidAPI.ts:46

View File

@@ -156,9 +156,10 @@ You can create your own themes, by changing any of the given variables below. If
## Theme Variables Reference Table
```note
Variables that are unique to some diagrams can be affected by changes in Theme Variables
```
> **Note**\
> Variables that are unique to some diagrams can be affected by changes in Theme Variables
>
> >
| Variable | Default/Base/Factor value | Calc | Description |
| -------------------- | ------------------------------ | ---- | -------------------------------------------------------------------------------------------------------------------------------- |

View File

@@ -119,10 +119,11 @@ Values:
- **antiscript**: html tags in text are allowed, (only script element is removed), click functionality is enabled
- **sandbox**: With this security level all rendering takes place in a sandboxed iframe. This prevent any JavaScript running in the context. This may hinder interactive functionality of the diagram like scripts, popups in sequence diagram or links to other tabs/targets etc.
```note
This changes the default behaviour of mermaid so that after upgrade to 8.2, unless the `securityLevel` is not changed, tags in flowcharts are encoded as tags and clicking is disabled.
**sandbox** security level is still in the beta version.
```
> **Note**\
> This changes the default behaviour of mermaid so that after upgrade to 8.2, unless the `securityLevel` is not changed, tags in flowcharts are encoded as tags and clicking is disabled.
> **sandbox** security level is still in the beta version.
>
> >
**If you are taking responsibility for the diagram source security you can set the `securityLevel` to a value of your choosing . This allows clicks and tags are allowed.**
@@ -187,9 +188,10 @@ Or with no config object, and a jQuery selection:
mermaid.init(undefined, $('#someId .yetAnotherClass'));
```
```warning
This type of integration is deprecated. Instead the preferred way of handling more complex integration is to use the mermaidAPI instead.
```
> **Warning**\
> This type of integration is deprecated. Instead the preferred way of handling more complex integration is to use the mermaidAPI instead.
>
> >
## Usage with webpack
@@ -343,9 +345,10 @@ on what kind of integration you use.
</script>
```
```note
This is the preferred way of configuring mermaid.
```
> **Note**\
> This is the preferred way of configuring mermaid.
>
> >
### The following methods are deprecated and are kept only for backwards compatibility.
@@ -361,9 +364,10 @@ approach are:
mermaid.startOnLoad = true;
```
```warning
This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
```
> **Warning**\
> This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
>
> >
## Using the mermaid_config
@@ -377,9 +381,10 @@ approach are:
mermaid_config.startOnLoad = true;
```
```warning
This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
```
> **Warning**\
> This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
>
> >
## Using the mermaid.init call
@@ -392,6 +397,7 @@ To set some configuration via the mermaid object. The two parameters that are su
mermaid_config.startOnLoad = true;
```
```warning
This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
```
> **Warning**\
> This way of setting the configuration is deprecated. Instead the preferred way is to use the initialize method. This functionality is only kept for backwards compatibility.
>
> >

View File

@@ -24,11 +24,12 @@ sequenceDiagram
Alice-)John: See you later!
```
```note
A note on nodes, the word "end" could potentially break the diagram, due to the way that the mermaid language is scripted.
If unavoidable, one must use parentheses(), quotation marks "", or brackets {},[], to enclose the word "end". i.e : (end), [end], {end}.
```
> **Note**\
> A note on nodes, the word "end" could potentially break the diagram, due to the way that the mermaid language is scripted.
>
> If unavoidable, one must use parentheses(), quotation marks "", or brackets {},\[], to enclose the word "end". i.e : (end), \[end], {end}.
>
> >
## Syntax

View File

@@ -34,7 +34,7 @@
"predocs:build": "rimraf docs && pnpm docs:code",
"docs:build": "ts-node-esm src/docs.mts",
"docs:verify": "pnpm docs:build --verify",
"docs:code": "typedoc --plugin typedoc-plugin-markdown --readme none --hideBreadcrumbs --hideInPageTOC --namedAnchors --out src/docs/config/setup --entryPointStrategy expand src/defaultConfig.ts src/config.ts src/mermaidAPI.ts",
"docs:code": "typedoc --plugin typedoc-plugin-markdown --readme none --hideBreadcrumbs --gitRemote disable --hideInPageTOC --namedAnchors --out src/docs/config/setup --entryPointStrategy expand src/defaultConfig.ts src/config.ts src/mermaidAPI.ts",
"predocs:dev": "pnpm docs:code",
"docs:dev": "vitepress dev src/docs",
"predocs:bundle": "pnpm docs:code",
@@ -77,7 +77,8 @@
"khroma": "^2.0.0",
"lodash": "^4.17.21",
"moment-mini": "^2.24.0",
"non-layered-tidy-tree-layout": "^2.0.2"
"non-layered-tidy-tree-layout": "^2.0.2",
"stylis": "^4.1.2"
},
"devDependencies": {
"@applitools/eyes-cypress": "3.27.5",

View File

@@ -18,7 +18,7 @@ import { MermaidConfig } from './config.type';
*
* ```html
* <script>
* var config = {
* const config = {
* startOnLoad:true,
* flowchart:{ useMaxWidth:true, htmlLabels:true, curve:'cardinal'},
* securityLevel:'loose',

View File

@@ -135,19 +135,19 @@ const copyTransformedContents = (filename: string, doCopy = false, transformedCo
const transformAnnotation = (content: string, type: 'warning' | 'tip' | 'note') => {
let transformed = content;
let regex = /::: note\n[\s\S]+?:::/gm;
let regex = /```note\n[\s\S]+?```/gm;
let text = 'Note';
switch (type) {
case 'note':
regex = /::: note\s?\n[\s\S]+?:::/gm;
regex = /```note\s?\n[\s\S]+?```/gm;
break;
case 'tip':
regex = /::: tip\s?\n[\s\S]+?:::/gm;
regex = /```tip\s?\n[\s\S]+?```/gm;
text = 'Note';
break;
case 'warning':
regex = /::: warning\s?\n[\s\S]+?:::/gm;
regex = /```warning\s?\n[\s\S]+?```/gm;
text = 'Warning';
break;
default:
@@ -159,7 +159,11 @@ const transformAnnotation = (content: string, type: 'warning' | 'tip' | 'note')
console.log(`found ${matches.length} of ${type}`);
const formatted = matches.map((element) =>
element.replace(`::: ${type}`, `> **${text}** `).replace(':::', '>').split('\n').join('\n> ')
element
.replace(`\`\`\`${type}`, `> **${text}** `)
.replace('```', '>')
.split('\n')
.join('\n> ')
);
let n = 0;
for (const match of matches) {

View File

@@ -1,22 +1,5 @@
// import { deflate } from 'pako';
// import { fromUint8Array } from 'js-base64';
import shiki from 'shiki';
// const serializeState = (state: State, serde: SerdeType = 'pako'): string => {
// if (serdes[serde] === undefined) {
// throw new Error(`Unknown serde type: ${serde}`);
// }
// const json = JSON.stringify(state);
// const serialized = serdes[serde].serialize(json);
// return `${serde}:${serialized}`;
// };
// const serialize = (state: string): string => {
// const data = new TextEncoder().encode(state);
// const compressed = deflate(data, { level: 9 });
// return fromUint8Array(compressed, true);
// };
const MermaidExample = async (md) => {
const fence = md.renderer.rules.fence.bind(md.renderer.rules);
@@ -34,10 +17,6 @@ const MermaidExample = async (md) => {
code =
'<h5>Code:</h5>' +
`<div class="language-mermaid">` +
// TODO: compute edit link!
// `<a class="edit" href="https://mermaid.live/edit#pako:${serialize(
// token.content
// )}" target=”_blank”>✒️</a>` +
`<button class="copy"></button><span class="lang">mermaid</span>` +
code +
'</div>';

2
pnpm-lock.yaml generated
View File

@@ -212,6 +212,7 @@ importers:
rimraf: 3.0.2
shiki: ^0.11.1
start-server-and-test: 1.14.0
stylis: ^4.1.2
ts-node: 10.9.1
typedoc: ^0.23.18
typedoc-plugin-markdown: ^3.13.6
@@ -229,6 +230,7 @@ importers:
lodash: 4.17.21
moment-mini: 2.29.4
non-layered-tidy-tree-layout: 2.0.2
stylis: 4.1.2
devDependencies:
'@applitools/eyes-cypress': 3.27.5
'@commitlint/cli': 17.1.2