mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-01 13:19:39 +02:00
Merge branch develop into standardized-pie-definitions
This commit is contained in:
13
.github/workflows/e2e.yml
vendored
13
.github/workflows/e2e.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
# Otherwise (e.g. if running from fork), we run on a single container only
|
# Otherwise (e.g. if running from fork), we run on a single container only
|
||||||
if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }}
|
if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }}
|
||||||
with:
|
with:
|
||||||
start: pnpm run dev
|
start: pnpm run dev:coverage
|
||||||
wait-on: 'http://localhost:9000'
|
wait-on: 'http://localhost:9000'
|
||||||
# Disable recording if we don't have an API key
|
# Disable recording if we don't have an API key
|
||||||
# e.g. if this action was run from a fork
|
# e.g. if this action was run from a fork
|
||||||
@@ -41,7 +41,16 @@ jobs:
|
|||||||
parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
||||||
env:
|
env:
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
|
VITEST_COVERAGE: true
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
if: steps.cypress.conclusion == 'success'
|
||||||
|
with:
|
||||||
|
files: coverage/cypress/lcov.info
|
||||||
|
flags: e2e
|
||||||
|
name: mermaid-codecov
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
|
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
|
||||||
|
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run Unit Tests
|
- name: Run Unit Tests
|
||||||
run: |
|
run: |
|
||||||
pnpm run ci --coverage
|
pnpm test:coverage
|
||||||
|
|
||||||
- name: Run ganttDb tests using California timezone
|
- name: Run ganttDb tests using California timezone
|
||||||
env:
|
env:
|
||||||
@@ -39,8 +39,16 @@ jobs:
|
|||||||
# since some days have 25 hours instead of 24.
|
# since some days have 25 hours instead of 24.
|
||||||
TZ: America/Los_Angeles
|
TZ: America/Los_Angeles
|
||||||
run: |
|
run: |
|
||||||
pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts
|
pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts --coverage
|
||||||
|
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./coverage/vitest/lcov.info
|
||||||
|
flags: unit
|
||||||
|
name: mermaid-codecov
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
# Coveralls is throwing 500. Disabled for now.
|
# Coveralls is throwing 500. Disabled for now.
|
||||||
# - name: Upload Coverage to Coveralls
|
# - name: Upload Coverage to Coveralls
|
||||||
# uses: coverallsapp/github-action@v2
|
# uses: coverallsapp/github-action@v2
|
||||||
|
@@ -27,7 +27,7 @@ Generate diagrams from markdown-like text.
|
|||||||
[](https://www.npmjs.com/package/mermaid)
|
[](https://www.npmjs.com/package/mermaid)
|
||||||
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml)
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml)
|
||||||
[](https://bundlephobia.com/package/mermaid)
|
[](https://bundlephobia.com/package/mermaid)
|
||||||
[](https://coveralls.io/github/mermaid-js/mermaid?branch=master)
|
[](https://app.codecov.io/github/mermaid-js/mermaid/tree/develop)
|
||||||
[](https://www.jsdelivr.com/package/npm/mermaid)
|
[](https://www.jsdelivr.com/package/npm/mermaid)
|
||||||
[](https://www.npmjs.com/package/mermaid)
|
[](https://www.npmjs.com/package/mermaid)
|
||||||
[](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
[](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
@@ -410,7 +410,7 @@ _Unfortunately you can not have a cake and eat it at the same time which in this
|
|||||||
|
|
||||||
## Reporting vulnerabilities
|
## Reporting vulnerabilities
|
||||||
|
|
||||||
To report a vulnerability, please e-mail security@mermaid.live with a description of the issue, the steps you took to create the issue, affected versions, and if known, mitigations for the issue.
|
To report a vulnerability, please e-mail <security@mermaid.live> with a description of the issue, the steps you took to create the issue, affected versions, and if known, mitigations for the issue.
|
||||||
|
|
||||||
## Appreciation
|
## Appreciation
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ Mermaid
|
|||||||
[](https://www.npmjs.com/package/mermaid)
|
[](https://www.npmjs.com/package/mermaid)
|
||||||
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml)
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml)
|
||||||
[](https://bundlephobia.com/package/mermaid)
|
[](https://bundlephobia.com/package/mermaid)
|
||||||
[](https://coveralls.io/github/mermaid-js/mermaid?branch=master)
|
[](https://app.codecov.io/github/mermaid-js/mermaid/tree/develop)
|
||||||
[](https://www.jsdelivr.com/package/npm/mermaid)
|
[](https://www.jsdelivr.com/package/npm/mermaid)
|
||||||
[](https://www.npmjs.com/package/mermaid)
|
[](https://www.npmjs.com/package/mermaid)
|
||||||
[](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
[](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
6
codecov.yaml
Normal file
6
codecov.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
comment:
|
||||||
|
layout: 'reach, diff, flags, files'
|
||||||
|
behavior: default
|
||||||
|
require_changes: false # if true: only post the comment if coverage changes
|
||||||
|
require_base: no # [yes :: must have a base report to post]
|
||||||
|
require_head: yes # [yes :: must have a head report to post]
|
@@ -1505,6 +1505,34 @@
|
|||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
graph TD
|
||||||
|
A([Start]) ==> B[Step 1]
|
||||||
|
B ==> C{Flow 1}
|
||||||
|
C -- Choice 1.1 --> D[Step 2.1]
|
||||||
|
C -- Choice 1.3 --> I[Step 2.3]
|
||||||
|
C == Choice 1.2 ==> E[Step 2.2]
|
||||||
|
D --> F{Flow 2}
|
||||||
|
E ==> F{Flow 2}
|
||||||
|
F{Flow 2} == Choice 2.1 ==> H[Feedback node]
|
||||||
|
H[Feedback node] ==> B[Step 1]
|
||||||
|
F{Flow 2} == Choice 2.2 ==> G((Finish))
|
||||||
|
|
||||||
|
linkStyle 0,1,4,6,7,8,9 stroke:gold, stroke-width:4px
|
||||||
|
|
||||||
|
classDef active_node fill:#0CF,stroke:#09F,stroke-width:6px
|
||||||
|
classDef unactive_node fill:#e0e0e0,stroke:#bdbdbd,stroke-width:3px
|
||||||
|
classDef bugged_node fill:#F88,stroke:#F22,stroke-width:3px
|
||||||
|
classDef start_node,finish_node fill:#3B1,stroke:#391,stroke-width:8px
|
||||||
|
|
||||||
|
class A start_node;
|
||||||
|
class B,C,E,F,H active_node;
|
||||||
|
class D unactive_node;
|
||||||
|
class G finish_node;
|
||||||
|
class I bugged_node
|
||||||
|
</pre>
|
||||||
|
<hr />
|
||||||
|
|
||||||
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
|
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
|
@@ -919,6 +919,10 @@ In the example below the style defined in the linkStyle statement will belong to
|
|||||||
|
|
||||||
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
||||||
|
|
||||||
|
It is also possible to add style to multiple links in a single statement, by separating link numbers with commas:
|
||||||
|
|
||||||
|
linkStyle 1,2,7 color:blue;
|
||||||
|
|
||||||
### Styling line curves
|
### Styling line curves
|
||||||
|
|
||||||
It is possible to style the type of curve used for lines between items, if the default method does not meet your needs.
|
It is possible to style the type of curve used for lines between items, if the default method does not meet your needs.
|
||||||
@@ -957,10 +961,14 @@ flowchart LR
|
|||||||
More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that
|
More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that
|
||||||
should have a different look.
|
should have a different look.
|
||||||
|
|
||||||
a class definition looks like the example below:
|
A class definition looks like the example below:
|
||||||
|
|
||||||
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
|
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
|
||||||
|
|
||||||
|
Also, it is possible to define style to multiple classes in one statement:
|
||||||
|
|
||||||
|
classDef firstClassName,secondClassName font-size:12pt;
|
||||||
|
|
||||||
Attachment of a class to a node is done as per below:
|
Attachment of a class to a node is done as per below:
|
||||||
|
|
||||||
class nodeId1 className;
|
class nodeId1 className;
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
"build:watch": "pnpm build:vite --watch",
|
"build:watch": "pnpm build:vite --watch",
|
||||||
"build": "pnpm run -r clean && pnpm build:types && pnpm build:vite",
|
"build": "pnpm run -r clean && pnpm build:types && pnpm build:vite",
|
||||||
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
|
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
|
||||||
|
"dev:coverage": "VITE_COVERAGE=true pnpm dev",
|
||||||
"release": "pnpm build",
|
"release": "pnpm build",
|
||||||
"lint": "eslint --cache --cache-strategy content --ignore-path .gitignore . && pnpm lint:jison && prettier --cache --check .",
|
"lint": "eslint --cache --cache-strategy content --ignore-path .gitignore . && pnpm lint:jison && prettier --cache --check .",
|
||||||
"lint:fix": "eslint --cache --cache-strategy content --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts",
|
"lint:fix": "eslint --cache --cache-strategy content --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts",
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
"coveralls": "^3.1.1",
|
"coveralls": "^3.1.1",
|
||||||
"cypress": "^12.10.0",
|
"cypress": "^12.10.0",
|
||||||
"cypress-image-snapshot": "^4.0.1",
|
"cypress-image-snapshot": "^4.0.1",
|
||||||
"esbuild": "^0.17.18",
|
"esbuild": "^0.18.0",
|
||||||
"eslint": "^8.39.0",
|
"eslint": "^8.39.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-cypress": "^2.13.2",
|
"eslint-plugin-cypress": "^2.13.2",
|
||||||
|
@@ -208,21 +208,22 @@ export const updateLink = function (positions, style) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addClass = function (id, style) {
|
export const addClass = function (ids, style) {
|
||||||
if (classes[id] === undefined) {
|
ids.split(',').forEach(function (id) {
|
||||||
classes[id] = { id: id, styles: [], textStyles: [] };
|
if (classes[id] === undefined) {
|
||||||
}
|
classes[id] = { id, styles: [], textStyles: [] };
|
||||||
|
}
|
||||||
|
|
||||||
if (style !== undefined && style !== null) {
|
if (style !== undefined && style !== null) {
|
||||||
style.forEach(function (s) {
|
style.forEach(function (s) {
|
||||||
if (s.match('color')) {
|
if (s.match('color')) {
|
||||||
const newStyle1 = s.replace('fill', 'bgFill');
|
const newStyle = s.replace('fill', 'bgFill').replace('color', 'fill');
|
||||||
const newStyle2 = newStyle1.replace('color', 'fill');
|
classes[id].textStyles.push(newStyle);
|
||||||
classes[id].textStyles.push(newStyle2);
|
}
|
||||||
}
|
classes[id].styles.push(s);
|
||||||
classes[id].styles.push(s);
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -41,3 +41,26 @@ describe('flow db subgraphs', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('flow db addClass', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
flowDb.clear();
|
||||||
|
});
|
||||||
|
it('should detect many classes', () => {
|
||||||
|
flowDb.addClass('a,b', ['stroke-width: 8px']);
|
||||||
|
const classes = flowDb.getClasses();
|
||||||
|
|
||||||
|
expect(classes.hasOwnProperty('a')).toBe(true);
|
||||||
|
expect(classes.hasOwnProperty('b')).toBe(true);
|
||||||
|
expect(classes['a']['styles']).toEqual(['stroke-width: 8px']);
|
||||||
|
expect(classes['b']['styles']).toEqual(['stroke-width: 8px']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect single class', () => {
|
||||||
|
flowDb.addClass('a', ['stroke-width: 8px']);
|
||||||
|
const classes = flowDb.getClasses();
|
||||||
|
|
||||||
|
expect(classes.hasOwnProperty('a')).toBe(true);
|
||||||
|
expect(classes['a']['styles']).toEqual(['stroke-width: 8px']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@@ -113,6 +113,22 @@ describe('[Style] when parsing', () => {
|
|||||||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red');
|
expect(classes['exClass'].styles[1]).toBe('border:1px solid red');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be possible to declare multiple classes', function () {
|
||||||
|
const res = flow.parser.parse(
|
||||||
|
'graph TD;classDef firstClass,secondClass background:#bbb,border:1px solid red;'
|
||||||
|
);
|
||||||
|
|
||||||
|
const classes = flow.parser.yy.getClasses();
|
||||||
|
|
||||||
|
expect(classes['firstClass'].styles.length).toBe(2);
|
||||||
|
expect(classes['firstClass'].styles[0]).toBe('background:#bbb');
|
||||||
|
expect(classes['firstClass'].styles[1]).toBe('border:1px solid red');
|
||||||
|
|
||||||
|
expect(classes['secondClass'].styles.length).toBe(2);
|
||||||
|
expect(classes['secondClass'].styles[0]).toBe('background:#bbb');
|
||||||
|
expect(classes['secondClass'].styles[1]).toBe('border:1px solid red');
|
||||||
|
});
|
||||||
|
|
||||||
it('should be possible to declare a class with a dot in the style', function () {
|
it('should be possible to declare a class with a dot in the style', function () {
|
||||||
const res = flow.parser.parse(
|
const res = flow.parser.parse(
|
||||||
'graph TD;classDef exClass background:#bbb,border:1.5px solid red;'
|
'graph TD;classDef exClass background:#bbb,border:1.5px solid red;'
|
||||||
|
@@ -20,17 +20,17 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify-json/carbon": "^1.1.16",
|
"@iconify-json/carbon": "^1.1.16",
|
||||||
"@unocss/reset": "^0.52.0",
|
"@unocss/reset": "^0.53.0",
|
||||||
"@vite-pwa/vitepress": "^0.0.5",
|
"@vite-pwa/vitepress": "^0.2.0",
|
||||||
"@vitejs/plugin-vue": "^4.2.1",
|
"@vitejs/plugin-vue": "^4.2.1",
|
||||||
"fast-glob": "^3.2.12",
|
"fast-glob": "^3.2.12",
|
||||||
"https-localhost": "^4.7.1",
|
"https-localhost": "^4.7.1",
|
||||||
"pathe": "^1.1.0",
|
"pathe": "^1.1.0",
|
||||||
"unocss": "^0.52.0",
|
"unocss": "^0.53.0",
|
||||||
"unplugin-vue-components": "^0.24.1",
|
"unplugin-vue-components": "^0.25.0",
|
||||||
"vite": "^4.3.3",
|
"vite": "^4.3.3",
|
||||||
"vite-plugin-pwa": "^0.15.0",
|
"vite-plugin-pwa": "^0.16.0",
|
||||||
"vitepress": "1.0.0-beta.1",
|
"vitepress": "1.0.0-beta.2",
|
||||||
"workbox-window": "^6.5.4"
|
"workbox-window": "^6.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -605,6 +605,12 @@ In the example below the style defined in the linkStyle statement will belong to
|
|||||||
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
It is also possible to add style to multiple links in a single statement, by separating link numbers with commas:
|
||||||
|
|
||||||
|
```
|
||||||
|
linkStyle 1,2,7 color:blue;
|
||||||
|
```
|
||||||
|
|
||||||
### Styling line curves
|
### Styling line curves
|
||||||
|
|
||||||
It is possible to style the type of curve used for lines between items, if the default method does not meet your needs.
|
It is possible to style the type of curve used for lines between items, if the default method does not meet your needs.
|
||||||
@@ -638,12 +644,18 @@ flowchart LR
|
|||||||
More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that
|
More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that
|
||||||
should have a different look.
|
should have a different look.
|
||||||
|
|
||||||
a class definition looks like the example below:
|
A class definition looks like the example below:
|
||||||
|
|
||||||
```
|
```
|
||||||
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
|
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Also, it is possible to define style to multiple classes in one statement:
|
||||||
|
|
||||||
|
```
|
||||||
|
classDef firstClassName,secondClassName font-size:12pt;
|
||||||
|
```
|
||||||
|
|
||||||
Attachment of a class to a node is done as per below:
|
Attachment of a class to a node is done as per below:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
911
pnpm-lock.yaml
generated
911
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user