mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Merge branch 'develop' into feature/class-namespace
This commit is contained in:
commit
204baa4586
1
.npmrc
1
.npmrc
@ -1,3 +1,2 @@
|
|||||||
auto-install-peers=true
|
auto-install-peers=true
|
||||||
strict-peer-dependencies=false
|
strict-peer-dependencies=false
|
||||||
use-inline-specifiers-lockfile-format=true
|
|
||||||
|
@ -3,6 +3,7 @@ import { resolve } from 'path';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import jisonPlugin from './jisonPlugin.js';
|
import jisonPlugin from './jisonPlugin.js';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
import type { TemplateType } from 'rollup-plugin-visualizer/dist/plugin/template-types.js';
|
import type { TemplateType } from 'rollup-plugin-visualizer/dist/plugin/template-types.js';
|
||||||
|
|
||||||
@ -102,9 +103,14 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.jison', '.js', '.ts', '.json'],
|
extensions: [],
|
||||||
},
|
},
|
||||||
plugins: [jisonPlugin(), ...visualizerOptions(packageName, core)],
|
plugins: [
|
||||||
|
jisonPlugin(),
|
||||||
|
// @ts-expect-error According to the type definitions, rollup plugins are incompatible with vite
|
||||||
|
typescript({ compilerOptions: { declaration: false } }),
|
||||||
|
...visualizerOptions(packageName, core),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (watch && config.build) {
|
if (watch && config.build) {
|
||||||
|
38
README.md
38
README.md
@ -240,6 +240,44 @@ pie
|
|||||||
|
|
||||||
### Git graph [experimental - <a href="https://mermaid.live/edit#pako:eNqNkMFugzAMhl8F-VyVAR1tOW_aA-zKxSSGRCMJCk6lCvHuNZPKZdM0n-zf3_8r8QIqaIIGMqnB8kfEybQ--y4VnLP8-9RF9Mpkmm40hmlnDKmvkPiH_kfS7nFo_VN0FAf6XwocQGgxa_nGsm1bYEOOWmik1dRjGrmF1q-Cpkkj07u2HCI0PY4zHQATh8-7V9BwTPSE3iwOEd1OjQE1iWkBvk_bzQY7s0Sq4Hs7bHqKo8iGeZqbPN_WR7mpSd1RHpvPVhuMbG7XOq_L-oJlRfW5wteq0qorrpe-PBW9Pr8UJcK6rg-BLYPQ">live editor</a>]
|
### Git graph [experimental - <a href="https://mermaid.live/edit#pako:eNqNkMFugzAMhl8F-VyVAR1tOW_aA-zKxSSGRCMJCk6lCvHuNZPKZdM0n-zf3_8r8QIqaIIGMqnB8kfEybQ--y4VnLP8-9RF9Mpkmm40hmlnDKmvkPiH_kfS7nFo_VN0FAf6XwocQGgxa_nGsm1bYEOOWmik1dRjGrmF1q-Cpkkj07u2HCI0PY4zHQATh8-7V9BwTPSE3iwOEd1OjQE1iWkBvk_bzQY7s0Sq4Hs7bHqKo8iGeZqbPN_WR7mpSd1RHpvPVhuMbG7XOq_L-oJlRfW5wteq0qorrpe-PBW9Pr8UJcK6rg-BLYPQ">live editor</a>]
|
||||||
|
|
||||||
|
### Bar chart (using gantt chart) [<a href="https://mermaid-js.github.io/mermaid/#/gantt">docs</a> - <a href="https://mermaid.live/edit#pako:eNptkU1vhCAQhv8KIenNugiI4rkf6bmXpvEyFVxJFDYyNt1u9r8X63Z7WQ9m5pknLzieaBeMpQ3dg0dsPUkPOhwteXZIXmJcbCT3xMAxkuh8Z8kIEclyMIB209fqKcwTICFvG4IvFy_oLrZ-g9F26ILfQgvNFN94VaRXQ1iWqpumZBcu1J8p1E1TXDx59eQNr5LyEqjJn6hv5QnGNlxevZJmdLLpy5xJSzut45biYCfb0iaVxvawjNjS1p-TCguG16PvaIPzYjO67e3BwX6GiTY9jPFKH43DMF_hGMDY1J4oHg-_f8hFTJFd8L3br3yZx4QHxENsdrt1nO8dDstH3oVpF50ZYMbhU6ud4qoGLqyqBJRCmO6j0HXPZdGbihUc6Pmc0QP49xD-b5X69ZQv2gjO81IwzWqhC1lKrjJ6pA3nVS7SMiVjrKirWlYp5fs3osgrWeo00lorLWvOzz8JVbXm">live editor</a>]
|
||||||
|
|
||||||
|
```
|
||||||
|
gantt
|
||||||
|
title Git Issues - days since last update
|
||||||
|
dateFormat X
|
||||||
|
axisFormat %s
|
||||||
|
|
||||||
|
section Issue19062
|
||||||
|
71 : 0, 71
|
||||||
|
section Issue19401
|
||||||
|
36 : 0, 36
|
||||||
|
section Issue193
|
||||||
|
34 : 0, 34
|
||||||
|
section Issue7441
|
||||||
|
9 : 0, 9
|
||||||
|
section Issue1300
|
||||||
|
5 : 0, 5
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
gantt
|
||||||
|
title Git Issues - days since last update
|
||||||
|
dateFormat X
|
||||||
|
axisFormat %s
|
||||||
|
|
||||||
|
section Issue19062
|
||||||
|
71 : 0, 71
|
||||||
|
section Issue19401
|
||||||
|
36 : 0, 36
|
||||||
|
section Issue193
|
||||||
|
34 : 0, 34
|
||||||
|
section Issue7441
|
||||||
|
9 : 0, 9
|
||||||
|
section Issue1300
|
||||||
|
5 : 0, 5
|
||||||
|
```
|
||||||
|
|
||||||
### User Journey diagram [<a href="https://mermaid-js.github.io/mermaid/#/user-journey">docs</a> - <a href="https://mermaid.live/edit#pako:eNplkMFuwjAQRH9l5TMiTVIC-FqqnjhxzWWJN4khsSN7XRSh_HsdKBVt97R6Mzsj-yoqq0hIAXCywRkaSwNxWHNHsB_hYt1ZmwYUfiueKtbWwIcFtjf5zgH2eCZgQgkrCXt64GgMg2fUzkvIn5Xd_V5COtMFvCH_62ht_5yk7MU8sn61HDTfxD8VYiF6cj1qFd94nWkpuKWYKWRcFdUYOi5FaaZoDYNCpnel2Toha-w8LQQGtofRVEKyC_Qw7TQ2DvsfV2dRUTy6Ch6H-UMb7TlGVtbUupl5cF3ELfPgZZLM8rLR3IbjsrJ94rVq0XH7uS2SIis2mOVUrHNc5bmqjul2U2evaa3WL2mGYpqmL2BGiho">live editor</a>]
|
### User Journey diagram [<a href="https://mermaid-js.github.io/mermaid/#/user-journey">docs</a> - <a href="https://mermaid.live/edit#pako:eNplkMFuwjAQRH9l5TMiTVIC-FqqnjhxzWWJN4khsSN7XRSh_HsdKBVt97R6Mzsj-yoqq0hIAXCywRkaSwNxWHNHsB_hYt1ZmwYUfiueKtbWwIcFtjf5zgH2eCZgQgkrCXt64GgMg2fUzkvIn5Xd_V5COtMFvCH_62ht_5yk7MU8sn61HDTfxD8VYiF6cj1qFd94nWkpuKWYKWRcFdUYOi5FaaZoDYNCpnel2Toha-w8LQQGtofRVEKyC_Qw7TQ2DvsfV2dRUTy6Ch6H-UMb7TlGVtbUupl5cF3ELfPgZZLM8rLR3IbjsrJ94rVq0XH7uS2SIis2mOVUrHNc5bmqjul2U2evaa3WL2mGYpqmL2BGiho">live editor</a>]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// @ts-nocheck TODO: Fix TS
|
// @ts-nocheck TODO: Fix TS
|
||||||
import { MockedD3 } from '../packages/mermaid/src/tests/MockedD3';
|
import { MockedD3 } from '../packages/mermaid/src/tests/MockedD3.js';
|
||||||
|
|
||||||
export const select = function () {
|
export const select = function () {
|
||||||
return new MockedD3();
|
return new MockedD3();
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
"graphviz",
|
"graphviz",
|
||||||
"grav",
|
"grav",
|
||||||
"greywolf",
|
"greywolf",
|
||||||
|
"huynh",
|
||||||
"inkdrop",
|
"inkdrop",
|
||||||
"jaoude",
|
"jaoude",
|
||||||
"jison",
|
"jison",
|
||||||
@ -90,6 +91,7 @@
|
|||||||
"sidharthv",
|
"sidharthv",
|
||||||
"sphinxcontrib",
|
"sphinxcontrib",
|
||||||
"statediagram",
|
"statediagram",
|
||||||
|
"steph",
|
||||||
"stylis",
|
"stylis",
|
||||||
"substate",
|
"substate",
|
||||||
"sveidqvist",
|
"sveidqvist",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { renderGraph } from '../../helpers/util';
|
import { renderGraph } from '../../helpers/util.js';
|
||||||
describe('Configuration', () => {
|
describe('Configuration', () => {
|
||||||
describe('arrowMarkerAbsolute', () => {
|
describe('arrowMarkerAbsolute', () => {
|
||||||
it('should handle default value false of arrowMarkerAbsolute', () => {
|
it('should handle default value false of arrowMarkerAbsolute', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { urlSnapshotTest } from '../../helpers/util';
|
import { urlSnapshotTest } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('mermaid', () => {
|
describe('mermaid', () => {
|
||||||
describe('registerDiagram', () => {
|
describe('registerDiagram', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { urlSnapshotTest } from '../../helpers/util';
|
import { urlSnapshotTest } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('CSS injections', () => {
|
describe('CSS injections', () => {
|
||||||
it('should not allow CSS injections outside of the diagram', () => {
|
it('should not allow CSS injections outside of the diagram', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util';
|
import { imgSnapshotTest } from '../../helpers/util.js';
|
||||||
describe('Class diagram V2', () => {
|
describe('Class diagram V2', () => {
|
||||||
it('0: should render a simple class diagram', () => {
|
it('0: should render a simple class diagram', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Class diagram', () => {
|
describe('Class diagram', () => {
|
||||||
it('1: should render a simple class diagram', () => {
|
it('1: should render a simple class diagram', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util';
|
import { imgSnapshotTest } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Current diagram', () => {
|
describe('Current diagram', () => {
|
||||||
it('should render a state with states in it', () => {
|
it('should render a state with states in it', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util';
|
import { imgSnapshotTest } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Flowchart', () => {
|
describe('Flowchart', () => {
|
||||||
it('34: testing the label width in percy', () => {
|
it('34: testing the label width in percy', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Entity Relationship Diagram', () => {
|
describe('Entity Relationship Diagram', () => {
|
||||||
it('should render a simple ER diagram', () => {
|
it('should render a simple ER diagram', () => {
|
||||||
@ -10,7 +10,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an ER diagram with a recursive relationship', () => {
|
it('should render an ER diagram with a recursive relationship', () => {
|
||||||
@ -23,7 +22,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an ER diagram with multiple relationships between the same two entities', () => {
|
it('should render an ER diagram with multiple relationships between the same two entities', () => {
|
||||||
@ -35,7 +33,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a cyclical ER diagram', () => {
|
it('should render a cyclical ER diagram', () => {
|
||||||
@ -48,7 +45,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a not-so-simple ER diagram', () => {
|
it('should render a not-so-simple ER diagram', () => {
|
||||||
@ -66,7 +62,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render multiple ER diagrams', () => {
|
it('should render multiple ER diagrams', () => {
|
||||||
@ -85,7 +80,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
],
|
],
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an ER diagram with blank or empty labels', () => {
|
it('should render an ER diagram with blank or empty labels', () => {
|
||||||
@ -98,7 +92,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an ER diagrams when useMaxWidth is true (default)', () => {
|
it('should render an ER diagrams when useMaxWidth is true (default)', () => {
|
||||||
@ -151,7 +144,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ er: { useMaxWidth: false } }
|
{ er: { useMaxWidth: false } }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with and without attributes', () => {
|
it('should render entities with and without attributes', () => {
|
||||||
@ -164,7 +156,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with generic and array attributes', () => {
|
it('should render entities with generic and array attributes', () => {
|
||||||
@ -179,7 +170,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with length in attributes type', () => {
|
it('should render entities with length in attributes type', () => {
|
||||||
@ -193,7 +183,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities and attributes with big and small entity names', () => {
|
it('should render entities and attributes with big and small entity names', () => {
|
||||||
@ -209,7 +198,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with keys', () => {
|
it('should render entities with keys', () => {
|
||||||
@ -228,7 +216,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with comments', () => {
|
it('should render entities with comments', () => {
|
||||||
@ -247,7 +234,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with keys and comments', () => {
|
it('should render entities with keys and comments', () => {
|
||||||
@ -267,7 +253,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render entities with aliases', () => {
|
it('should render entities with aliases', () => {
|
||||||
@ -285,7 +270,6 @@ describe('Entity Relationship Diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{ logLevel: 1 }
|
{ logLevel: 1 }
|
||||||
);
|
);
|
||||||
cy.get('svg');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('1433: should render a simple ER diagram with a title', () => {
|
it('1433: should render a simple ER diagram with a title', () => {
|
||||||
|
45
cypress/integration/rendering/errorDiagram.spec.js
Normal file
45
cypress/integration/rendering/errorDiagram.spec.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { imgSnapshotTest } from '../../helpers/util';
|
||||||
|
|
||||||
|
describe('Error Diagrams', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.on('uncaught:exception', (err) => {
|
||||||
|
expect(err.message).to.include('Parse error');
|
||||||
|
// return false to prevent the error from
|
||||||
|
// failing this test
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render a simple ER diagram', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
error
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render error diagram for actual errors', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
flowchart TD
|
||||||
|
A[Christmas] --|Get money| B(Go shopping)
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render error for wrong ER diagram', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
erDiagram
|
||||||
|
ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many"
|
||||||
|
MONGODB-CLUSTERS ||..|{
|
||||||
|
ATLAS-TEAMS ||..|{
|
||||||
|
`,
|
||||||
|
{ logLevel: 1 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe.skip('Flowchart ELK', () => {
|
describe.skip('Flowchart ELK', () => {
|
||||||
it('1-elk: should render a simple flowchart', () => {
|
it('1-elk: should render a simple flowchart', () => {
|
||||||
@ -684,4 +684,149 @@ A --> B
|
|||||||
{ titleTopMargin: 0 }
|
{ titleTopMargin: 0 }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
describe('Markdown strings flowchart-elk (#4220)', () => {
|
||||||
|
describe('html labels', () => {
|
||||||
|
it('With styling and classes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass
|
||||||
|
id1(Start)-->id2(Stop)
|
||||||
|
style id1 fill:#f9f,stroke:#333,stroke-width:4px
|
||||||
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
|
classDef someclass fill:#f96
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('With formatting in a node', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
a{"\`The **cat** in the hat\`"} -- 1o --> b
|
||||||
|
a -- 2o --> c
|
||||||
|
a -- 3o --> d
|
||||||
|
g --2i--> a
|
||||||
|
d --1i--> a
|
||||||
|
h --3i -->a
|
||||||
|
b --> d(The dog in the hog)
|
||||||
|
c --> d
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('New line in node and formatted edge label', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
b("\`The dog in **the** hog.(1)
|
||||||
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Wrapping long text with a new line', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
b(\`The dog in **the** hog.(1).. a a a a *very long text* about it
|
||||||
|
Word!
|
||||||
|
|
||||||
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`) --> c
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Sub graphs and markdown strings', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
subgraph "One"
|
||||||
|
a("\`The **cat**
|
||||||
|
in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}}
|
||||||
|
end
|
||||||
|
subgraph "\`**Two**\`"
|
||||||
|
c("\`The **cat**
|
||||||
|
in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('svg text labels', () => {
|
||||||
|
it('With styling and classes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass
|
||||||
|
id1(Start)-->id2(Stop)
|
||||||
|
style id1 fill:#f9f,stroke:#333,stroke-width:4px
|
||||||
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
|
classDef someclass fill:#f96
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('With formatting in a node', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
a{"\`The **cat** in the hat\`"} -- 1o --> b
|
||||||
|
a -- 2o --> c
|
||||||
|
a -- 3o --> d
|
||||||
|
g --2i--> a
|
||||||
|
d --1i--> a
|
||||||
|
h --3i -->a
|
||||||
|
b --> d(The dog in the hog)
|
||||||
|
c --> d
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('New line in node and formatted edge label', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
b("\`The dog in **the** hog.(1)
|
||||||
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Wrapping long text with a new line', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
b("\`The dog in **the** hog.(1).. a a a a *very long text* about it
|
||||||
|
Word!
|
||||||
|
|
||||||
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Sub graphs and markdown strings', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart-elk LR
|
||||||
|
subgraph "One"
|
||||||
|
a("\`The **cat**
|
||||||
|
in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}}
|
||||||
|
end
|
||||||
|
subgraph "\`**Two**\`"
|
||||||
|
c("\`The **cat**
|
||||||
|
in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Flowchart v2', () => {
|
describe('Flowchart v2', () => {
|
||||||
it('1: should render a simple flowchart', () => {
|
it('1: should render a simple flowchart', () => {
|
||||||
@ -685,4 +685,159 @@ A ~~~ B
|
|||||||
{ titleTopMargin: 0 }
|
{ titleTopMargin: 0 }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('4023: Should render html labels with images and-or text correctly', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`flowchart TD
|
||||||
|
B[<img src='https://mermaid.js.org/mermaid-logo.svg'>]
|
||||||
|
B-->C[<img src="https://mermaid.js.org/mermaid-logo.svg"> more text <img src='https://mermaid.js.org/mermaid-logo.svg'>]
|
||||||
|
B-->D(<img src='https://mermaid.js.org/mermaid-logo.svg'> some text)
|
||||||
|
B-->E(plain)`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
describe('Markdown strings flowchart (#4220)', () => {
|
||||||
|
describe('html labels', () => {
|
||||||
|
it('With styling and classes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart LR
|
||||||
|
A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass
|
||||||
|
id1(Start)-->id2(Stop)
|
||||||
|
style id1 fill:#f9f,stroke:#333,stroke-width:4px
|
||||||
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
|
classDef someclass fill:#f96
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('With formatting in a node', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart LR
|
||||||
|
a{"\`The **cat** in the hat\`"} -- 1o --> b
|
||||||
|
a -- 2o --> c
|
||||||
|
a -- 3o --> d
|
||||||
|
g --2i--> a
|
||||||
|
d --1i--> a
|
||||||
|
h --3i -->a
|
||||||
|
b --> d(The dog in the hog)
|
||||||
|
c --> d
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('New line in node and formatted edge label', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart LR
|
||||||
|
b("\`The dog in **the** hog.(1)
|
||||||
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Wrapping long text with a new line', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart LR
|
||||||
|
b("\`The dog in **the** hog.(1).. a a a a *very long text* about it
|
||||||
|
Word!
|
||||||
|
|
||||||
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Sub graphs and markdown strings', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": true}} }%%
|
||||||
|
flowchart LR
|
||||||
|
subgraph "One"
|
||||||
|
a("\`The **cat**
|
||||||
|
in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}}
|
||||||
|
end
|
||||||
|
subgraph "\`**Two**\`"
|
||||||
|
c("\`The **cat**
|
||||||
|
in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('svg text labels', () => {
|
||||||
|
it('With styling and classes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass
|
||||||
|
id1(Start)-->id2(Stop)
|
||||||
|
style id1 fill:#f9f,stroke:#333,stroke-width:4px
|
||||||
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
|
classDef someclass fill:#f96
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('With formatting in a node', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
a{"\`The **cat** in the hat\`"} -- 1o --> b
|
||||||
|
a -- 2o --> c
|
||||||
|
a -- 3o --> d
|
||||||
|
g --2i--> a
|
||||||
|
d --1i--> a
|
||||||
|
h --3i -->a
|
||||||
|
b --> d(The dog in the hog)
|
||||||
|
c --> d
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('New line in node and formatted edge label', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
b("\`The dog in **the** hog.(1)
|
||||||
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Wrapping long text with a new line', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
b("\`The dog in **the** hog.(1).. a a a a *very long text* about it
|
||||||
|
Word!
|
||||||
|
|
||||||
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('Sub graphs and markdown strings', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
subgraph "One"
|
||||||
|
a("\`The **cat**
|
||||||
|
in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}}
|
||||||
|
end
|
||||||
|
subgraph "\`**Two**\`"
|
||||||
|
c("\`The **cat**
|
||||||
|
in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Graph', () => {
|
describe('Graph', () => {
|
||||||
it('1: should render a simple flowchart no htmlLabels', () => {
|
it('1: should render a simple flowchart no htmlLabels', () => {
|
||||||
|
@ -133,6 +133,24 @@ describe('Gantt diagram', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should default to showing today marker', () => {
|
||||||
|
// This test only works if the environment thinks today is 1010-10-10
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title Show today marker (vertical line should be visible)
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
axisFormat %d
|
||||||
|
%% Should default to being on
|
||||||
|
%% todayMarker on
|
||||||
|
section Section1
|
||||||
|
Yesterday: 1010-10-09, 1d
|
||||||
|
Today: 1010-10-10, 1d
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should hide today marker', () => {
|
it('should hide today marker', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@ -142,7 +160,8 @@ describe('Gantt diagram', () => {
|
|||||||
axisFormat %d
|
axisFormat %d
|
||||||
todayMarker off
|
todayMarker off
|
||||||
section Section1
|
section Section1
|
||||||
Today: 1, -1h
|
Yesterday: 1010-10-09, 1d
|
||||||
|
Today: 1010-10-10, 1d
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
@ -157,7 +176,8 @@ describe('Gantt diagram', () => {
|
|||||||
axisFormat %d
|
axisFormat %d
|
||||||
todayMarker stroke-width:5px,stroke:#00f,opacity:0.5
|
todayMarker stroke-width:5px,stroke:#00f,opacity:0.5
|
||||||
section Section1
|
section Section1
|
||||||
Today: 1, -1h
|
Yesterday: 1010-10-09, 1d
|
||||||
|
Today: 1010-10-10, 1d
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
@ -435,4 +455,39 @@ describe('Gantt diagram', () => {
|
|||||||
{ gantt: { topAxis: true } }
|
{ gantt: { topAxis: true } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render when compact is true', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
---
|
||||||
|
displayMode: compact
|
||||||
|
---
|
||||||
|
gantt
|
||||||
|
title GANTT compact
|
||||||
|
dateFormat HH:mm:ss
|
||||||
|
axisFormat %Hh%M
|
||||||
|
|
||||||
|
section DB Clean
|
||||||
|
Clean: 12:00:00, 10m
|
||||||
|
Clean: 12:30:00, 12m
|
||||||
|
Clean: 13:00:00, 8m
|
||||||
|
Clean: 13:30:00, 9m
|
||||||
|
Clean: 14:00:00, 13m
|
||||||
|
Clean: 14:30:00, 10m
|
||||||
|
Clean: 15:00:00, 11m
|
||||||
|
|
||||||
|
section Sessions
|
||||||
|
A: 12:00:00, 63m
|
||||||
|
B: 12:30:00, 12m
|
||||||
|
C: 13:05:00, 12m
|
||||||
|
D: 13:06:00, 33m
|
||||||
|
E: 13:15:00, 55m
|
||||||
|
F: 13:20:00, 12m
|
||||||
|
G: 13:32:00, 18m
|
||||||
|
H: 13:50:00, 20m
|
||||||
|
I: 14:10:00, 10m
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -223,5 +223,18 @@ mindmap
|
|||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
describe('Markdown strings mindmaps (#4220)', () => {
|
||||||
|
it('Formatted label with linebreak and a wrapping label and emojis', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`mindmap
|
||||||
|
id1[\`**Start** with
|
||||||
|
a second line 😎\`]
|
||||||
|
id2[\`The dog in **the** hog... a *very long text* about it
|
||||||
|
Word!\`]
|
||||||
|
`,
|
||||||
|
{ titleTopMargin: 0 }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
/* The end */
|
/* The end */
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/// <reference types="Cypress" />
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
context('Sequence diagram', () => {
|
context('Sequence diagram', () => {
|
||||||
it('should render a sequence diagram with boxes', () => {
|
it('should render a sequence diagram with boxes', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('State diagram', () => {
|
describe('State diagram', () => {
|
||||||
it('v2 should render a simple info', () => {
|
it('v2 should render a simple info', () => {
|
||||||
@ -530,7 +530,7 @@ stateDiagram-v2
|
|||||||
[*] --> A
|
[*] --> A
|
||||||
A --> B: test({ foo#colon; 'far' })
|
A --> B: test({ foo#colon; 'far' })
|
||||||
B --> [*]
|
B --> [*]
|
||||||
classDef badBadEvent fill:#f00,color:white,font-weight:bold
|
classDef badBadEvent fill:#f00,color:white,font-weight:bold
|
||||||
class B badBadEvent
|
class B badBadEvent
|
||||||
`,
|
`,
|
||||||
{ logLevel: 0, fontFamily: 'courier' }
|
{ logLevel: 0, fontFamily: 'courier' }
|
||||||
@ -543,14 +543,14 @@ stateDiagram-v2
|
|||||||
classDef notMoving fill:white
|
classDef notMoving fill:white
|
||||||
classDef movement font-style:italic;
|
classDef movement font-style:italic;
|
||||||
classDef badBadEvent fill:#f00,color:white,font-weight:bold
|
classDef badBadEvent fill:#f00,color:white,font-weight:bold
|
||||||
|
|
||||||
[*] --> Still
|
[*] --> Still
|
||||||
Still --> [*]
|
Still --> [*]
|
||||||
Still --> Moving
|
Still --> Moving
|
||||||
Moving --> Still
|
Moving --> Still
|
||||||
Moving --> Crash
|
Moving --> Crash
|
||||||
Crash --> [*]
|
Crash --> [*]
|
||||||
|
|
||||||
class Still notMoving
|
class Still notMoving
|
||||||
class Moving, Crash movement
|
class Moving, Crash movement
|
||||||
class Crash badBadEvent
|
class Crash badBadEvent
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('State diagram', () => {
|
describe('State diagram', () => {
|
||||||
it('should render a simple state diagrams', () => {
|
it('should render a simple state diagrams', () => {
|
||||||
|
@ -188,7 +188,7 @@ mindmap
|
|||||||
//import mindmap from '../../packages/mermaid-mindmap/src/detector';
|
//import mindmap from '../../packages/mermaid-mindmap/src/detector';
|
||||||
// import example from '../../packages/mermaid-example-diagram/src/detector';
|
// import example from '../../packages/mermaid-example-diagram/src/detector';
|
||||||
// import timeline from '../../packages/mermaid-timeline/src/detector';
|
// import timeline from '../../packages/mermaid-timeline/src/detector';
|
||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
// await mermaid.registerExternalDiagrams([]);
|
// await mermaid.registerExternalDiagrams([]);
|
||||||
mermaid.parseError = function (err, hash) {
|
mermaid.parseError = function (err, hash) {
|
||||||
// console.error('Mermaid error: ', err);
|
// console.error('Mermaid error: ', err);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
// TODO: this file should be testing the ./mermaid.core.mjs file, as that's the file listed in the package.json file that users will use
|
||||||
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
|
||||||
let code = `flowchart LR
|
let code = `flowchart LR
|
||||||
Power_Supply --> Transmitter_A
|
Power_Supply --> Transmitter_A
|
||||||
|
@ -11,9 +11,9 @@ example-diagram
|
|||||||
<!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> -->
|
<!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> -->
|
||||||
<!-- <script type="module" src="./external-diagrams-mindmap.mjs" /> -->
|
<!-- <script type="module" src="./external-diagrams-mindmap.mjs" /> -->
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import exampleDiagram from '../../packages/mermaid-example-diagram/src/detector';
|
import exampleDiagram from '../../packages/mermaid-example-diagram/dist/mermaid-example-diagram.core.mjs';
|
||||||
// import example from '../../packages/mermaid-example-diagram/src/detector';
|
// import example from '../../packages/mermaid-example-diagram/src/detector';
|
||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
|
||||||
await mermaid.registerExternalDiagrams([exampleDiagram]);
|
await mermaid.registerExternalDiagrams([exampleDiagram]);
|
||||||
await mermaid.initialize({ logLevel: 0 });
|
await mermaid.initialize({ logLevel: 0 });
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme: 'forest',
|
theme: 'forest',
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
}
|
}
|
||||||
.mermaid svg {
|
.mermaid svg {
|
||||||
/* font-size: 18px !important; */
|
/* font-size: 18px !important; */
|
||||||
background-color: #eee;
|
background-color: #efefef;
|
||||||
background-image: radial-gradient(#fff 1%, transparent 11%),
|
background-image: radial-gradient(#fff 51%, transparent 91%),
|
||||||
radial-gradient(#fff 1%, transparent 11%);
|
radial-gradient(#fff 51%, transparent 91%);
|
||||||
background-size: 20px 20px;
|
background-size: 20px 20px;
|
||||||
background-position: 0 0, 10px 10px;
|
background-position: 0 0, 10px 10px;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
@ -51,29 +51,103 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 72px;
|
font-size: 72px;
|
||||||
}
|
}
|
||||||
|
/* tspan {
|
||||||
|
font-size: 6px !important;
|
||||||
|
} */
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
stateDiagram-v2
|
||||||
graph BT
|
[*] --> Still
|
||||||
a{The cat in the hat} -- 1o --> b
|
Still --> [*]
|
||||||
a -- 2o --> c
|
Still --> Moving
|
||||||
a -- 3o --> d
|
Moving --> Still
|
||||||
g --2i--> a
|
Moving --> Crash
|
||||||
d --1i--> a
|
Crash --> [*] </pre
|
||||||
h --3i -->a
|
>
|
||||||
b --> d(The dog in the hog)
|
<pre id="diagram" class="mermaid2">
|
||||||
c --> d
|
flowchart RL
|
||||||
|
subgraph "`one`"
|
||||||
|
a1 -- l1 --> a2
|
||||||
|
a1 -- l2 --> a2
|
||||||
|
end
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram" class="mermaid">
|
||||||
|
flowchart RL
|
||||||
|
subgraph "`one`"
|
||||||
|
a1 -- l1 --> a2
|
||||||
|
a1 -- l2 --> a2
|
||||||
|
end
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid2">
|
<pre id="diagram" class="mermaid2">
|
||||||
flowchart-elk TB
|
flowchart
|
||||||
a --> b
|
id["`A root with a long text that wraps to keep the node size in check. A root with a long text that wraps to keep the node size in check`"]</pre
|
||||||
a --> c
|
>
|
||||||
b --> d
|
<pre id="diagram" class="mermaid2">
|
||||||
c --> d
|
flowchart LR
|
||||||
|
A[A text that needs to be wrapped wraps to another line]
|
||||||
|
B[A text that needs to be<br/>wrapped wraps to another line]
|
||||||
|
C["`A text that needs to be wrapped to another line`"]</pre>
|
||||||
|
<pre id="diagram" class="mermaid2">
|
||||||
|
flowchart LR
|
||||||
|
C["`A text
|
||||||
|
that needs
|
||||||
|
to be wrapped
|
||||||
|
in another
|
||||||
|
way`"]
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
<pre id="diagram" class="mermaid">
|
||||||
|
classDiagram-v2
|
||||||
|
note "I love this diagram!\nDo you love it?"
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram" class="mermaid">
|
||||||
|
stateDiagram-v2
|
||||||
|
State1: The state with a note with minus - and plus + in it
|
||||||
|
note left of State1
|
||||||
|
Important information! You can write
|
||||||
|
notes with . and in them.
|
||||||
|
end note </pre
|
||||||
|
>
|
||||||
|
<pre id="diagram" class="mermaid2">
|
||||||
|
mindmap
|
||||||
|
root
|
||||||
|
Child3(A node with an icon and with a long text that wraps to keep the node size in check)
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
<pre id="diagram" class="mermaid2">
|
||||||
|
%%{init: {"theme": "forest"} }%%
|
||||||
|
mindmap
|
||||||
|
id1[**Start2**<br/>end]
|
||||||
|
id2[**Start2**<br />end]
|
||||||
|
%% Another comment
|
||||||
|
id3[**Start2**<br>end] %% Comment
|
||||||
|
id4[**Start2**<br >end<br >the very end]
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid2">
|
<pre id="diagram" class="mermaid2">
|
||||||
|
mindmap
|
||||||
|
id1["`**Start2**
|
||||||
|
second line 😎 with long text that is wrapping to the next line`"]
|
||||||
|
id2["`Child **with bold** text`"]
|
||||||
|
id3["`Children of which some
|
||||||
|
is using *italic type of* text`"]
|
||||||
|
id4[Child]
|
||||||
|
id5["`Child
|
||||||
|
Row
|
||||||
|
and another
|
||||||
|
`"]
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram" class="mermaid2">
|
||||||
|
mindmap
|
||||||
|
id1("`**Root**`"]
|
||||||
|
id2["`A formatted text... with **bold** and *italics*`"]
|
||||||
|
id3[Regular labels works as usual]
|
||||||
|
id4["`Emojis and unicode works too: 🤓
|
||||||
|
शान्तिः سلام 和平 `"]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram" class="mermaid">
|
||||||
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
||||||
flowchart TB
|
flowchart TB
|
||||||
%% I could not figure out how to use double quotes in labels in Mermaid
|
%% I could not figure out how to use double quotes in labels in Mermaid
|
||||||
@ -89,7 +163,7 @@ flowchart TB
|
|||||||
rom --> core2
|
rom --> core2
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph amd[AMD Latte GPU]
|
subgraph amd["`**AMD** Latte GPU`"]
|
||||||
mem[Memory & I/O Bridge]
|
mem[Memory & I/O Bridge]
|
||||||
dram[DRAM Controller]
|
dram[DRAM Controller]
|
||||||
edram[32 MB EDRAM MEM1]
|
edram[32 MB EDRAM MEM1]
|
||||||
@ -128,6 +202,62 @@ flowchart TB
|
|||||||
rtc{{rtc}}
|
rtc{{rtc}}
|
||||||
</pre
|
</pre
|
||||||
>
|
>
|
||||||
|
<pre id="diagram" class="mermaid2">
|
||||||
|
%%{init: {"flowchart": {"defaultRenderer": "elk", "htmlLabels": false}} }%%
|
||||||
|
flowchart TB
|
||||||
|
%% I could not figure out how to use double quotes in labels in Mermaid
|
||||||
|
subgraph ibm[IBM Espresso CPU]
|
||||||
|
core0[IBM PowerPC Broadway Core 0]
|
||||||
|
core1[IBM PowerPC Broadway Core 1]
|
||||||
|
core2[IBM PowerPC Broadway Core 2]
|
||||||
|
|
||||||
|
rom[16 KB ROM]
|
||||||
|
|
||||||
|
core0 --- core2
|
||||||
|
|
||||||
|
rom --> core2
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph amd["`**AMD** Latte GPU`"]
|
||||||
|
mem[Memory & I/O Bridge]
|
||||||
|
dram[DRAM Controller]
|
||||||
|
edram[32 MB EDRAM MEM1]
|
||||||
|
rom[512 B SEEPROM]
|
||||||
|
|
||||||
|
sata[SATA IF]
|
||||||
|
exi[EXI]
|
||||||
|
|
||||||
|
subgraph gx[GX]
|
||||||
|
sram[3 MB 1T-SRAM]
|
||||||
|
end
|
||||||
|
|
||||||
|
radeon[AMD Radeon R7xx GX2]
|
||||||
|
|
||||||
|
mem --- gx
|
||||||
|
mem --- radeon
|
||||||
|
|
||||||
|
rom --- mem
|
||||||
|
|
||||||
|
mem --- sata
|
||||||
|
mem --- exi
|
||||||
|
|
||||||
|
dram --- sata
|
||||||
|
dram --- exi
|
||||||
|
end
|
||||||
|
|
||||||
|
ddr3[2 GB DDR3 RAM MEM2]
|
||||||
|
|
||||||
|
mem --- ddr3
|
||||||
|
dram --- ddr3
|
||||||
|
edram --- ddr3
|
||||||
|
|
||||||
|
core1 --- mem
|
||||||
|
|
||||||
|
exi --- rtc
|
||||||
|
rtc{{rtc}}
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<pre id="diagram" class="mermaid2">
|
<pre id="diagram" class="mermaid2">
|
||||||
flowchart TB
|
flowchart TB
|
||||||
@ -263,21 +393,23 @@ mindmap
|
|||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
// import mindmap from '../../packages/mermaid-mindmap/src/detector';
|
// import mindmap from '../../packages/mermaid-mindmap/src/detector';
|
||||||
import example from '../../packages/mermaid-example-diagram/src/detector';
|
import example from '../../packages/mermaid-example-diagram/src/mermaid-example-diagram.core.mjs';
|
||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
await mermaid.registerExternalDiagrams([example]);
|
await mermaid.registerExternalDiagrams([example]);
|
||||||
mermaid.parseError = function (err, hash) {
|
mermaid.parseError = function (err, hash) {
|
||||||
// console.error('Mermaid error: ', err);
|
// console.error('Mermaid error: ', err);
|
||||||
};
|
};
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme: 'forest',
|
// theme: 'forest',
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
logLevel: 5,
|
logLevel: 0,
|
||||||
flowchart: {
|
flowchart: {
|
||||||
// defaultRenderer: 'elk',
|
// defaultRenderer: 'elk',
|
||||||
useMaxWidth: false,
|
useMaxWidth: false,
|
||||||
|
// htmlLabels: false,
|
||||||
htmlLabels: true,
|
htmlLabels: true,
|
||||||
},
|
},
|
||||||
|
// htmlLabels: false,
|
||||||
gantt: {
|
gantt: {
|
||||||
useMaxWidth: false,
|
useMaxWidth: false,
|
||||||
},
|
},
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
// import mermaid from './mermaid.esm.mjs';
|
// import mermaid from './mermaid.esm.mjs';
|
||||||
import mermaid from '../../packages/mermaid/src/mermaid';
|
import mermaid from '../../packages/mermaid/dist/mermaid.esm.mjs';
|
||||||
// import mermaidMindmap from './mermaid-mindmap.esm.mjs';
|
// import mermaidMindmap from './mermaid-mindmap.esm.mjs';
|
||||||
|
|
||||||
// import mermaidMindmap from 'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.3.0/+esm';
|
// import mermaidMindmap from 'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.3.0/+esm';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import mermaid2 from '../../packages/mermaid/src/mermaid';
|
import mermaid2 from './mermaid.esm.mjs';
|
||||||
import externalExample from '../../packages/mermaid-example-diagram/src/detector';
|
import externalExample from '../../packages/mermaid-example-diagram/dist/mermaid-example-diagram.core.mjs';
|
||||||
|
|
||||||
function b64ToUtf8(str) {
|
function b64ToUtf8(str) {
|
||||||
return decodeURIComponent(escape(window.atob(str)));
|
return decodeURIComponent(escape(window.atob(str)));
|
||||||
@ -47,7 +47,6 @@ const contentLoaded = async function () {
|
|||||||
await mermaid2.registerExternalDiagrams([externalExample]);
|
await mermaid2.registerExternalDiagrams([externalExample]);
|
||||||
mermaid2.initialize(graphObj.mermaid);
|
mermaid2.initialize(graphObj.mermaid);
|
||||||
await mermaid2.run();
|
await mermaid2.run();
|
||||||
markRendered();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -123,7 +122,6 @@ const contentLoadedApi = async function () {
|
|||||||
bindFunctions(div);
|
bindFunctions(div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
markRendered();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof document !== 'undefined') {
|
if (typeof document !== 'undefined') {
|
||||||
@ -135,10 +133,10 @@ if (typeof document !== 'undefined') {
|
|||||||
function () {
|
function () {
|
||||||
if (this.location.href.match('xss.html')) {
|
if (this.location.href.match('xss.html')) {
|
||||||
this.console.log('Using api');
|
this.console.log('Using api');
|
||||||
void contentLoadedApi();
|
void contentLoadedApi().finally(markRendered);
|
||||||
} else {
|
} else {
|
||||||
this.console.log('Not using api');
|
this.console.log('Not using api');
|
||||||
void contentLoaded();
|
void contentLoaded().finally(markRendered);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
|
38
demos/error.html
Normal file
38
demos/error.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<title>Error | Mermaid Quick Test Page</title>
|
||||||
|
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<pre class="mermaid">
|
||||||
|
erDiagram
|
||||||
|
ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many"
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
erDiagram
|
||||||
|
ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many"
|
||||||
|
ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many"
|
||||||
|
MONGODB-CLUSTERS ||..|{
|
||||||
|
ATLAS-TEAMS ||..|{
|
||||||
|
</pre>
|
||||||
|
<hr />
|
||||||
|
<pre class="mermaid">
|
||||||
|
flowchart TD
|
||||||
|
A[Christmas] -->|Get money| B(Go shopping)
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
flowchart TD
|
||||||
|
A[Christmas] --|Get money| B(Go shopping)
|
||||||
|
</pre>
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -78,7 +78,7 @@
|
|||||||
axisFormat %d/%m
|
axisFormat %d/%m
|
||||||
todayMarker off
|
todayMarker off
|
||||||
section Section1
|
section Section1
|
||||||
Today: 1, -01:00, 5min
|
Today: 1, 08-08-09-01:00, 5min
|
||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
@ -89,7 +89,7 @@
|
|||||||
axisFormat %d/%m
|
axisFormat %d/%m
|
||||||
todayMarker stroke-width:5px,stroke:#00f,opacity:0.5
|
todayMarker stroke-width:5px,stroke:#00f,opacity:0.5
|
||||||
section Section1
|
section Section1
|
||||||
Today: 1, -01:00, 5min
|
Today: 1, 08-08-09-01:00, 5min
|
||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
@ -166,6 +166,37 @@
|
|||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
displayMode: compact
|
||||||
|
---
|
||||||
|
gantt
|
||||||
|
title GANTT compact
|
||||||
|
dateFormat HH:mm:ss
|
||||||
|
axisFormat %Hh%M
|
||||||
|
|
||||||
|
section DB Clean
|
||||||
|
Clean: 12:00:00, 10m
|
||||||
|
Clean: 12:30:00, 12m
|
||||||
|
Clean: 13:00:00, 8m
|
||||||
|
Clean: 13:30:00, 9m
|
||||||
|
Clean: 14:00:00, 13m
|
||||||
|
Clean: 14:30:00, 10m
|
||||||
|
Clean: 15:00:00, 11m
|
||||||
|
|
||||||
|
section Sessions
|
||||||
|
A: 12:00:00, 63m
|
||||||
|
B: 12:30:00, 12m
|
||||||
|
C: 13:05:00, 12m
|
||||||
|
D: 13:06:00, 33m
|
||||||
|
E: 13:15:00, 55m
|
||||||
|
F: 13:20:00, 12m
|
||||||
|
G: 13:32:00, 18m
|
||||||
|
H: 13:50:00, 20m
|
||||||
|
I: 14:10:00, 10m
|
||||||
|
</pre>
|
||||||
|
<hr />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function ganttTestClick(a, b, c) {
|
function ganttTestClick(a, b, c) {
|
||||||
console.log('a:', a);
|
console.log('a:', a);
|
||||||
|
@ -16,4 +16,4 @@
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:70](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L70)
|
[mermaidAPI.ts:77](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L77)
|
||||||
|
@ -39,7 +39,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:91](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L91)
|
[mermaidAPI.ts:98](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L98)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -51,4 +51,4 @@ The svg code for the rendered graph.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:81](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L81)
|
[mermaidAPI.ts:88](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L88)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[defaultConfig.ts:2093](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2093)
|
[defaultConfig.ts:2115](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2115)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:75](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L75)
|
[mermaidAPI.ts:82](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L82)
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
@ -88,6 +88,7 @@ const config = {
|
|||||||
numberSectionStyles: 4,
|
numberSectionStyles: 4,
|
||||||
axisFormat: '%Y-%m-%d',
|
axisFormat: '%Y-%m-%d',
|
||||||
topAxis: false,
|
topAxis: false,
|
||||||
|
displayMode: '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mermaid.initialize(config);
|
mermaid.initialize(config);
|
||||||
@ -95,7 +96,7 @@ mermaid.initialize(config);
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:659](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L659)
|
[mermaidAPI.ts:673](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L673)
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ Return the last node appended
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:305](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L305)
|
[mermaidAPI.ts:312](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L312)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ the cleaned up svgCode
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:256](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L256)
|
[mermaidAPI.ts:263](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L263)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ the string with all the user styles
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:185](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L185)
|
[mermaidAPI.ts:192](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L192)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ the string with all the user styles
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:233](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L233)
|
[mermaidAPI.ts:240](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L240)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:169](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L169)
|
[mermaidAPI.ts:176](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L176)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:149](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L149)
|
[mermaidAPI.ts:156](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L156)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -268,7 +269,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:120](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L120)
|
[mermaidAPI.ts:127](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L127)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -294,7 +295,7 @@ Put the svgCode into an iFrame. Return the iFrame code
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:284](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L284)
|
[mermaidAPI.ts:291](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L291)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -319,4 +320,4 @@ Remove any existing elements from the given document
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:355](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L355)
|
[mermaidAPI.ts:362](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L362)
|
||||||
|
@ -23,6 +23,7 @@ They also serve as proof of concept, for the variety of things that can be built
|
|||||||
- [Mermaid Flow Visual Editor](https://www.mermaidflow.app) (**Native support**)
|
- [Mermaid Flow Visual Editor](https://www.mermaidflow.app) (**Native support**)
|
||||||
- [Deepdwn](https://billiam.itch.io/deepdwn) (**Native support**)
|
- [Deepdwn](https://billiam.itch.io/deepdwn) (**Native support**)
|
||||||
- [Joplin](https://joplinapp.org) (**Native support**)
|
- [Joplin](https://joplinapp.org) (**Native support**)
|
||||||
|
- [Slab](https://slab.com) (**Native support**)
|
||||||
- [Swimm](https://swimm.io) (**Native support**)
|
- [Swimm](https://swimm.io) (**Native support**)
|
||||||
- [Notion](https://notion.so) (**Native support**)
|
- [Notion](https://notion.so) (**Native support**)
|
||||||
- [Observable](https://observablehq.com/@observablehq/mermaid) (**Native support**)
|
- [Observable](https://observablehq.com/@observablehq/mermaid) (**Native support**)
|
||||||
|
@ -263,7 +263,7 @@ To Deploy Mermaid:
|
|||||||
|
|
||||||
### [Mermaid API](../config/setup/README.md):
|
### [Mermaid API](../config/setup/README.md):
|
||||||
|
|
||||||
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaid.initialize` call into the HTML like so:**
|
**To deploy mermaid without a bundler, insert a `script` tag with an absolute address and a `mermaid.initialize` call into the HTML using the following example:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@ -272,9 +272,9 @@ To Deploy Mermaid:
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Doing so will command the mermaid parser to look for the `<div>` or `<pre>` tags with `class="mermaid"`. From these tags mermaid will try to read the diagram/chart definitions and render them into SVG charts.**
|
**Doing so commands the mermaid parser to look for the `<div>` or `<pre>` tags with `class="mermaid"`. From these tags, mermaid tries read the diagram/chart definitions and render them into SVG charts.**
|
||||||
|
|
||||||
**Examples can be found at** [Other examples](../syntax/examples.md)
|
**Examples can be found in** [Other examples](../syntax/examples.md)
|
||||||
|
|
||||||
## Sibling projects
|
## Sibling projects
|
||||||
|
|
||||||
|
13
docs/news/announcements.md
Normal file
13
docs/news/announcements.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||||
|
>
|
||||||
|
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/news/announcements.md](../../packages/mermaid/src/docs/news/announcements.md).
|
||||||
|
|
||||||
|
# Announcements
|
||||||
|
|
||||||
|
## [Automatic text wrapping in flowcharts is here!](https://www.mermaidchart.com/blog/posts/automatic-text-wrapping-in-flowcharts-is-here)
|
||||||
|
|
||||||
|
3 April 2023 · 3 mins
|
||||||
|
|
||||||
|
Markdown Strings reduce the hassle # Starting from v10.
|
31
docs/news/blog.md
Normal file
31
docs/news/blog.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||||
|
>
|
||||||
|
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/news/blog.md](../../packages/mermaid/src/docs/news/blog.md).
|
||||||
|
|
||||||
|
# Blog
|
||||||
|
|
||||||
|
## [Mermaid Chart officially launched with sharable diagram links and presentation mode](https://www.mermaidchart.com/blog/posts/mermaid-chart-officially-launched-with-sharable-diagram-links-and-presentation-mode/)
|
||||||
|
|
||||||
|
27 March 2023 · 2 mins
|
||||||
|
|
||||||
|
Exciting news for all Mermaid OSS fans: Mermaid Chart has officially launched with Mermaid Chart!
|
||||||
|
|
||||||
|
## [If you're not excited about ChatGPT, then you're not being creative](https://www.mermaidchart.com/blog/posts/if-youre-not-excited-about-chatgpt-then-youre-not-being-creative-enough/)
|
||||||
|
|
||||||
|
8 March 2023 · 9 mins
|
||||||
|
|
||||||
|
The hype around AI in general and ChatGPT, in particular, is so intense that it’s very understandable to assume the hype train is driving straight toward the trough of disillusionment.
|
||||||
|
|
||||||
|
## [Flow charts are O(n)2 complex, so don't go over 100 connections](https://www.mermaidchart.com/blog/posts/flow-charts-are-on2-complex-so-dont-go-over-100-connections/)
|
||||||
|
|
||||||
|
1 March 2023 · 12 mins
|
||||||
|
|
||||||
|
Flowchart design is a game of balance: Read about the importance of dialling in the right level of detail and how to manage complexity in large flowcharts.
|
||||||
|
|
||||||
|
## [Busting the myth that developers can't write](https://www.mermaidchart.com/blog/posts/busting-the-myth-that-developers-cant-write/)
|
||||||
|
|
||||||
|
10 February 2023 · 10 mins
|
||||||
|
|
||||||
|
Busting the myth that developers can’t write # It’s an annoying stereotype that developers don’t know how to write, speak, and otherwise communicate.
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 12 KiB |
@ -183,8 +183,6 @@ flowchart LR
|
|||||||
|
|
||||||
### A hexagon node
|
### A hexagon node
|
||||||
|
|
||||||
Code:
|
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
flowchart LR
|
flowchart LR
|
||||||
id1{{This is the text in the box}}
|
id1{{This is the text in the box}}
|
||||||
@ -712,6 +710,44 @@ flowchart LR
|
|||||||
B1 --> B2
|
B1 --> B2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Markdown Strings
|
||||||
|
|
||||||
|
The "Markdown Strings" feature enhances flowcharts and mind maps by offering a more versatile string type, which supports text formatting options such as bold and italics, and automatically wraps text within labels.
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
subgraph "One"
|
||||||
|
a("`The **cat**
|
||||||
|
in the hat`") -- "edge label" --> b{{"`The **dog** in the hog`"}}
|
||||||
|
end
|
||||||
|
subgraph "`**Two**`"
|
||||||
|
c("`The **cat**
|
||||||
|
in the hat`") -- "`Bold **edge label**`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
%%{init: {"flowchart": {"htmlLabels": false}} }%%
|
||||||
|
flowchart LR
|
||||||
|
subgraph "One"
|
||||||
|
a("`The **cat**
|
||||||
|
in the hat`") -- "edge label" --> b{{"`The **dog** in the hog`"}}
|
||||||
|
end
|
||||||
|
subgraph "`**Two**`"
|
||||||
|
c("`The **cat**
|
||||||
|
in the hat`") -- "`Bold **edge label**`" --> d("The dog in the hog")
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Formatting:
|
||||||
|
|
||||||
|
- For bold text, use double asterisks \*\* before and after the text.
|
||||||
|
- For italics, use single asterisks \* before and after the text.
|
||||||
|
- With traditional strings, you needed to add <br> tags for text to wrap in nodes. However, markdown strings automatically wrap text when it becomes too long and allows you to start a new line by simply using a newline character instead of a <br> tag.
|
||||||
|
|
||||||
|
This feature is applicable to node labels, edge labels, and subgraph labels.
|
||||||
|
|
||||||
## Interaction
|
## Interaction
|
||||||
|
|
||||||
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
|
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
|
||||||
|
@ -257,9 +257,41 @@ The pattern is:
|
|||||||
|
|
||||||
More info in: <https://github.com/d3/d3-time#interval_every>
|
More info in: <https://github.com/d3/d3-time#interval_every>
|
||||||
|
|
||||||
|
## Output in compact mode
|
||||||
|
|
||||||
|
The compact mode allows you to display multiple tasks in the same row. Compact mode can be enabled for a gantt chart by setting the display mode of the graph via preceeding YAML settings.
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
---
|
||||||
|
displayMode: compact
|
||||||
|
---
|
||||||
|
gantt
|
||||||
|
title A Gantt Diagram
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
|
||||||
|
section Section
|
||||||
|
A task :a1, 2014-01-01, 30d
|
||||||
|
Another task :a2, 2014-01-20, 25d
|
||||||
|
Another one :a3, 2014-02-10, 20d
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
---
|
||||||
|
displayMode: compact
|
||||||
|
---
|
||||||
|
gantt
|
||||||
|
title A Gantt Diagram
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
|
||||||
|
section Section
|
||||||
|
A task :a1, 2014-01-01, 30d
|
||||||
|
Another task :a2, 2014-01-20, 25d
|
||||||
|
Another one :a3, 2014-02-10, 20d
|
||||||
|
```
|
||||||
|
|
||||||
## Comments
|
## Comments
|
||||||
|
|
||||||
Comments can be entered within a gantt chart, which will be ignored by the parser. Comments need to be on their own line and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
Comments can be entered within a gantt chart, which will be ignored by the parser. Comments need to be on their own line and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax.
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
gantt
|
gantt
|
||||||
@ -432,3 +464,41 @@ Beginner's tip—a full example using interactive links in an html context:
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Bar chart (using gantt chart)
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
gantt
|
||||||
|
title Git Issues - days since last update
|
||||||
|
dateFormat X
|
||||||
|
axisFormat %s
|
||||||
|
section Issue19062
|
||||||
|
71 : 0, 71
|
||||||
|
section Issue19401
|
||||||
|
36 : 0, 36
|
||||||
|
section Issue193
|
||||||
|
34 : 0, 34
|
||||||
|
section Issue7441
|
||||||
|
9 : 0, 9
|
||||||
|
section Issue1300
|
||||||
|
5 : 0, 5
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
gantt
|
||||||
|
title Git Issues - days since last update
|
||||||
|
dateFormat X
|
||||||
|
axisFormat %s
|
||||||
|
section Issue19062
|
||||||
|
71 : 0, 71
|
||||||
|
section Issue19401
|
||||||
|
36 : 0, 36
|
||||||
|
section Issue193
|
||||||
|
34 : 0, 34
|
||||||
|
section Issue7441
|
||||||
|
9 : 0, 9
|
||||||
|
section Issue1300
|
||||||
|
5 : 0, 5
|
||||||
|
```
|
||||||
|
@ -224,7 +224,7 @@ mindmap
|
|||||||
C
|
C
|
||||||
```
|
```
|
||||||
|
|
||||||
_These classes needs top be supplied by the site administrator._
|
_These classes need to be supplied by the site administrator._
|
||||||
|
|
||||||
## Unclear indentation
|
## Unclear indentation
|
||||||
|
|
||||||
@ -254,6 +254,34 @@ Root
|
|||||||
C
|
C
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Markdown Strings
|
||||||
|
|
||||||
|
The "Markdown Strings" feature enhances mind maps by offering a more versatile string type, which supports text formatting options such as bold and italics, and automatically wraps text within labels.
|
||||||
|
|
||||||
|
```mermaid-example
|
||||||
|
mindmap
|
||||||
|
id1["`**Root** with
|
||||||
|
a second line
|
||||||
|
Unicode works too: 🤓`"]
|
||||||
|
id2["`The dog in **the** hog... a *very long text* that wraps to a new line`"]
|
||||||
|
id3[Regular labels still works]
|
||||||
|
```
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
mindmap
|
||||||
|
id1["`**Root** with
|
||||||
|
a second line
|
||||||
|
Unicode works too: 🤓`"]
|
||||||
|
id2["`The dog in **the** hog... a *very long text* that wraps to a new line`"]
|
||||||
|
id3[Regular labels still works]
|
||||||
|
```
|
||||||
|
|
||||||
|
Formatting:
|
||||||
|
|
||||||
|
- For bold text, use double asterisks \*\* before and after the text.
|
||||||
|
- For italics, use single asterisks \* before and after the text.
|
||||||
|
- With traditional strings, you needed to add <br> tags for text to wrap in nodes. However, markdown strings automatically wrap text when it becomes too long and allows you to start a new line by simply using a newline character instead of a <br> tag.
|
||||||
|
|
||||||
## Integrating with your library/website.
|
## Integrating with your library/website.
|
||||||
|
|
||||||
Mindmap uses the experimental lazy loading & async rendering features which could change in the future. From version 9.4.0 this diagram is included in mermaid but use lazy loading in order to keep the size of mermaid down. This is important in order to be able to add additional diagrams going forward.
|
Mindmap uses the experimental lazy loading & async rendering features which could change in the future. From version 9.4.0 this diagram is included in mermaid but use lazy loading in order to keep the size of mermaid down. This is important in order to be able to add additional diagrams going forward.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
> Timeline: This is an experimental diagram for now. The syntax and properties can change in future releases. The syntax is stable except for the icon integration which is the experimental part.
|
> Timeline: This is an experimental diagram for now. The syntax and properties can change in future releases. The syntax is stable except for the icon integration which is the experimental part.
|
||||||
|
|
||||||
"A timeline is a type of diagram used to illustrate a chronology of events, dates, or periods of time. It is usually presented graphically to indicate the passing of time, and it is usually organized chronologically. A basic timeline presents a list of events in chronological order, usually using dates as markers. A timeline can also be used to show the relationship between events, such as the relationship between the events of a person's life. A timeline can also be used to show the relationship between events, such as the relationship between the events of a person's life." Wikipedia
|
"A timeline is a type of diagram used to illustrate a chronology of events, dates, or periods of time. It is usually presented graphically to indicate the passing of time, and it is usually organized chronologically. A basic timeline presents a list of events in chronological order, usually using dates as markers. A timeline can also be used to show the relationship between events, such as the relationship between the events of a person's life." Wikipedia
|
||||||
|
|
||||||
### An example of a timeline.
|
### An example of a timeline.
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ However, if there is no section defined, then we have two possibilities:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that this is no, section defined, and each time period and its corresponding events will have its own color scheme.
|
Note that there are no sections defined, and each time period and its corresponding events will have its own color scheme.
|
||||||
|
|
||||||
2. Disable the multiColor option using the `disableMultiColor` option. This will make all time periods and events follow the same color scheme.
|
2. Disable the multiColor option using the `disableMultiColor` option. This will make all time periods and events follow the same color scheme.
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ let us look at same example, where we have disabled the multiColor option.
|
|||||||
|
|
||||||
### Customizing Color scheme
|
### Customizing Color scheme
|
||||||
|
|
||||||
You can customize the color scheme using the `cScale0` to `cScale11` theme variables. Mermaid allows you to set unique colors for up-to 12, where `cScale0` variable will drive the value of the first section or time-period, `cScale1` will drive the value of the second section and so on.
|
You can customize the color scheme using the `cScale0` to `cScale11` theme variables. Mermaid allows you to set unique colors for up-to 12 sections, where `cScale0` variable will drive the value of the first section or time-period, `cScale1` will drive the value of the second section and so on.
|
||||||
In case you have more than 12 sections, the color scheme will start to repeat.
|
In case you have more than 12 sections, the color scheme will start to repeat.
|
||||||
|
|
||||||
NOTE: Default values for these theme variables are picked from the selected theme. If you want to override the default values, you can use the `initialize` call to add your custom theme variable values.
|
NOTE: Default values for these theme variables are picked from the selected theme. If you want to override the default values, you can use the `initialize` call to add your custom theme variable values.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "mermaid-monorepo",
|
"name": "mermaid-monorepo",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "10.0.2",
|
"version": "10.1.0",
|
||||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "pnpm@7.29.0",
|
"packageManager": "pnpm@7.30.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"diagram",
|
"diagram",
|
||||||
"markdown",
|
"markdown",
|
||||||
@ -58,6 +58,7 @@
|
|||||||
"@commitlint/cli": "^17.2.0",
|
"@commitlint/cli": "^17.2.0",
|
||||||
"@commitlint/config-conventional": "^17.2.0",
|
"@commitlint/config-conventional": "^17.2.0",
|
||||||
"@cspell/eslint-plugin": "^6.14.2",
|
"@cspell/eslint-plugin": "^6.14.2",
|
||||||
|
"@rollup/plugin-typescript": "^11.0.0",
|
||||||
"@types/cors": "^2.8.13",
|
"@types/cors": "^2.8.13",
|
||||||
"@types/eslint": "^8.4.10",
|
"@types/eslint": "^8.4.10",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
@ -112,6 +113,6 @@
|
|||||||
"vitest": "^0.29.0"
|
"vitest": "^0.29.0"
|
||||||
},
|
},
|
||||||
"volta": {
|
"volta": {
|
||||||
"node": "18.14.2"
|
"node": "18.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// @ts-ignore: TODO Fix ts errors
|
// @ts-ignore: TODO Fix ts errors
|
||||||
import parser from './parser/exampleDiagram';
|
import parser from './parser/exampleDiagram.jison';
|
||||||
import * as db from './exampleDiagramDb';
|
import * as db from './exampleDiagramDb.js';
|
||||||
import renderer from './exampleDiagramRenderer';
|
import renderer from './exampleDiagramRenderer.js';
|
||||||
import styles from './styles';
|
import styles from './styles.js';
|
||||||
import { injectUtils } from './mermaidUtils';
|
import { injectUtils } from './mermaidUtils.js';
|
||||||
|
|
||||||
export const diagram = {
|
export const diagram = {
|
||||||
db,
|
db,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { parser } from './parser/exampleDiagram';
|
import { parser } from './parser/exampleDiagram.jison';
|
||||||
import * as db from './exampleDiagramDb';
|
import * as db from './exampleDiagramDb.js';
|
||||||
import { injectUtils } from './mermaidUtils';
|
import { injectUtils } from './mermaidUtils.js';
|
||||||
// Todo fix utils functions for tests
|
// Todo fix utils functions for tests
|
||||||
import {
|
import {
|
||||||
log,
|
log,
|
||||||
@ -8,7 +8,7 @@ import {
|
|||||||
getConfig,
|
getConfig,
|
||||||
sanitizeText,
|
sanitizeText,
|
||||||
setupGraphViewBox,
|
setupGraphViewBox,
|
||||||
} from '../../mermaid/src/diagram-api/diagramAPI';
|
} from '../../mermaid/src/diagram-api/diagramAPI.js';
|
||||||
|
|
||||||
injectUtils(log, setLogLevel, getConfig, sanitizeText, setupGraphViewBox);
|
injectUtils(log, setLogLevel, getConfig, sanitizeText, setupGraphViewBox);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** Created by knut on 15-01-14. */
|
/** Created by knut on 15-01-14. */
|
||||||
import { log } from './mermaidUtils';
|
import { log } from './mermaidUtils.js';
|
||||||
|
|
||||||
var message = '';
|
var message = '';
|
||||||
var info = false;
|
var info = false;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** Created by knut on 14-12-11. */
|
/** Created by knut on 14-12-11. */
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log, getConfig, setupGraphViewbox } from './mermaidUtils';
|
import { log, getConfig, setupGraphViewbox } from './mermaidUtils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"module": "esnext",
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"outDir": "./dist"
|
"outDir": "./dist"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mermaid",
|
"name": "mermaid",
|
||||||
"version": "10.0.2",
|
"version": "10.1.0",
|
||||||
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "./dist/mermaid.core.mjs",
|
"module": "./dist/mermaid.core.mjs",
|
||||||
@ -53,11 +53,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^6.0.0",
|
"@braintree/sanitize-url": "^6.0.0",
|
||||||
|
"@khanacademy/simple-markdown": "^0.8.6",
|
||||||
"cytoscape": "^3.23.0",
|
"cytoscape": "^3.23.0",
|
||||||
"cytoscape-cose-bilkent": "^4.1.0",
|
"cytoscape-cose-bilkent": "^4.1.0",
|
||||||
"cytoscape-fcose": "^2.1.0",
|
"cytoscape-fcose": "^2.1.0",
|
||||||
"d3": "^7.4.0",
|
"d3": "^7.4.0",
|
||||||
"dagre-d3-es": "7.0.9",
|
"dagre-d3-es": "7.0.10",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"dompurify": "2.4.5",
|
"dompurify": "2.4.5",
|
||||||
"elkjs": "^0.8.2",
|
"elkjs": "^0.8.2",
|
||||||
@ -74,7 +75,7 @@
|
|||||||
"@types/d3": "^7.4.0",
|
"@types/d3": "^7.4.0",
|
||||||
"@types/dompurify": "^2.4.0",
|
"@types/dompurify": "^2.4.0",
|
||||||
"@types/jsdom": "^21.0.0",
|
"@types/jsdom": "^21.0.0",
|
||||||
"@types/lodash-es": "^4.17.6",
|
"@types/lodash-es": "^4.17.7",
|
||||||
"@types/micromatch": "^4.0.2",
|
"@types/micromatch": "^4.0.2",
|
||||||
"@types/prettier": "^2.7.1",
|
"@types/prettier": "^2.7.1",
|
||||||
"@types/stylis": "^4.0.2",
|
"@types/stylis": "^4.0.2",
|
||||||
@ -86,6 +87,7 @@
|
|||||||
"coveralls": "^3.1.1",
|
"coveralls": "^3.1.1",
|
||||||
"cpy-cli": "^4.2.0",
|
"cpy-cli": "^4.2.0",
|
||||||
"cspell": "^6.14.3",
|
"cspell": "^6.14.3",
|
||||||
|
"csstree-validator": "^3.0.0",
|
||||||
"globby": "^13.1.2",
|
"globby": "^13.1.2",
|
||||||
"jison": "^0.4.18",
|
"jison": "^0.4.18",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import * as configApi from './config';
|
import * as configApi from './config.js';
|
||||||
import { log } from './logger';
|
import { log } from './logger.js';
|
||||||
import { getDiagram, registerDiagram } from './diagram-api/diagramAPI';
|
import { getDiagram, registerDiagram } from './diagram-api/diagramAPI.js';
|
||||||
import { detectType, getDiagramLoader } from './diagram-api/detectType';
|
import { detectType, getDiagramLoader } from './diagram-api/detectType.js';
|
||||||
import { extractFrontMatter } from './diagram-api/frontmatter';
|
import { extractFrontMatter } from './diagram-api/frontmatter.js';
|
||||||
import { UnknownDiagramError } from './errors';
|
import { UnknownDiagramError } from './errors.js';
|
||||||
import { DetailedError } from './utils';
|
import { DetailedError } from './utils.js';
|
||||||
|
import { cleanupComments } from './diagram-api/comments.js';
|
||||||
|
|
||||||
export type ParseErrorFunction = (err: string | DetailedError | unknown, hash?: any) => void;
|
export type ParseErrorFunction = (err: string | DetailedError | unknown, hash?: any) => void;
|
||||||
|
|
||||||
@ -43,7 +44,10 @@ export class Diagram {
|
|||||||
// Similarly, we can't do this in getDiagramFromText() because some code
|
// Similarly, we can't do this in getDiagramFromText() because some code
|
||||||
// calls diagram.db.clear(), which would reset anything set by
|
// calls diagram.db.clear(), which would reset anything set by
|
||||||
// extractFrontMatter().
|
// extractFrontMatter().
|
||||||
this.parser.parse = (text: string) => originalParse(extractFrontMatter(text, this.db));
|
|
||||||
|
this.parser.parse = (text: string) =>
|
||||||
|
originalParse(cleanupComments(extractFrontMatter(text, this.db)));
|
||||||
|
|
||||||
this.parser.parser.yy = this.db;
|
this.parser.parser.yy = this.db;
|
||||||
if (diagram.init) {
|
if (diagram.init) {
|
||||||
diagram.init(cnf);
|
diagram.init(cnf);
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* We can't easily use `vi.spyOn(mermaidAPI, "function")` since the object is frozen with `Object.freeze()`.
|
* We can't easily use `vi.spyOn(mermaidAPI, "function")` since the object is frozen with `Object.freeze()`.
|
||||||
*/
|
*/
|
||||||
import * as configApi from '../config';
|
import * as configApi from '../config.js';
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import { mermaidAPI as mAPI } from '../mermaidAPI';
|
import { mermaidAPI as mAPI } from '../mermaidAPI.js';
|
||||||
|
|
||||||
// original version cannot be modified since it was frozen with `Object.freeze()`
|
// original version cannot be modified since it was frozen with `Object.freeze()`
|
||||||
export const mermaidAPI = {
|
export const mermaidAPI = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { MockedD3 } from './tests/MockedD3';
|
import { MockedD3 } from './tests/MockedD3.js';
|
||||||
import { setA11yDiagramInfo, addSVGa11yTitleDescription } from './accessibility';
|
import { setA11yDiagramInfo, addSVGa11yTitleDescription } from './accessibility.js';
|
||||||
import { D3Element } from './mermaidAPI';
|
import { D3Element } from './mermaidAPI.js';
|
||||||
|
|
||||||
describe('accessibility', () => {
|
describe('accessibility', () => {
|
||||||
const fauxSvgNode = new MockedD3();
|
const fauxSvgNode = new MockedD3();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* @see https://www.w3.org/TR/svg-aam-1.0/
|
* @see https://www.w3.org/TR/svg-aam-1.0/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
import { D3Element } from './mermaidAPI';
|
import { D3Element } from './mermaidAPI.js';
|
||||||
|
|
||||||
import isEmpty from 'lodash-es/isEmpty.js';
|
import isEmpty from 'lodash-es/isEmpty.js';
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { sanitizeText as _sanitizeText } from './diagrams/common/common';
|
import { sanitizeText as _sanitizeText } from './diagrams/common/common.js';
|
||||||
import { getConfig } from './config';
|
import { getConfig } from './config.js';
|
||||||
let title = '';
|
let title = '';
|
||||||
let diagramTitle = '';
|
let diagramTitle = '';
|
||||||
let description = '';
|
let description = '';
|
||||||
|
|
||||||
const sanitizeText = (txt: string): string => _sanitizeText(txt, getConfig());
|
const sanitizeText = (txt: string): string => _sanitizeText(txt, getConfig());
|
||||||
|
|
||||||
export const clear = function (): void {
|
export const clear = function (): void {
|
||||||
@ -36,10 +37,10 @@ export const getDiagramTitle = function (): string {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setAccTitle,
|
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
|
setAccTitle,
|
||||||
|
getDiagramTitle,
|
||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
getDiagramTitle: getDiagramTitle,
|
|
||||||
getAccDescription,
|
getAccDescription,
|
||||||
setAccDescription,
|
setAccDescription,
|
||||||
clear,
|
clear,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as configApi from './config';
|
import * as configApi from './config.js';
|
||||||
|
|
||||||
describe('when working with site config', function () {
|
describe('when working with site config', function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assignWithDepth from './assignWithDepth';
|
import assignWithDepth from './assignWithDepth.js';
|
||||||
import { log } from './logger';
|
import { log } from './logger.js';
|
||||||
import theme from './themes';
|
import theme from './themes/index.js';
|
||||||
import config from './defaultConfig';
|
import config from './defaultConfig.js';
|
||||||
import type { MermaidConfig } from './config.type';
|
import type { MermaidConfig } from './config.type.js';
|
||||||
|
|
||||||
export const defaultConfig: MermaidConfig = Object.freeze(config);
|
export const defaultConfig: MermaidConfig = Object.freeze(config);
|
||||||
|
|
||||||
|
@ -335,6 +335,7 @@ export interface GanttDiagramConfig extends BaseDiagramConfig {
|
|||||||
axisFormat?: string;
|
axisFormat?: string;
|
||||||
tickInterval?: string;
|
tickInterval?: string;
|
||||||
topAxis?: boolean;
|
topAxis?: boolean;
|
||||||
|
displayMode?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SequenceDiagramConfig extends BaseDiagramConfig {
|
export interface SequenceDiagramConfig extends BaseDiagramConfig {
|
||||||
@ -385,6 +386,7 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
|
|||||||
curve?: string;
|
curve?: string;
|
||||||
padding?: number;
|
padding?: number;
|
||||||
defaultRenderer?: string;
|
defaultRenderer?: string;
|
||||||
|
wrappingWidth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FontConfig {
|
export interface FontConfig {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import intersectRect from './intersect/intersect-rect';
|
import intersectRect from './intersect/intersect-rect.js';
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import createLabel from './createLabel';
|
import createLabel from './createLabel.js';
|
||||||
|
import { createText } from '../rendering-util/createText.js';
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config.js';
|
||||||
import { evaluate } from '../diagrams/common/common';
|
import { evaluate } from '../diagrams/common/common.js';
|
||||||
|
|
||||||
const rect = (parent, node) => {
|
const rect = (parent, node) => {
|
||||||
log.trace('Creating subgraph rect for ', node.id, node);
|
log.info('Creating subgraph rect for ', node.id, node);
|
||||||
|
|
||||||
// Add outer g element
|
// Add outer g element
|
||||||
const shapeSvg = parent
|
const shapeSvg = parent
|
||||||
@ -17,12 +18,18 @@ const rect = (parent, node) => {
|
|||||||
// add the rect
|
// add the rect
|
||||||
const rect = shapeSvg.insert('rect', ':first-child');
|
const rect = shapeSvg.insert('rect', ':first-child');
|
||||||
|
|
||||||
|
const useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels);
|
||||||
|
|
||||||
// Create the label and insert it after the rect
|
// Create the label and insert it after the rect
|
||||||
const label = shapeSvg.insert('g').attr('class', 'cluster-label');
|
const label = shapeSvg.insert('g').attr('class', 'cluster-label');
|
||||||
|
|
||||||
const text = label
|
// const text = label
|
||||||
.node()
|
// .node()
|
||||||
.appendChild(createLabel(node.labelText, node.labelStyle, undefined, true));
|
// .appendChild(createLabel(node.labelText, node.labelStyle, undefined, true));
|
||||||
|
const text =
|
||||||
|
node.labelType === 'markdown'
|
||||||
|
? createText(label, node.labelText, { style: node.labelStyle, useHtmlLabels })
|
||||||
|
: label.node().appendChild(createLabel(node.labelText, node.labelStyle, undefined, true));
|
||||||
|
|
||||||
// Get the size of the label
|
// Get the size of the label
|
||||||
let bbox = text.getBBox();
|
let bbox = text.getBBox();
|
||||||
@ -56,13 +63,20 @@ const rect = (parent, node) => {
|
|||||||
.attr('width', width)
|
.attr('width', width)
|
||||||
.attr('height', node.height + padding);
|
.attr('height', node.height + padding);
|
||||||
|
|
||||||
|
if (useHtmlLabels) {
|
||||||
|
label.attr(
|
||||||
|
'transform',
|
||||||
|
// This puts the labal on top of the box instead of inside it
|
||||||
|
'translate(' + (node.x - bbox.width / 2) + ', ' + (node.y - node.height / 2) + ')'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
label.attr(
|
||||||
|
'transform',
|
||||||
|
// This puts the labal on top of the box instead of inside it
|
||||||
|
'translate(' + node.x + ', ' + (node.y - node.height / 2) + ')'
|
||||||
|
);
|
||||||
|
}
|
||||||
// Center the label
|
// Center the label
|
||||||
label.attr(
|
|
||||||
'transform',
|
|
||||||
// This puts the labal on top of the box instead of inside it
|
|
||||||
// 'translate(' + (node.x - bbox.width / 2) + ', ' + (node.y - node.height / 2 - bbox.height) + ')'
|
|
||||||
'translate(' + (node.x - bbox.width / 2) + ', ' + (node.y - node.height / 2) + ')'
|
|
||||||
);
|
|
||||||
|
|
||||||
const rectBox = rect.node().getBBox();
|
const rectBox = rect.node().getBBox();
|
||||||
node.width = rectBox.width;
|
node.width = rectBox.width;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config.js';
|
||||||
import { evaluate } from '../diagrams/common/common';
|
import { evaluate } from '../diagrams/common/common.js';
|
||||||
import { decodeEntities } from '../mermaidAPI';
|
import { decodeEntities } from '../mermaidAPI.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dom
|
* @param dom
|
||||||
@ -41,7 +41,13 @@ function addHtmlLabel(node) {
|
|||||||
div.attr('xmlns', 'http://www.w3.org/1999/xhtml');
|
div.attr('xmlns', 'http://www.w3.org/1999/xhtml');
|
||||||
return fo.node();
|
return fo.node();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @param _vertexText
|
||||||
|
* @param style
|
||||||
|
* @param isTitle
|
||||||
|
* @param isNode
|
||||||
|
* @deprecated svg-util/createText instead
|
||||||
|
*/
|
||||||
const createLabel = (_vertexText, style, isTitle, isNode) => {
|
const createLabel = (_vertexText, style, isTitle, isNode) => {
|
||||||
let vertexText = _vertexText || '';
|
let vertexText = _vertexText || '';
|
||||||
if (typeof vertexText === 'object') {
|
if (typeof vertexText === 'object') {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import createLabel from './createLabel';
|
import createLabel from './createLabel.js';
|
||||||
|
import { createText } from '../rendering-util/createText.js';
|
||||||
import { line, curveBasis, select } from 'd3';
|
import { line, curveBasis, select } from 'd3';
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config.js';
|
||||||
import utils from '../utils';
|
import utils from '../utils.js';
|
||||||
import { evaluate } from '../diagrams/common/common';
|
import { evaluate } from '../diagrams/common/common.js';
|
||||||
|
|
||||||
let edgeLabels = {};
|
let edgeLabels = {};
|
||||||
let terminalLabels = {};
|
let terminalLabels = {};
|
||||||
@ -14,8 +15,17 @@ export const clear = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const insertEdgeLabel = (elem, edge) => {
|
export const insertEdgeLabel = (elem, edge) => {
|
||||||
|
const useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels);
|
||||||
// Create the actual text element
|
// Create the actual text element
|
||||||
const labelElement = createLabel(edge.label, edge.labelStyle);
|
const labelElement =
|
||||||
|
edge.labelType === 'markdown'
|
||||||
|
? createText(elem, edge.label, {
|
||||||
|
style: edge.labelStyle,
|
||||||
|
useHtmlLabels,
|
||||||
|
addSvgBackground: true,
|
||||||
|
})
|
||||||
|
: createLabel(edge.label, edge.labelStyle);
|
||||||
|
log.info('abc82', edge, edge.labelType);
|
||||||
|
|
||||||
// Create outer g, edgeLabel, this will be positioned after graph layout
|
// Create outer g, edgeLabel, this will be positioned after graph layout
|
||||||
const edgeLabel = elem.insert('g').attr('class', 'edgeLabel');
|
const edgeLabel = elem.insert('g').attr('class', 'edgeLabel');
|
||||||
@ -26,7 +36,7 @@ export const insertEdgeLabel = (elem, edge) => {
|
|||||||
|
|
||||||
// Center the label
|
// Center the label
|
||||||
let bbox = labelElement.getBBox();
|
let bbox = labelElement.getBBox();
|
||||||
if (evaluate(getConfig().flowchart.htmlLabels)) {
|
if (useHtmlLabels) {
|
||||||
const div = labelElement.children[0];
|
const div = labelElement.children[0];
|
||||||
const dv = select(labelElement);
|
const dv = select(labelElement);
|
||||||
bbox = div.getBoundingClientRect();
|
bbox = div.getBoundingClientRect();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { intersection } from './edges';
|
import { intersection } from './edges.js';
|
||||||
import { setLogLevel } from '../logger';
|
import { setLogLevel } from '../logger.js';
|
||||||
|
|
||||||
describe('Graphlib decorations', () => {
|
describe('Graphlib decorations', () => {
|
||||||
let node;
|
let node;
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';
|
import { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';
|
||||||
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
|
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
|
||||||
import insertMarkers from './markers';
|
import insertMarkers from './markers.js';
|
||||||
import { updateNodeBounds } from './shapes/util';
|
import { updateNodeBounds } from './shapes/util.js';
|
||||||
import {
|
import {
|
||||||
clear as clearGraphlib,
|
clear as clearGraphlib,
|
||||||
clusterDb,
|
clusterDb,
|
||||||
adjustClustersAndEdges,
|
adjustClustersAndEdges,
|
||||||
findNonClusterChild,
|
findNonClusterChild,
|
||||||
sortNodesByHierarchy,
|
sortNodesByHierarchy,
|
||||||
} from './mermaid-graphlib';
|
} from './mermaid-graphlib.js';
|
||||||
import { insertNode, positionNode, clear as clearNodes, setNodeElem } from './nodes';
|
import { insertNode, positionNode, clear as clearNodes, setNodeElem } from './nodes.js';
|
||||||
import { insertCluster, clear as clearClusters } from './clusters';
|
import { insertCluster, clear as clearClusters } from './clusters.js';
|
||||||
import { insertEdgeLabel, positionEdgeLabel, insertEdge, clear as clearEdges } from './edges';
|
import { insertEdgeLabel, positionEdgeLabel, insertEdge, clear as clearEdges } from './edges.js';
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
|
|
||||||
const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
const recursiveRender = async (_elem, graph, diagramtype, parentCluster) => {
|
||||||
log.info('Graph in recursive render: XXX', graphlibJson.write(graph), parentCluster);
|
log.info('Graph in recursive render: XXX', graphlibJson.write(graph), parentCluster);
|
||||||
const dir = graph.graph().rankdir;
|
const dir = graph.graph().rankdir;
|
||||||
log.trace('Dir in recursive render - dir:', dir);
|
log.trace('Dir in recursive render - dir:', dir);
|
||||||
@ -35,44 +35,46 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
|||||||
|
|
||||||
// Insert nodes, this will insert them into the dom and each node will get a size. The size is updated
|
// Insert nodes, this will insert them into the dom and each node will get a size. The size is updated
|
||||||
// to the abstract node and is later used by dagre for the layout
|
// to the abstract node and is later used by dagre for the layout
|
||||||
graph.nodes().forEach(function (v) {
|
await Promise.all(
|
||||||
const node = graph.node(v);
|
graph.nodes().map(async function (v) {
|
||||||
if (parentCluster !== undefined) {
|
const node = graph.node(v);
|
||||||
const data = JSON.parse(JSON.stringify(parentCluster.clusterData));
|
if (parentCluster !== undefined) {
|
||||||
// data.clusterPositioning = true;
|
const data = JSON.parse(JSON.stringify(parentCluster.clusterData));
|
||||||
log.info('Setting data for cluster XXX (', v, ') ', data, parentCluster);
|
// data.clusterPositioning = true;
|
||||||
graph.setNode(parentCluster.id, data);
|
log.info('Setting data for cluster XXX (', v, ') ', data, parentCluster);
|
||||||
if (!graph.parent(v)) {
|
graph.setNode(parentCluster.id, data);
|
||||||
log.trace('Setting parent', v, parentCluster.id);
|
if (!graph.parent(v)) {
|
||||||
graph.setParent(v, parentCluster.id, data);
|
log.trace('Setting parent', v, parentCluster.id);
|
||||||
|
graph.setParent(v, parentCluster.id, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
log.info('(Insert) Node XXX' + v + ': ' + JSON.stringify(graph.node(v)));
|
||||||
log.info('(Insert) Node XXX' + v + ': ' + JSON.stringify(graph.node(v)));
|
if (node && node.clusterNode) {
|
||||||
if (node && node.clusterNode) {
|
// const children = graph.children(v);
|
||||||
// const children = graph.children(v);
|
log.info('Cluster identified', v, node.width, graph.node(v));
|
||||||
log.info('Cluster identified', v, node.width, graph.node(v));
|
const o = await recursiveRender(nodes, node.graph, diagramtype, graph.node(v));
|
||||||
const o = recursiveRender(nodes, node.graph, diagramtype, graph.node(v));
|
const newEl = o.elem;
|
||||||
const newEl = o.elem;
|
updateNodeBounds(node, newEl);
|
||||||
updateNodeBounds(node, newEl);
|
node.diff = o.diff || 0;
|
||||||
node.diff = o.diff || 0;
|
log.info('Node bounds (abc123)', v, node, node.width, node.x, node.y);
|
||||||
log.info('Node bounds (abc123)', v, node, node.width, node.x, node.y);
|
setNodeElem(newEl, node);
|
||||||
setNodeElem(newEl, node);
|
|
||||||
|
|
||||||
log.warn('Recursive render complete ', newEl, node);
|
log.warn('Recursive render complete ', newEl, node);
|
||||||
} else {
|
|
||||||
if (graph.children(v).length > 0) {
|
|
||||||
// This is a cluster but not to be rendered recursively
|
|
||||||
// Render as before
|
|
||||||
log.info('Cluster - the non recursive path XXX', v, node.id, node, graph);
|
|
||||||
log.info(findNonClusterChild(node.id, graph));
|
|
||||||
clusterDb[node.id] = { id: findNonClusterChild(node.id, graph), node };
|
|
||||||
// insertCluster(clusters, graph.node(v));
|
|
||||||
} else {
|
} else {
|
||||||
log.info('Node - the non recursive path', v, node.id, node);
|
if (graph.children(v).length > 0) {
|
||||||
insertNode(nodes, graph.node(v), dir);
|
// This is a cluster but not to be rendered recursively
|
||||||
|
// Render as before
|
||||||
|
log.info('Cluster - the non recursive path XXX', v, node.id, node, graph);
|
||||||
|
log.info(findNonClusterChild(node.id, graph));
|
||||||
|
clusterDb[node.id] = { id: findNonClusterChild(node.id, graph), node };
|
||||||
|
// insertCluster(clusters, graph.node(v));
|
||||||
|
} else {
|
||||||
|
log.info('Node - the non recursive path', v, node.id, node);
|
||||||
|
await insertNode(nodes, graph.node(v), dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
|
|
||||||
// Insert labels, this will insert them into the dom so that the width can be calculated
|
// Insert labels, this will insert them into the dom so that the width can be calculated
|
||||||
// Also figure out which edges point to/from clusters and adjust them accordingly
|
// Also figure out which edges point to/from clusters and adjust them accordingly
|
||||||
@ -146,7 +148,7 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
|||||||
return { elem, diff };
|
return { elem, diff };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const render = (elem, graph, markers, diagramtype, id) => {
|
export const render = async (elem, graph, markers, diagramtype, id) => {
|
||||||
insertMarkers(elem, markers, diagramtype, id);
|
insertMarkers(elem, markers, diagramtype, id);
|
||||||
clearNodes();
|
clearNodes();
|
||||||
clearEdges();
|
clearEdges();
|
||||||
@ -157,7 +159,7 @@ export const render = (elem, graph, markers, diagramtype, id) => {
|
|||||||
adjustClustersAndEdges(graph);
|
adjustClustersAndEdges(graph);
|
||||||
log.warn('Graph after:', graphlibJson.write(graph));
|
log.warn('Graph after:', graphlibJson.write(graph));
|
||||||
// log.warn('Graph ever after:', graphlibJson.write(graph.node('A').graph));
|
// log.warn('Graph ever after:', graphlibJson.write(graph.node('A').graph));
|
||||||
recursiveRender(elem, graph, diagramtype);
|
await recursiveRender(elem, graph, diagramtype);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const shapeDefinitions = {};
|
// const shapeDefinitions = {};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import intersectEllipse from './intersect-ellipse';
|
import intersectEllipse from './intersect-ellipse.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param node
|
* @param node
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint "no-console": off */
|
/* eslint "no-console": off */
|
||||||
|
|
||||||
import intersectLine from './intersect-line';
|
import intersectLine from './intersect-line.js';
|
||||||
|
|
||||||
export default intersectPolygon;
|
export default intersectPolygon;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
||||||
|
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
|
|
||||||
// Only add the number of markers that the diagram needs
|
// Only add the number of markers that the diagram needs
|
||||||
const insertMarkers = (elem, markerArray, type, id) => {
|
const insertMarkers = (elem, markerArray, type, id) => {
|
||||||
@ -142,7 +142,7 @@ const point = (elem, type) => {
|
|||||||
.append('marker')
|
.append('marker')
|
||||||
.attr('id', type + '-pointEnd')
|
.attr('id', type + '-pointEnd')
|
||||||
.attr('class', 'marker ' + type)
|
.attr('class', 'marker ' + type)
|
||||||
.attr('viewBox', '0 0 12 20')
|
.attr('viewBox', '0 0 10 10')
|
||||||
.attr('refX', 10)
|
.attr('refX', 10)
|
||||||
.attr('refY', 5)
|
.attr('refY', 5)
|
||||||
.attr('markerUnits', 'userSpaceOnUse')
|
.attr('markerUnits', 'userSpaceOnUse')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** Decorates with functions required by mermaids dagre-wrapper. */
|
/** Decorates with functions required by mermaids dagre-wrapper. */
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
|
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
|
||||||
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
|
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import {
|
|||||||
adjustClustersAndEdges,
|
adjustClustersAndEdges,
|
||||||
extractDescendants,
|
extractDescendants,
|
||||||
sortNodesByHierarchy,
|
sortNodesByHierarchy,
|
||||||
} from './mermaid-graphlib';
|
} from './mermaid-graphlib.js';
|
||||||
import { setLogLevel, log } from '../logger';
|
import { setLogLevel, log } from '../logger.js';
|
||||||
|
|
||||||
describe('Graphlib decorations', () => {
|
describe('Graphlib decorations', () => {
|
||||||
let g;
|
let g;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import { labelHelper, updateNodeBounds, insertPolygonShape } from './shapes/util';
|
import { labelHelper, updateNodeBounds, insertPolygonShape } from './shapes/util.js';
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config.js';
|
||||||
import intersect from './intersect/index.js';
|
import intersect from './intersect/index.js';
|
||||||
import createLabel from './createLabel';
|
import createLabel from './createLabel.js';
|
||||||
import note from './shapes/note';
|
import note from './shapes/note.js';
|
||||||
import { parseMember } from '../diagrams/class/svgDraw';
|
import { parseMember } from '../diagrams/class/svgDraw.js';
|
||||||
import { evaluate } from '../diagrams/common/common';
|
import { evaluate } from '../diagrams/common/common.js';
|
||||||
|
|
||||||
const question = (parent, node) => {
|
const question = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -69,8 +69,8 @@ const choice = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const hexagon = (parent, node) => {
|
const hexagon = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const f = 4;
|
const f = 4;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -96,8 +96,8 @@ const hexagon = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const rect_left_inv_arrow = (parent, node) => {
|
const rect_left_inv_arrow = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -122,8 +122,8 @@ const rect_left_inv_arrow = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lean_right = (parent, node) => {
|
const lean_right = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -145,8 +145,8 @@ const lean_right = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lean_left = (parent, node) => {
|
const lean_left = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -168,8 +168,8 @@ const lean_left = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const trapezoid = (parent, node) => {
|
const trapezoid = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -191,8 +191,8 @@ const trapezoid = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const inv_trapezoid = (parent, node) => {
|
const inv_trapezoid = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -214,8 +214,8 @@ const inv_trapezoid = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const rect_right_inv_arrow = (parent, node) => {
|
const rect_right_inv_arrow = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -238,8 +238,8 @@ const rect_right_inv_arrow = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cylinder = (parent, node) => {
|
const cylinder = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const rx = w / 2;
|
const rx = w / 2;
|
||||||
@ -310,13 +310,19 @@ const cylinder = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const rect = (parent, node) => {
|
const rect = async (parent, node) => {
|
||||||
const { shapeSvg, bbox, halfPadding } = labelHelper(parent, node, 'node ' + node.classes, true);
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
|
parent,
|
||||||
|
node,
|
||||||
|
'node ' + node.classes,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
log.trace('Classes = ', node.classes);
|
|
||||||
// add the rect
|
// add the rect
|
||||||
const rect = shapeSvg.insert('rect', ':first-child');
|
const rect = shapeSvg.insert('rect', ':first-child');
|
||||||
|
|
||||||
|
// const totalWidth = bbox.width + node.padding * 2;
|
||||||
|
// const totalHeight = bbox.height + node.padding * 2;
|
||||||
const totalWidth = bbox.width + node.padding;
|
const totalWidth = bbox.width + node.padding;
|
||||||
const totalHeight = bbox.height + node.padding;
|
const totalHeight = bbox.height + node.padding;
|
||||||
rect
|
rect
|
||||||
@ -324,6 +330,8 @@ const rect = (parent, node) => {
|
|||||||
.attr('style', node.style)
|
.attr('style', node.style)
|
||||||
.attr('rx', node.rx)
|
.attr('rx', node.rx)
|
||||||
.attr('ry', node.ry)
|
.attr('ry', node.ry)
|
||||||
|
// .attr('x', -bbox.width / 2 - node.padding)
|
||||||
|
// .attr('y', -bbox.height / 2 - node.padding)
|
||||||
.attr('x', -bbox.width / 2 - halfPadding)
|
.attr('x', -bbox.width / 2 - halfPadding)
|
||||||
.attr('y', -bbox.height / 2 - halfPadding)
|
.attr('y', -bbox.height / 2 - halfPadding)
|
||||||
.attr('width', totalWidth)
|
.attr('width', totalWidth)
|
||||||
@ -349,8 +357,8 @@ const rect = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const labelRect = (parent, node) => {
|
const labelRect = async (parent, node) => {
|
||||||
const { shapeSvg } = labelHelper(parent, node, 'label', true);
|
const { shapeSvg } = await labelHelper(parent, node, 'label', true);
|
||||||
|
|
||||||
log.trace('Classes = ', node.classes);
|
log.trace('Classes = ', node.classes);
|
||||||
// add the rect
|
// add the rect
|
||||||
@ -536,8 +544,8 @@ const rectWithTitle = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const stadium = (parent, node) => {
|
const stadium = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
const w = bbox.width + h / 4 + node.padding;
|
const w = bbox.width + h / 4 + node.padding;
|
||||||
@ -562,8 +570,8 @@ const stadium = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const circle = (parent, node) => {
|
const circle = async (parent, node) => {
|
||||||
const { shapeSvg, bbox, halfPadding } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(parent, node, undefined, true);
|
||||||
const circle = shapeSvg.insert('circle', ':first-child');
|
const circle = shapeSvg.insert('circle', ':first-child');
|
||||||
|
|
||||||
// center the circle around its coordinate
|
// center the circle around its coordinate
|
||||||
@ -587,8 +595,8 @@ const circle = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const doublecircle = (parent, node) => {
|
const doublecircle = async (parent, node) => {
|
||||||
const { shapeSvg, bbox, halfPadding } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(parent, node, undefined, true);
|
||||||
const gap = 5;
|
const gap = 5;
|
||||||
const circleGroup = shapeSvg.insert('g', ':first-child');
|
const circleGroup = shapeSvg.insert('g', ':first-child');
|
||||||
const outerCircle = circleGroup.insert('circle');
|
const outerCircle = circleGroup.insert('circle');
|
||||||
@ -623,8 +631,8 @@ const doublecircle = (parent, node) => {
|
|||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
const subroutine = (parent, node) => {
|
const subroutine = async (parent, node) => {
|
||||||
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
|
const { shapeSvg, bbox } = await labelHelper(parent, node, undefined, true);
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@ -973,7 +981,7 @@ const shapes = {
|
|||||||
|
|
||||||
let nodeElems = {};
|
let nodeElems = {};
|
||||||
|
|
||||||
export const insertNode = (elem, node, dir) => {
|
export const insertNode = async (elem, node, dir) => {
|
||||||
let newEl;
|
let newEl;
|
||||||
let el;
|
let el;
|
||||||
|
|
||||||
@ -986,9 +994,9 @@ export const insertNode = (elem, node, dir) => {
|
|||||||
target = node.linkTarget || '_blank';
|
target = node.linkTarget || '_blank';
|
||||||
}
|
}
|
||||||
newEl = elem.insert('svg:a').attr('xlink:href', node.link).attr('target', target);
|
newEl = elem.insert('svg:a').attr('xlink:href', node.link).attr('target', target);
|
||||||
el = shapes[node.shape](newEl, node, dir);
|
el = await shapes[node.shape](newEl, node, dir);
|
||||||
} else {
|
} else {
|
||||||
el = shapes[node.shape](elem, node, dir);
|
el = await shapes[node.shape](elem, node, dir);
|
||||||
newEl = el;
|
newEl = el;
|
||||||
}
|
}
|
||||||
if (node.tooltip) {
|
if (node.tooltip) {
|
||||||
@ -1014,6 +1022,7 @@ export const clear = () => {
|
|||||||
|
|
||||||
export const positionNode = (node) => {
|
export const positionNode = (node) => {
|
||||||
const el = nodeElems[node.id];
|
const el = nodeElems[node.id];
|
||||||
|
|
||||||
log.trace(
|
log.trace(
|
||||||
'Transforming node',
|
'Transforming node',
|
||||||
node.diff,
|
node.diff,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
||||||
|
|
||||||
// import { log } from '../logger';
|
// import { log } from '../logger.js';
|
||||||
|
|
||||||
// Only add the number of markers that the diagram needs
|
// Only add the number of markers that the diagram needs
|
||||||
const insertPatterns = (elem, patternArray, type, id) => {
|
const insertPatterns = (elem, patternArray, type, id) => {
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
import { updateNodeBounds, labelHelper } from './util';
|
import { updateNodeBounds, labelHelper } from './util.js';
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger.js';
|
||||||
|
import { getConfig } from '../../config.js';
|
||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
|
|
||||||
const note = (parent, node) => {
|
const note = async (parent, node) => {
|
||||||
const { shapeSvg, bbox, halfPadding } = labelHelper(parent, node, 'node ' + node.classes, true);
|
const useHtmlLabels = node.useHtmlLabels || getConfig().flowchart.htmlLabels;
|
||||||
|
if (!useHtmlLabels) {
|
||||||
|
node.centerLabel = true;
|
||||||
|
}
|
||||||
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
|
parent,
|
||||||
|
node,
|
||||||
|
'node ' + node.classes,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
log.info('Classes = ', node.classes);
|
log.info('Classes = ', node.classes);
|
||||||
// add the rect
|
// add the rect
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
import createLabel from '../createLabel';
|
import createLabel from '../createLabel.js';
|
||||||
import { getConfig } from '../../config';
|
import { createText } from '../../rendering-util/createText.js';
|
||||||
import { decodeEntities } from '../../mermaidAPI';
|
import { getConfig } from '../../config.js';
|
||||||
|
import { decodeEntities } from '../../mermaidAPI.js';
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { evaluate, sanitizeText } from '../../diagrams/common/common';
|
import { evaluate, sanitizeText } from '../../diagrams/common/common.js';
|
||||||
export const labelHelper = (parent, node, _classes, isNode) => {
|
|
||||||
|
export const labelHelper = async (parent, node, _classes, isNode) => {
|
||||||
let classes;
|
let classes;
|
||||||
|
const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig().flowchart.htmlLabels);
|
||||||
if (!_classes) {
|
if (!_classes) {
|
||||||
classes = 'node default';
|
classes = 'node default';
|
||||||
} else {
|
} else {
|
||||||
@ -27,9 +30,17 @@ export const labelHelper = (parent, node, _classes, isNode) => {
|
|||||||
labelText = typeof node.labelText === 'string' ? node.labelText : node.labelText[0];
|
labelText = typeof node.labelText === 'string' ? node.labelText : node.labelText[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = label
|
const textNode = label.node();
|
||||||
.node()
|
let text;
|
||||||
.appendChild(
|
if (node.labelType === 'markdown') {
|
||||||
|
// text = textNode;
|
||||||
|
text = createText(label, sanitizeText(decodeEntities(labelText), getConfig()), {
|
||||||
|
useHtmlLabels,
|
||||||
|
width: node.width || getConfig().flowchart.wrappingWidth,
|
||||||
|
classes: 'markdown-node-label',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
text = textNode.appendChild(
|
||||||
createLabel(
|
createLabel(
|
||||||
sanitizeText(decodeEntities(labelText), getConfig()),
|
sanitizeText(decodeEntities(labelText), getConfig()),
|
||||||
node.labelStyle,
|
node.labelStyle,
|
||||||
@ -37,23 +48,61 @@ export const labelHelper = (parent, node, _classes, isNode) => {
|
|||||||
isNode
|
isNode
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the size of the label
|
// Get the size of the label
|
||||||
let bbox = text.getBBox();
|
let bbox = text.getBBox();
|
||||||
|
const halfPadding = node.padding / 2;
|
||||||
|
|
||||||
if (evaluate(getConfig().flowchart.htmlLabels)) {
|
if (evaluate(getConfig().flowchart.htmlLabels)) {
|
||||||
const div = text.children[0];
|
const div = text.children[0];
|
||||||
const dv = select(text);
|
const dv = select(text);
|
||||||
|
|
||||||
|
// if there are images, need to wait for them to load before getting the bounding box
|
||||||
|
const images = div.getElementsByTagName('img');
|
||||||
|
if (images) {
|
||||||
|
const noImgText = labelText.replace(/<img[^>]*>/g, '').trim() === '';
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
[...images].map(
|
||||||
|
(img) =>
|
||||||
|
new Promise((res) =>
|
||||||
|
img.addEventListener('load', function () {
|
||||||
|
img.style.display = 'flex';
|
||||||
|
img.style.flexDirection = 'column';
|
||||||
|
|
||||||
|
if (noImgText) {
|
||||||
|
// default size if no text
|
||||||
|
const bodyFontSize = getConfig().fontSize
|
||||||
|
? getConfig().fontSize
|
||||||
|
: window.getComputedStyle(document.body).fontSize;
|
||||||
|
const enlargingFactor = 5;
|
||||||
|
img.style.width = parseInt(bodyFontSize, 10) * enlargingFactor + 'px';
|
||||||
|
} else {
|
||||||
|
img.style.width = '100%';
|
||||||
|
}
|
||||||
|
res(img);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bbox = div.getBoundingClientRect();
|
bbox = div.getBoundingClientRect();
|
||||||
dv.attr('width', bbox.width);
|
dv.attr('width', bbox.width);
|
||||||
dv.attr('height', bbox.height);
|
dv.attr('height', bbox.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const halfPadding = node.padding / 2;
|
|
||||||
|
|
||||||
// Center the label
|
// Center the label
|
||||||
label.attr('transform', 'translate(' + -bbox.width / 2 + ', ' + -bbox.height / 2 + ')');
|
if (useHtmlLabels) {
|
||||||
|
label.attr('transform', 'translate(' + -bbox.width / 2 + ', ' + -bbox.height / 2 + ')');
|
||||||
|
} else {
|
||||||
|
label.attr('transform', 'translate(' + 0 + ', ' + -bbox.height / 2 + ')');
|
||||||
|
}
|
||||||
|
if (node.centerLabel) {
|
||||||
|
label.attr('transform', 'translate(' + -bbox.width / 2 + ', ' + -bbox.height / 2 + ')');
|
||||||
|
}
|
||||||
|
label.insert('rect', ':first-child');
|
||||||
return { shapeSvg, bbox, halfPadding, label };
|
return { shapeSvg, bbox, halfPadding, label };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import theme from './themes';
|
import theme from './themes/index.js';
|
||||||
import { MermaidConfig } from './config.type';
|
import { MermaidConfig } from './config.type.js';
|
||||||
/**
|
/**
|
||||||
* **Configuration methods in Mermaid version 8.6.0 have been updated, to learn more[[click
|
* **Configuration methods in Mermaid version 8.6.0 have been updated, to learn more[[click
|
||||||
* here](8.6.0_docs.md)].**
|
* here](8.6.0_docs.md)].**
|
||||||
@ -258,6 +258,18 @@ const config: Partial<MermaidConfig> = {
|
|||||||
* Default value: 'dagre-wrapper'
|
* Default value: 'dagre-wrapper'
|
||||||
*/
|
*/
|
||||||
defaultRenderer: 'dagre-wrapper',
|
defaultRenderer: 'dagre-wrapper',
|
||||||
|
/**
|
||||||
|
* | Parameter | Description | Type | Required | Values |
|
||||||
|
* | --------------- | ----------- | ------- | -------- | ----------------------- |
|
||||||
|
* | wrappingWidth | See notes | number | 4 | width of nodes where text is wrapped |
|
||||||
|
*
|
||||||
|
* **Notes:**
|
||||||
|
*
|
||||||
|
* When using markdown strings the text ius wrapped automatically, this
|
||||||
|
* value sets the max width of a text before it continues on a new line.
|
||||||
|
* Default value: 'dagre-wrapper'
|
||||||
|
*/
|
||||||
|
wrappingWidth: 200,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** The object containing configurations specific for sequence diagrams */
|
/** The object containing configurations specific for sequence diagrams */
|
||||||
@ -659,6 +671,17 @@ const config: Partial<MermaidConfig> = {
|
|||||||
*/
|
*/
|
||||||
numberSectionStyles: 4,
|
numberSectionStyles: 4,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* | Parameter | Description | Type | Required | Values |
|
||||||
|
* | ----------- | ------------------------- | ------ | -------- | --------- |
|
||||||
|
* | displayMode | Controls the display mode | string | 4 | 'compact' |
|
||||||
|
*
|
||||||
|
* **Notes**:
|
||||||
|
*
|
||||||
|
* - **compact**: Enables displaying multiple tasks on the same row.
|
||||||
|
*/
|
||||||
|
displayMode: '',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* | Parameter | Description | Type | Required | Values |
|
* | Parameter | Description | Type | Required | Values |
|
||||||
* | ---------- | ---------------------------- | ---- | -------- | ---------------- |
|
* | ---------- | ---------------------------- | ---- | -------- | ---------------- |
|
||||||
@ -684,7 +707,6 @@ const config: Partial<MermaidConfig> = {
|
|||||||
* Default value: undefined
|
* Default value: undefined
|
||||||
*/
|
*/
|
||||||
tickInterval: undefined,
|
tickInterval: undefined,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* | Parameter | Description | Type | Required | Values |
|
* | Parameter | Description | Type | Required | Values |
|
||||||
* | ----------- | ----------- | ------- | -------- | ----------- |
|
* | ----------- | ----------- | ------- | -------- | ----------- |
|
||||||
|
94
packages/mermaid/src/diagram-api/comments.spec.ts
Normal file
94
packages/mermaid/src/diagram-api/comments.spec.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// tests to check that comments are removed
|
||||||
|
|
||||||
|
import { cleanupComments } from './comments.js';
|
||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
|
||||||
|
describe('comments', () => {
|
||||||
|
it('should remove comments', () => {
|
||||||
|
const text = `
|
||||||
|
|
||||||
|
%% This is a comment
|
||||||
|
%% This is another comment
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
%% This is a comment
|
||||||
|
`;
|
||||||
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
|
"graph TD
|
||||||
|
A-->B
|
||||||
|
"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should keep init statements when removing comments', () => {
|
||||||
|
const text = `
|
||||||
|
%% This is a comment
|
||||||
|
|
||||||
|
%% This is another comment
|
||||||
|
%%{init: {'theme': 'forest'}}%%
|
||||||
|
%%{ init: {'theme': 'space before init'}}%%
|
||||||
|
%%{init: {'theme': 'space after ending'}}%%
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
|
||||||
|
B-->C
|
||||||
|
%% This is a comment
|
||||||
|
`;
|
||||||
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
|
"%%{init: {'theme': 'forest'}}%%
|
||||||
|
%%{ init: {'theme': 'space before init'}}%%
|
||||||
|
%%{init: {'theme': 'space after ending'}}%%
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
|
||||||
|
B-->C
|
||||||
|
"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove indented comments', () => {
|
||||||
|
const text = `
|
||||||
|
%% This is a comment
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
%% This is a comment
|
||||||
|
C-->D
|
||||||
|
`;
|
||||||
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
|
"graph TD
|
||||||
|
A-->B
|
||||||
|
C-->D
|
||||||
|
"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove empty newlines from start', () => {
|
||||||
|
const text = `
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%% This is a comment
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
`;
|
||||||
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
|
"graph TD
|
||||||
|
A-->B
|
||||||
|
"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove comments at end of text with no newline', () => {
|
||||||
|
const text = `
|
||||||
|
graph TD
|
||||||
|
A-->B
|
||||||
|
%% This is a comment`;
|
||||||
|
|
||||||
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
|
"graph TD
|
||||||
|
A-->B
|
||||||
|
"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
});
|
8
packages/mermaid/src/diagram-api/comments.ts
Normal file
8
packages/mermaid/src/diagram-api/comments.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Remove all lines starting with `%%` from the text that don't contain a `%%{`
|
||||||
|
* @param text - The text to remove comments from
|
||||||
|
* @returns cleaned text
|
||||||
|
*/
|
||||||
|
export const cleanupComments = (text: string): string => {
|
||||||
|
return text.trimStart().replace(/^\s*%%(?!{)[^\n]+\n?/gm, '');
|
||||||
|
};
|
@ -1,14 +1,14 @@
|
|||||||
import { MermaidConfig } from '../config.type';
|
import { MermaidConfig } from '../config.type.js';
|
||||||
import { log } from '../logger';
|
import { log } from '../logger.js';
|
||||||
import type {
|
import type {
|
||||||
DetectorRecord,
|
DetectorRecord,
|
||||||
DiagramDetector,
|
DiagramDetector,
|
||||||
DiagramLoader,
|
DiagramLoader,
|
||||||
ExternalDiagramDefinition,
|
ExternalDiagramDefinition,
|
||||||
} from './types';
|
} from './types.js';
|
||||||
import { frontMatterRegex } from './frontmatter';
|
import { frontMatterRegex } from './frontmatter.js';
|
||||||
import { getDiagram, registerDiagram } from './diagramAPI';
|
import { getDiagram, registerDiagram } from './diagramAPI.js';
|
||||||
import { UnknownDiagramError } from '../errors';
|
import { UnknownDiagramError } from '../errors.js';
|
||||||
|
|
||||||
const directive = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi;
|
const directive = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi;
|
||||||
const anyComment = /\s*%%.*\n/gm;
|
const anyComment = /\s*%%.*\n/gm;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { it, describe, expect } from 'vitest';
|
import { it, describe, expect } from 'vitest';
|
||||||
import { detectType } from './detectType';
|
import { detectType } from './detectType.js';
|
||||||
import { addDiagrams } from './diagram-orchestration';
|
import { addDiagrams } from './diagram-orchestration.js';
|
||||||
|
|
||||||
describe('diagram-orchestration', () => {
|
describe('diagram-orchestration', () => {
|
||||||
it('should register diagrams', () => {
|
it('should register diagrams', () => {
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import c4 from '../diagrams/c4/c4Detector';
|
import c4 from '../diagrams/c4/c4Detector.js';
|
||||||
import flowchart from '../diagrams/flowchart/flowDetector';
|
import flowchart from '../diagrams/flowchart/flowDetector.js';
|
||||||
import flowchartV2 from '../diagrams/flowchart/flowDetector-v2';
|
import flowchartV2 from '../diagrams/flowchart/flowDetector-v2.js';
|
||||||
import er from '../diagrams/er/erDetector';
|
import er from '../diagrams/er/erDetector.js';
|
||||||
import git from '../diagrams/git/gitGraphDetector';
|
import git from '../diagrams/git/gitGraphDetector.js';
|
||||||
import gantt from '../diagrams/gantt/ganttDetector';
|
import gantt from '../diagrams/gantt/ganttDetector.js';
|
||||||
import info from '../diagrams/info/infoDetector';
|
import info from '../diagrams/info/infoDetector.js';
|
||||||
import pie from '../diagrams/pie/pieDetector';
|
import pie from '../diagrams/pie/pieDetector.js';
|
||||||
import requirement from '../diagrams/requirement/requirementDetector';
|
import requirement from '../diagrams/requirement/requirementDetector.js';
|
||||||
import sequence from '../diagrams/sequence/sequenceDetector';
|
import sequence from '../diagrams/sequence/sequenceDetector.js';
|
||||||
import classDiagram from '../diagrams/class/classDetector';
|
import classDiagram from '../diagrams/class/classDetector.js';
|
||||||
import classDiagramV2 from '../diagrams/class/classDetector-V2';
|
import classDiagramV2 from '../diagrams/class/classDetector-V2.js';
|
||||||
import state from '../diagrams/state/stateDetector';
|
import state from '../diagrams/state/stateDetector.js';
|
||||||
import stateV2 from '../diagrams/state/stateDetector-V2';
|
import stateV2 from '../diagrams/state/stateDetector-V2.js';
|
||||||
import journey from '../diagrams/user-journey/journeyDetector';
|
import journey from '../diagrams/user-journey/journeyDetector.js';
|
||||||
import error from '../diagrams/error/errorDetector';
|
import errorDiagram from '../diagrams/error/errorDiagram.js';
|
||||||
import flowchartElk from '../diagrams/flowchart/elk/detector';
|
import flowchartElk from '../diagrams/flowchart/elk/detector.js';
|
||||||
import timeline from '../diagrams/timeline/detector';
|
import timeline from '../diagrams/timeline/detector.js';
|
||||||
import mindmap from '../diagrams/mindmap/detector';
|
import mindmap from '../diagrams/mindmap/detector.js';
|
||||||
import { registerLazyLoadedDiagrams } from './detectType';
|
import { registerLazyLoadedDiagrams } from './detectType.js';
|
||||||
import { registerDiagram } from './diagramAPI';
|
import { registerDiagram } from './diagramAPI.js';
|
||||||
|
|
||||||
let hasLoadedDiagrams = false;
|
let hasLoadedDiagrams = false;
|
||||||
export const addDiagrams = () => {
|
export const addDiagrams = () => {
|
||||||
@ -28,6 +28,9 @@ export const addDiagrams = () => {
|
|||||||
// This is added here to avoid race-conditions.
|
// This is added here to avoid race-conditions.
|
||||||
// We could optimize the loading logic somehow.
|
// We could optimize the loading logic somehow.
|
||||||
hasLoadedDiagrams = true;
|
hasLoadedDiagrams = true;
|
||||||
|
registerDiagram('error', errorDiagram, (text) => {
|
||||||
|
return text.toLowerCase().trim() === 'error';
|
||||||
|
});
|
||||||
registerDiagram(
|
registerDiagram(
|
||||||
'---',
|
'---',
|
||||||
// --- diagram type may appear if YAML front-matter is not parsed correctly
|
// --- diagram type may appear if YAML front-matter is not parsed correctly
|
||||||
@ -57,7 +60,6 @@ export const addDiagrams = () => {
|
|||||||
);
|
);
|
||||||
// Ordering of detectors is important. The first one to return true will be used.
|
// Ordering of detectors is important. The first one to return true will be used.
|
||||||
registerLazyLoadedDiagrams(
|
registerLazyLoadedDiagrams(
|
||||||
error,
|
|
||||||
c4,
|
c4,
|
||||||
classDiagramV2,
|
classDiagramV2,
|
||||||
classDiagram,
|
classDiagram,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { detectType } from './detectType';
|
import { detectType } from './detectType.js';
|
||||||
import { getDiagram, registerDiagram } from './diagramAPI';
|
import { getDiagram, registerDiagram } from './diagramAPI.js';
|
||||||
import { addDiagrams } from './diagram-orchestration';
|
import { addDiagrams } from './diagram-orchestration.js';
|
||||||
import { DiagramDetector } from './types';
|
import { DiagramDetector } from './types.js';
|
||||||
import { getDiagramFromText } from '../Diagram';
|
import { getDiagramFromText } from '../Diagram.js';
|
||||||
import { it, describe, expect, beforeAll } from 'vitest';
|
import { it, describe, expect, beforeAll } from 'vitest';
|
||||||
|
|
||||||
addDiagrams();
|
addDiagrams();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { addDetector } from './detectType';
|
import { addDetector } from './detectType.js';
|
||||||
import { log as _log, setLogLevel as _setLogLevel } from '../logger';
|
import { log as _log, setLogLevel as _setLogLevel } from '../logger.js';
|
||||||
import { getConfig as _getConfig } from '../config';
|
import { getConfig as _getConfig } from '../config.js';
|
||||||
import { sanitizeText as _sanitizeText } from '../diagrams/common/common';
|
import { sanitizeText as _sanitizeText } from '../diagrams/common/common.js';
|
||||||
import { setupGraphViewbox as _setupGraphViewbox } from '../setupGraphViewbox';
|
import { setupGraphViewbox as _setupGraphViewbox } from '../setupGraphViewbox.js';
|
||||||
import { addStylesForDiagram } from '../styles';
|
import { addStylesForDiagram } from '../styles.js';
|
||||||
import { DiagramDefinition, DiagramDetector } from './types';
|
import { DiagramDefinition, DiagramDetector } from './types.js';
|
||||||
import * as _commonDb from '../commonDb';
|
import * as _commonDb from '../commonDb.js';
|
||||||
import { parseDirective as _parseDirective } from '../directiveUtils';
|
import { parseDirective as _parseDirective } from '../directiveUtils.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Packaging and exposing resources for external diagrams so that they can import
|
Packaging and exposing resources for external diagrams so that they can import
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import { extractFrontMatter } from './frontmatter';
|
import { extractFrontMatter } from './frontmatter.js';
|
||||||
|
|
||||||
const dbMock = () => ({ setDiagramTitle: vi.fn() });
|
const dbMock = () => ({ setDiagramTitle: vi.fn() });
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DiagramDb } from './types';
|
import { DiagramDb } from './types.js';
|
||||||
// The "* as yaml" part is necessary for tree-shaking
|
// The "* as yaml" part is necessary for tree-shaking
|
||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
|
|
||||||
@ -11,6 +11,8 @@ export const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s;
|
|||||||
|
|
||||||
type FrontMatterMetadata = {
|
type FrontMatterMetadata = {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
// Allows custom display modes. Currently used for compact mode in gantt charts.
|
||||||
|
displayMode?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +35,10 @@ export function extractFrontMatter(text: string, db: DiagramDb): string {
|
|||||||
db.setDiagramTitle?.(parsed.title);
|
db.setDiagramTitle?.(parsed.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parsed?.displayMode) {
|
||||||
|
db.setDisplayMode?.(parsed.displayMode);
|
||||||
|
}
|
||||||
|
|
||||||
return text.slice(matches[0].length);
|
return text.slice(matches[0].length);
|
||||||
} else {
|
} else {
|
||||||
return text;
|
return text;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { MermaidConfig } from '../config.type';
|
import { MermaidConfig } from '../config.type.js';
|
||||||
|
|
||||||
export interface InjectUtils {
|
export interface InjectUtils {
|
||||||
_log: any;
|
_log: any;
|
||||||
@ -16,6 +16,7 @@ export interface InjectUtils {
|
|||||||
export interface DiagramDb {
|
export interface DiagramDb {
|
||||||
clear?: () => void;
|
clear?: () => void;
|
||||||
setDiagramTitle?: (title: string) => void;
|
setDiagramTitle?: (title: string) => void;
|
||||||
|
setDisplayMode?: (title: string) => void;
|
||||||
getAccTitle?: () => string;
|
getAccTitle?: () => string;
|
||||||
getAccDescription?: () => string;
|
getAccDescription?: () => string;
|
||||||
bindFunctions?: (element: Element) => void;
|
bindFunctions?: (element: Element) => void;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { describe, test, expect } from 'vitest';
|
import { describe, test, expect } from 'vitest';
|
||||||
import { Diagram, getDiagramFromText } from './Diagram';
|
import { Diagram, getDiagramFromText } from './Diagram.js';
|
||||||
import { addDetector } from './diagram-api/detectType';
|
import { addDetector } from './diagram-api/detectType.js';
|
||||||
import { addDiagrams } from './diagram-api/diagram-orchestration';
|
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
|
||||||
|
|
||||||
addDiagrams();
|
addDiagrams();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import mermaidAPI from '../../mermaidAPI';
|
import mermaidAPI from '../../mermaidAPI.js';
|
||||||
import * as configApi from '../../config';
|
import * as configApi from '../../config.js';
|
||||||
import { sanitizeText } from '../common/common';
|
import { sanitizeText } from '../common/common.js';
|
||||||
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb';
|
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb.js';
|
||||||
|
|
||||||
let c4ShapeArray = [];
|
let c4ShapeArray = [];
|
||||||
let boundaryParseStack = [''];
|
let boundaryParseStack = [''];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ExternalDiagramDefinition } from '../../diagram-api/types';
|
import type { ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
const id = 'c4';
|
const id = 'c4';
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ const detector = (txt: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
const { diagram } = await import('./c4Diagram');
|
const { diagram } = await import('./c4Diagram.js');
|
||||||
return { id, diagram };
|
return { id, diagram };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// @ts-ignore: TODO Fix ts errors
|
// @ts-ignore: TODO Fix ts errors
|
||||||
import c4Parser from './parser/c4Diagram';
|
import c4Parser from './parser/c4Diagram.jison';
|
||||||
import c4Db from './c4Db';
|
import c4Db from './c4Db.js';
|
||||||
import c4Renderer from './c4Renderer';
|
import c4Renderer from './c4Renderer.js';
|
||||||
import c4Styles from './styles';
|
import c4Styles from './styles.js';
|
||||||
import { MermaidConfig } from '../../config.type';
|
import { MermaidConfig } from '../../config.type.js';
|
||||||
import { DiagramDefinition } from '../../diagram-api/types';
|
import { DiagramDefinition } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
export const diagram: DiagramDefinition = {
|
export const diagram: DiagramDefinition = {
|
||||||
parser: c4Parser,
|
parser: c4Parser,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import svgDraw from './svgDraw';
|
import svgDraw from './svgDraw.js';
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger.js';
|
||||||
import { parser } from './parser/c4Diagram';
|
import { parser } from './parser/c4Diagram.jison';
|
||||||
import common from '../common/common';
|
import common from '../common/common.js';
|
||||||
import c4Db from './c4Db';
|
import c4Db from './c4Db.js';
|
||||||
import * as configApi from '../../config';
|
import * as configApi from '../../config.js';
|
||||||
import assignWithDepth from '../../assignWithDepth';
|
import assignWithDepth from '../../assignWithDepth.js';
|
||||||
import { wrapLabel, calculateTextWidth, calculateTextHeight } from '../../utils';
|
import { wrapLabel, calculateTextWidth, calculateTextHeight } from '../../utils.js';
|
||||||
import { configureSvgSize } from '../../setupGraphViewbox';
|
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||||
|
|
||||||
let globalBoundaryMaxX = 0,
|
let globalBoundaryMaxX = 0,
|
||||||
globalBoundaryMaxY = 0;
|
globalBoundaryMaxY = 0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import c4Db from '../c4Db';
|
import c4Db from '../c4Db.js';
|
||||||
import c4 from './c4Diagram.jison';
|
import c4 from './c4Diagram.jison';
|
||||||
import { setConfig } from '../../../config';
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import c4Db from '../c4Db';
|
import c4Db from '../c4Db.js';
|
||||||
import c4 from './c4Diagram.jison';
|
import c4 from './c4Diagram.jison';
|
||||||
import { setConfig } from '../../../config';
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import c4Db from '../c4Db';
|
import c4Db from '../c4Db.js';
|
||||||
import c4 from './c4Diagram.jison';
|
import c4 from './c4Diagram.jison';
|
||||||
import { setConfig } from '../../../config';
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import c4Db from '../c4Db';
|
import c4Db from '../c4Db.js';
|
||||||
import c4 from './c4Diagram.jison';
|
import c4 from './c4Diagram.jison';
|
||||||
import { setConfig } from '../../../config';
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import c4Db from '../c4Db';
|
import c4Db from '../c4Db.js';
|
||||||
import c4 from './c4Diagram.jison';
|
import c4 from './c4Diagram.jison';
|
||||||
import { setConfig } from '../../../config';
|
import { setConfig } from '../../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import common from '../common/common';
|
import common from '../common/common.js';
|
||||||
import { sanitizeUrl } from '@braintree/sanitize-url';
|
import { sanitizeUrl } from '@braintree/sanitize-url';
|
||||||
|
|
||||||
export const drawRect = function (elem, rectData) {
|
export const drawRect = function (elem, rectData) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// @ts-expect-error - d3 types issue
|
// @ts-expect-error - d3 types issue
|
||||||
import { select, Selection } from 'd3';
|
import { select, Selection } from 'd3';
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger.js';
|
||||||
import * as configApi from '../../config';
|
import * as configApi from '../../config.js';
|
||||||
import common from '../common/common';
|
import common from '../common/common.js';
|
||||||
import utils from '../../utils';
|
import utils from '../../utils.js';
|
||||||
import mermaidAPI from '../../mermaidAPI';
|
import mermaidAPI from '../../mermaidAPI.js';
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
@ -13,7 +13,7 @@ import {
|
|||||||
clear as commonClear,
|
clear as commonClear,
|
||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
getDiagramTitle,
|
getDiagramTitle,
|
||||||
} from '../../commonDb';
|
} from '../../commonDb.js';
|
||||||
import {
|
import {
|
||||||
ClassRelation,
|
ClassRelation,
|
||||||
ClassNode,
|
ClassNode,
|
||||||
@ -21,7 +21,7 @@ import {
|
|||||||
ClassMap,
|
ClassMap,
|
||||||
NamespaceMap,
|
NamespaceMap,
|
||||||
NamespaceNode,
|
NamespaceNode,
|
||||||
} from './classTypes';
|
} from './classTypes.js';
|
||||||
|
|
||||||
const MERMAID_DOM_ID_PREFIX = 'classId-';
|
const MERMAID_DOM_ID_PREFIX = 'classId-';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types';
|
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
const id = 'classDiagram';
|
const id = 'classDiagram';
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ const detector: DiagramDetector = (txt, config) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
const { diagram } = await import('./classDiagram-v2');
|
const { diagram } = await import('./classDiagram-v2.js');
|
||||||
return { id, diagram };
|
return { id, diagram };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types';
|
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
||||||
|
|
||||||
const id = 'class';
|
const id = 'class';
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ const detector: DiagramDetector = (txt, config) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
const { diagram } = await import('./classDiagram');
|
const { diagram } = await import('./classDiagram.js');
|
||||||
return { id, diagram };
|
return { id, diagram };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { parser } from './parser/classDiagram';
|
import { parser } from './parser/classDiagram.jison';
|
||||||
import classDb from './classDb';
|
import classDb from './classDb.js';
|
||||||
|
|
||||||
describe('class diagram, ', function () {
|
describe('class diagram, ', function () {
|
||||||
describe('when parsing data from a classDiagram it', function () {
|
describe('when parsing data from a classDiagram it', function () {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { DiagramDefinition } from '../../diagram-api/types';
|
import { DiagramDefinition } from '../../diagram-api/types.js';
|
||||||
// @ts-ignore: TODO Fix ts errors
|
// @ts-ignore: TODO Fix ts errors
|
||||||
import parser from './parser/classDiagram';
|
import parser from './parser/classDiagram.jison';
|
||||||
import db from './classDb';
|
import db from './classDb.js';
|
||||||
import styles from './styles';
|
import styles from './styles.js';
|
||||||
import renderer from './classRenderer-v2';
|
import renderer from './classRenderer-v2.js';
|
||||||
|
|
||||||
export const diagram: DiagramDefinition = {
|
export const diagram: DiagramDefinition = {
|
||||||
parser,
|
parser,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user