mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 21:39:40 +02:00
Merge branch 'knsv/mindmap-refactoring' of https://github.com/mermaid-js/mermaid into knsv/mindmap-refactoring
This commit is contained in:
3
.github/workflows/e2e-applitools.yml
vendored
3
.github/workflows/e2e-applitools.yml
vendored
@@ -23,9 +23,6 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
e2e-applitools:
|
e2e-applitools:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1
|
|
||||||
options: --user 1001
|
|
||||||
steps:
|
steps:
|
||||||
- if: ${{ ! env.USE_APPLI }}
|
- if: ${{ ! env.USE_APPLI }}
|
||||||
name: Warn if not using Applitools
|
name: Warn if not using Applitools
|
||||||
|
@@ -29,8 +29,7 @@ In GitHub, you first [**fork a mermaid repository**](https://github.com/mermaid-
|
|||||||
|
|
||||||
Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
|
Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
|
||||||
|
|
||||||
> **💡 Tip**
|
> **💡 Tip** > [Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
||||||
> [Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone git@github.com/your-fork/mermaid
|
git clone git@github.com/your-fork/mermaid
|
||||||
|
@@ -33,8 +33,7 @@ mindmap
|
|||||||
|
|
||||||
## Join the Development
|
## Join the Development
|
||||||
|
|
||||||
> **💡 Tip**
|
> **💡 Tip** > **Check out our** [**detailed contribution guide**](./contributing.md).
|
||||||
> **Check out our** [**detailed contribution guide**](./contributing.md).
|
|
||||||
|
|
||||||
Where to start:
|
Where to start:
|
||||||
|
|
||||||
@@ -48,8 +47,7 @@ Where to start:
|
|||||||
|
|
||||||
## A Question Or a Suggestion?
|
## A Question Or a Suggestion?
|
||||||
|
|
||||||
> **💡 Tip**
|
> **💡 Tip** > **Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
|
||||||
> **Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
|
|
||||||
|
|
||||||
If you have faced a vulnerability [report it to us](./security.md).
|
If you have faced a vulnerability [report it to us](./security.md).
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ While directives allow you to change most of the default configuration settings,
|
|||||||
Mermaid basically supports two types of configuration options to be overridden by directives.
|
Mermaid basically supports two types of configuration options to be overridden by directives.
|
||||||
|
|
||||||
1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are:
|
1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are:
|
||||||
|
|
||||||
- theme
|
- theme
|
||||||
- fontFamily
|
- fontFamily
|
||||||
- logLevel
|
- logLevel
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: LayoutData
|
# Interface: LayoutData
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:180](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L180)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:184](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L184)
|
||||||
|
|
||||||
## Indexable
|
## Indexable
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:180](https://github.co
|
|||||||
|
|
||||||
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:183](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L183)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:187](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L187)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:183](https://github.co
|
|||||||
|
|
||||||
> **edges**: `Edge`\[]
|
> **edges**: `Edge`\[]
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:182](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L182)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:186](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L186)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -38,4 +38,4 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:182](https://github.co
|
|||||||
|
|
||||||
> **nodes**: `Node`\[]
|
> **nodes**: `Node`\[]
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:181](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L181)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:185](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L185)
|
||||||
|
@@ -29,6 +29,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
|
|||||||
- **Plugins** - A plugin system for extending the functionality of Mermaid.
|
- **Plugins** - A plugin system for extending the functionality of Mermaid.
|
||||||
|
|
||||||
Official Mermaid Chart plugins:
|
Official Mermaid Chart plugins:
|
||||||
|
|
||||||
- [Mermaid Chart GPT](https://chatgpt.com/g/g-684cc36f30208191b21383b88650a45d-mermaid-chart-diagrams-and-charts)
|
- [Mermaid Chart GPT](https://chatgpt.com/g/g-684cc36f30208191b21383b88650a45d-mermaid-chart-diagrams-and-charts)
|
||||||
- [Confluence](https://marketplace.atlassian.com/apps/1234056/mermaid-chart-for-confluence?hosting=cloud&tab=overview)
|
- [Confluence](https://marketplace.atlassian.com/apps/1234056/mermaid-chart-for-confluence?hosting=cloud&tab=overview)
|
||||||
- [Jira](https://marketplace.atlassian.com/apps/1234810/mermaid-chart-for-jira?tab=overview&hosting=cloud)
|
- [Jira](https://marketplace.atlassian.com/apps/1234810/mermaid-chart-for-jira?tab=overview&hosting=cloud)
|
||||||
|
@@ -35,11 +35,13 @@ The Mermaid Chart team is excited to introduce a new Visual Editor for Flowchart
|
|||||||
Learn more:
|
Learn more:
|
||||||
|
|
||||||
- Visual Editor For Flowcharts
|
- Visual Editor For Flowcharts
|
||||||
|
|
||||||
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-releases-new-visual-editor-for-flowcharts)
|
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-releases-new-visual-editor-for-flowcharts)
|
||||||
|
|
||||||
- [Demo video](https://www.youtube.com/watch?v=5aja0gijoO0)
|
- [Demo video](https://www.youtube.com/watch?v=5aja0gijoO0)
|
||||||
|
|
||||||
- Visual Editor For Sequence diagrams
|
- Visual Editor For Sequence diagrams
|
||||||
|
|
||||||
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams)
|
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams)
|
||||||
|
|
||||||
- [Demo video](https://youtu.be/imc2u5_N6Dc)
|
- [Demo video](https://youtu.be/imc2u5_N6Dc)
|
||||||
|
@@ -139,6 +139,7 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [ ] Legend
|
- [ ] Legend
|
||||||
|
|
||||||
- [x] System Context
|
- [x] System Context
|
||||||
|
|
||||||
- [x] Person(alias, label, ?descr, ?sprite, ?tags, $link)
|
- [x] Person(alias, label, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] Person_Ext
|
- [x] Person_Ext
|
||||||
- [x] System(alias, label, ?descr, ?sprite, ?tags, $link)
|
- [x] System(alias, label, ?descr, ?sprite, ?tags, $link)
|
||||||
@@ -152,6 +153,7 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] System_Boundary
|
- [x] System_Boundary
|
||||||
|
|
||||||
- [x] Container diagram
|
- [x] Container diagram
|
||||||
|
|
||||||
- [x] Container(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Container(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] ContainerDb
|
- [x] ContainerDb
|
||||||
- [x] ContainerQueue
|
- [x] ContainerQueue
|
||||||
@@ -161,6 +163,7 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] Container_Boundary(alias, label, ?tags, $link)
|
- [x] Container_Boundary(alias, label, ?tags, $link)
|
||||||
|
|
||||||
- [x] Component diagram
|
- [x] Component diagram
|
||||||
|
|
||||||
- [x] Component(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Component(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] ComponentDb
|
- [x] ComponentDb
|
||||||
- [x] ComponentQueue
|
- [x] ComponentQueue
|
||||||
@@ -169,15 +172,18 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] ComponentQueue_Ext
|
- [x] ComponentQueue_Ext
|
||||||
|
|
||||||
- [x] Dynamic diagram
|
- [x] Dynamic diagram
|
||||||
|
|
||||||
- [x] RelIndex(index, from, to, label, ?tags, $link)
|
- [x] RelIndex(index, from, to, label, ?tags, $link)
|
||||||
|
|
||||||
- [x] Deployment diagram
|
- [x] Deployment diagram
|
||||||
|
|
||||||
- [x] Deployment_Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link)
|
- [x] Deployment_Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link): short name of Deployment_Node()
|
- [x] Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link): short name of Deployment_Node()
|
||||||
- [x] Node_L(alias, label, ?type, ?descr, ?sprite, ?tags, $link): left aligned Node()
|
- [x] Node_L(alias, label, ?type, ?descr, ?sprite, ?tags, $link): left aligned Node()
|
||||||
- [x] Node_R(alias, label, ?type, ?descr, ?sprite, ?tags, $link): right aligned Node()
|
- [x] Node_R(alias, label, ?type, ?descr, ?sprite, ?tags, $link): right aligned Node()
|
||||||
|
|
||||||
- [x] Relationship Types
|
- [x] Relationship Types
|
||||||
|
|
||||||
- [x] Rel(from, to, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Rel(from, to, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] BiRel (bidirectional relationship)
|
- [x] BiRel (bidirectional relationship)
|
||||||
- [x] Rel_U, Rel_Up
|
- [x] Rel_U, Rel_Up
|
||||||
|
@@ -356,6 +356,7 @@ Below is a comprehensive list of the newly introduced shapes and their correspon
|
|||||||
| Manual File | Flipped Triangle | `flip-tri` | Manual file operation | `flipped-triangle`, `manual-file` |
|
| Manual File | Flipped Triangle | `flip-tri` | Manual file operation | `flipped-triangle`, `manual-file` |
|
||||||
| Manual Input | Sloped Rectangle | `sl-rect` | Manual input step | `manual-input`, `sloped-rectangle` |
|
| Manual Input | Sloped Rectangle | `sl-rect` | Manual input step | `manual-input`, `sloped-rectangle` |
|
||||||
| Manual Operation | Trapezoid Base Top | `trap-t` | Represents a manual task | `inv-trapezoid`, `manual`, `trapezoid-top` |
|
| Manual Operation | Trapezoid Base Top | `trap-t` | Represents a manual task | `inv-trapezoid`, `manual`, `trapezoid-top` |
|
||||||
|
| Mindmap Circle | mindmapCircle | `mindmap-circle` | mindmapCircle | `mindmap-circle` |
|
||||||
| Multi-Document | Stacked Document | `docs` | Multiple documents | `documents`, `st-doc`, `stacked-document` |
|
| Multi-Document | Stacked Document | `docs` | Multiple documents | `documents`, `st-doc`, `stacked-document` |
|
||||||
| Multi-Process | Stacked Rectangle | `st-rect` | Multiple processes | `processes`, `procs`, `stacked-rectangle` |
|
| Multi-Process | Stacked Rectangle | `st-rect` | Multiple processes | `processes`, `procs`, `stacked-rectangle` |
|
||||||
| Odd | Odd | `odd` | Odd shape | |
|
| Odd | Odd | `odd` | Odd shape | |
|
||||||
|
@@ -360,8 +360,7 @@ gantt
|
|||||||
weekday monday
|
weekday monday
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Warning**
|
> **Warning** > `millisecond` and `second` support was added in v10.3.0
|
||||||
> `millisecond` and `second` support was added in v10.3.0
|
|
||||||
|
|
||||||
## Output in compact mode
|
## Output in compact mode
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^7.0.4",
|
"@braintree/sanitize-url": "^7.0.4",
|
||||||
"@iconify/utils": "^2.1.33",
|
"@iconify/utils": "^3.0.1",
|
||||||
"@mermaid-js/parser": "workspace:^",
|
"@mermaid-js/parser": "workspace:^",
|
||||||
"@types/d3": "^7.4.3",
|
"@types/d3": "^7.4.3",
|
||||||
"cytoscape": "^3.29.3",
|
"cytoscape": "^3.29.3",
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
"fast-glob": "^3.3.3",
|
"fast-glob": "^3.3.3",
|
||||||
"https-localhost": "^4.7.1",
|
"https-localhost": "^4.7.1",
|
||||||
"pathe": "^2.0.3",
|
"pathe": "^2.0.3",
|
||||||
"unocss": "^66.0.0",
|
"unocss": "^66.4.2",
|
||||||
"unplugin-vue-components": "^28.4.0",
|
"unplugin-vue-components": "^28.4.0",
|
||||||
"vite": "^6.1.1",
|
"vite": "^6.1.1",
|
||||||
"vite-plugin-pwa": "^1.0.0",
|
"vite-plugin-pwa": "^1.0.0",
|
||||||
|
@@ -41,7 +41,6 @@ import { decodeEntities, encodeEntities } from './utils.js';
|
|||||||
import { toBase64 } from './utils/base64.js';
|
import { toBase64 } from './utils/base64.js';
|
||||||
import { StateDB } from './diagrams/state/stateDb.js';
|
import { StateDB } from './diagrams/state/stateDb.js';
|
||||||
import { ensureNodeFromSelector, jsdomIt } from './tests/util.js';
|
import { ensureNodeFromSelector, jsdomIt } from './tests/util.js';
|
||||||
import { select } from 'd3';
|
|
||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +49,6 @@ import { JSDOM } from 'jsdom';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
describe('mermaidAPI', () => {
|
describe('mermaidAPI', () => {
|
||||||
describe('encodeEntities', () => {
|
describe('encodeEntities', () => {
|
||||||
it('removes the ending ; from style [text1]:[optional word]#[text2]; with ', () => {
|
it('removes the ending ; from style [text1]:[optional word]#[text2]; with ', () => {
|
||||||
@@ -913,4 +911,241 @@ graph TD;A--x|text including URL space|B;`)
|
|||||||
expect(sequenceDiagram1.db.getActors()).not.toEqual(sequenceDiagram2.db.getActors());
|
expect(sequenceDiagram1.db.getActors()).not.toEqual(sequenceDiagram2.db.getActors());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('mermaidAPI config precedence', () => {
|
||||||
|
const id = 'mermaid-config-test';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mermaidAPI.globalReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
jsdomIt('renders with YAML config taking precedence over initialize config', async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
fontFamily: 'Arial',
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
flowchart: { htmlLabels: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
theme: base
|
||||||
|
fontFamily: Courier
|
||||||
|
themeVariables:
|
||||||
|
fontFamily: "Courier New"
|
||||||
|
fontSize: "20px"
|
||||||
|
flowchart:
|
||||||
|
htmlLabels: true
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { svg } = await mermaidAPI.render('yaml-over-init', diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.theme).toBe('base');
|
||||||
|
expect(config.fontFamily).toBe('Courier');
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Courier New');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('20px');
|
||||||
|
expect(config.flowchart?.htmlLabels).toBe(true);
|
||||||
|
|
||||||
|
const svgNode = ensureNodeFromSelector('svg', new JSDOM(svg).window.document);
|
||||||
|
expect(svgNode).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with YAML themeVariables fully overriding initialize themeVariables',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
themeVariables:
|
||||||
|
fontFamily: "Courier New"
|
||||||
|
fontSize: "20px"
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { svg } = await mermaidAPI.render(id, diagramText);
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Courier New');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('20px');
|
||||||
|
expect(config.themeVariables.fontFamily).not.toBe('Arial');
|
||||||
|
expect(config.themeVariables.fontSize).not.toBe('16px');
|
||||||
|
|
||||||
|
const svgNode = ensureNodeFromSelector('svg', new JSDOM(svg).window.document);
|
||||||
|
expect(svgNode).not.toBeNull();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with YAML themeVariables overriding only provided keys and keeping others from initialize',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
fontFamily: 'Arial',
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px', colorPrimary: '#ff0000' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
themeVariables:
|
||||||
|
fontFamily: "Courier New"
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { svg } = await mermaidAPI.render(id, diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Courier New');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('16px');
|
||||||
|
expect(config.themeVariables.colorPrimary).toBe('#ff0000');
|
||||||
|
|
||||||
|
const svgNode = ensureNodeFromSelector('svg', new JSDOM(svg).window.document);
|
||||||
|
expect(svgNode).not.toBeNull();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with YAML config (no themeVariables) and falls back to initialize themeVariables',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
theme: base
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { svg } = await mermaidAPI.render(id, diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Arial');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('16px');
|
||||||
|
expect(config.theme).toBe('base');
|
||||||
|
|
||||||
|
const svgNode = ensureNodeFromSelector('svg', new JSDOM(svg).window.document);
|
||||||
|
expect(svgNode).not.toBeNull();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with full YAML config block taking full precedence over initialize config',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
fontFamily: 'Arial',
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
flowchart: { htmlLabels: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
theme: base
|
||||||
|
fontFamily: Courier
|
||||||
|
themeVariables:
|
||||||
|
fontFamily: "Courier New"
|
||||||
|
fontSize: "20px"
|
||||||
|
flowchart:
|
||||||
|
htmlLabels: true
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
const { svg } = await mermaidAPI.render('yaml-over-init', diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.theme).toBe('base');
|
||||||
|
expect(config.fontFamily).toBe('Courier');
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Courier New');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('20px');
|
||||||
|
expect(config.flowchart?.htmlLabels).toBe(true);
|
||||||
|
|
||||||
|
const svgNode = ensureNodeFromSelector('svg', new JSDOM(svg).window.document);
|
||||||
|
expect(svgNode).not.toBeNull();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with YAML config (no themeVariables) and falls back to initialize themeVariables (duplicate scenario)',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config:
|
||||||
|
theme: base
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
await mermaidAPI.render(id, diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Arial');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('16px');
|
||||||
|
expect(config.theme).toBe('base');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jsdomIt('renders with no YAML config so initialize config is fully applied', async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
fontFamily: 'Arial',
|
||||||
|
themeVariables: { fontFamily: 'Arial', fontSize: '16px' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
await mermaidAPI.render(id, diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.theme).toBe('forest');
|
||||||
|
expect(config.fontFamily).toBe('Arial');
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Arial');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('16px');
|
||||||
|
});
|
||||||
|
|
||||||
|
jsdomIt(
|
||||||
|
'renders with empty YAML config block and falls back to initialize config',
|
||||||
|
async () => {
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'dark',
|
||||||
|
themeVariables: { fontFamily: 'Times', fontSize: '14px' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const diagramText = `---
|
||||||
|
config: {}
|
||||||
|
---
|
||||||
|
flowchart TD
|
||||||
|
A --> B
|
||||||
|
`;
|
||||||
|
|
||||||
|
await mermaidAPI.render(id, diagramText);
|
||||||
|
|
||||||
|
const config = mermaidAPI.getConfig();
|
||||||
|
expect(config.theme).toBe('dark');
|
||||||
|
expect(config.themeVariables.fontFamily).toBe('Times');
|
||||||
|
expect(config.themeVariables.fontSize).toBe('14px');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user