Skip to content

Commit 8d6317b

Browse files
committed
Merge branch 'develop' into pr/csholmq/4958
* develop: (21 commits) Fix typo fix typo Add new Atlassian integrations chore(deps): update all patch dependencies chore: release v10.6.1 fix(flow): fix invalid ellipseText regex review fixes Update XYChart's nav link in the docs template Update index.md add comment for ts ignore move decodeEntities to utils review fixes chore(deps): update all minor dependencies chore: Point to correct changelog add spec fix: getMessageAPI so it considers entity codes Update classDiagram.md Chore: Typo fixed in multiple files feat(gantt): update styles docs(integrations): add Mermaid for Slack ...
2 parents a3ee21d + 72038a6 commit 8d6317b

29 files changed

+318
-354
lines changed

docs/config/setup/interfaces/mermaidAPI.ParseOptions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
#### Defined in
1818

19-
[mermaidAPI.ts:59](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L59)
19+
[mermaidAPI.ts:60](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L60)

docs/config/setup/interfaces/mermaidAPI.RenderResult.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
3939
4040
#### Defined in
4141
42-
[mermaidAPI.ts:79](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L79)
42+
[mermaidAPI.ts:80](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L80)
4343
4444
---
4545
@@ -51,4 +51,4 @@ The svg code for the rendered graph.
5151
5252
#### Defined in
5353
54-
[mermaidAPI.ts:69](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L69)
54+
[mermaidAPI.ts:70](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L70)

docs/config/setup/modules/mermaidAPI.md

+9-49
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
2525

2626
#### Defined in
2727

28-
[mermaidAPI.ts:63](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L63)
28+
[mermaidAPI.ts:64](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L64)
2929

3030
## Variables
3131

@@ -96,7 +96,7 @@ mermaid.initialize(config);
9696

9797
#### Defined in
9898

99-
[mermaidAPI.ts:641](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L641)
99+
[mermaidAPI.ts:603](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L603)
100100

101101
## Functions
102102

@@ -127,7 +127,7 @@ Return the last node appended
127127

128128
#### Defined in
129129

130-
[mermaidAPI.ts:299](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L299)
130+
[mermaidAPI.ts:263](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L263)
131131

132132
---
133133

@@ -153,7 +153,7 @@ the cleaned up svgCode
153153

154154
#### Defined in
155155

156-
[mermaidAPI.ts:245](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L245)
156+
[mermaidAPI.ts:209](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L209)
157157

158158
---
159159

@@ -178,7 +178,7 @@ the string with all the user styles
178178

179179
#### Defined in
180180

181-
[mermaidAPI.ts:175](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L175)
181+
[mermaidAPI.ts:139](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L139)
182182

183183
---
184184

@@ -201,7 +201,7 @@ the string with all the user styles
201201

202202
#### Defined in
203203

204-
[mermaidAPI.ts:222](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L222)
204+
[mermaidAPI.ts:186](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L186)
205205

206206
---
207207

@@ -228,47 +228,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
228228

229229
#### Defined in
230230

231-
[mermaidAPI.ts:160](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L160)
232-
233-
---
234-
235-
### decodeEntities
236-
237-
**decodeEntities**(`text`): `string`
238-
239-
#### Parameters
240-
241-
| Name | Type | Description |
242-
| :----- | :------- | :----------------- |
243-
| `text` | `string` | text to be decoded |
244-
245-
#### Returns
246-
247-
`string`
248-
249-
#### Defined in
250-
251-
[mermaidAPI.ts:146](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L146)
252-
253-
---
254-
255-
### encodeEntities
256-
257-
**encodeEntities**(`text`): `string`
258-
259-
#### Parameters
260-
261-
| Name | Type | Description |
262-
| :----- | :------- | :----------------- |
263-
| `text` | `string` | text to be encoded |
264-
265-
#### Returns
266-
267-
`string`
268-
269-
#### Defined in
270-
271-
[mermaidAPI.ts:117](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L117)
231+
[mermaidAPI.ts:124](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L124)
272232

273233
---
274234

@@ -294,7 +254,7 @@ Put the svgCode into an iFrame. Return the iFrame code
294254

295255
#### Defined in
296256

297-
[mermaidAPI.ts:276](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L276)
257+
[mermaidAPI.ts:240](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L240)
298258

299259
---
300260

@@ -319,4 +279,4 @@ Remove any existing elements from the given document
319279

320280
#### Defined in
321281

322-
[mermaidAPI.ts:349](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L349)
282+
[mermaidAPI.ts:313](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L313)

docs/ecosystem/integrations-community.md

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Below are a list of community plugins and integrations created with Mermaid.
4242
- [Mermaid plugin for GitBook](https://github.com/wwformat/gitbook-plugin-mermaid-pdf)
4343
- [LiveBook](https://livebook.dev)
4444
- [Atlassian Products](https://www.atlassian.com)
45+
- [Mermaid for Confluence](https://marketplace.atlassian.com/apps/1224722/mermaid-for-confluence?hosting=cloud&tab=overview)
46+
- [Mermaid Integration for Confluence](https://marketplace.atlassian.com/apps/1222792/mermaid-integration-for-confluence?hosting=cloud&tab=overview)
47+
- [Mermaid Diagrams for Confluence](https://marketplace.atlassian.com/apps/1226945/mermaid-diagrams-for-confluence?hosting=cloud&tab=overview)
48+
- [Mermaid Macro for Confluence](https://marketplace.atlassian.com/apps/1231150/mermaid-macro-for-confluence?hosting=cloud&tab=overview)
49+
- [EliteSoft Mermaid Charts and Diagrams](https://marketplace.atlassian.com/apps/1227286/elitesoft-mermaid-charts-and-diagrams?hosting=cloud&tab=overview)
50+
- [Mermaid for Jira Cloud - Draw UML diagrams easily](https://marketplace.atlassian.com/apps/1223053/mermaid-for-jira-cloud-draw-uml-diagrams-easily?hosting=cloud&tab=overview)
4551
- [Mermaid Charts & Diagrams for Confluence](https://marketplace.atlassian.com/apps/1222572/)
4652
- [Mermaid Charts & Diagrams for Jira](https://marketplace.atlassian.com/apps/1224537/)
4753
- [Mermaid Live Editor for Confluence Cloud](https://marketplace.atlassian.com/apps/1231571/mermaid-live-editor-for-confluence?hosting=cloud&tab=overview)
@@ -100,6 +106,8 @@ Communication tools and platforms
100106
- [phpbb-ext-mermaid](https://github.com/AlfredoRamos/phpbb-ext-mermaid)
101107
- [NodeBB](https://nodebb.org)
102108
- [Mermaid Plugin](https://www.npmjs.com/package/nodebb-plugin-mermaid)
109+
- [Slack](https://slack.com)
110+
- [Mermaid for Slack](https://github.com/JackuB/mermaid-for-slack)
103111

104112
### Wikis
105113

docs/intro/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ To Deploy Mermaid:
340340
</script>
341341
```
342342

343-
**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.**
343+
**Doing so commands the mermaid parser to look for the `<div>` or `<pre>` tags with `class="mermaid"`. From these tags, mermaid tries to read the diagram/chart definitions and render them into SVG charts.**
344344

345345
**Examples can be found in** [Other examples](../syntax/examples.md)
346346

docs/syntax/c4.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ UpdateRelStyle(customerA, bankA, $offsetY="60")
399399
title Component diagram for Internet Banking System - API Application
400400
401401
Container(spa, "Single Page Application", "javascript and angular", "Provides all the internet banking functionality to customers via their web browser.")
402-
Container(ma, "Mobile App", "Xamarin", "Provides a limited subset ot the internet banking functionality to customers via their mobile mobile device.")
402+
Container(ma, "Mobile App", "Xamarin", "Provides a limited subset to the internet banking functionality to customers via their mobile mobile device.")
403403
ContainerDb(db, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")
404404
System_Ext(mbs, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")
405405
@@ -439,7 +439,7 @@ UpdateRelStyle(customerA, bankA, $offsetY="60")
439439
title Component diagram for Internet Banking System - API Application
440440
441441
Container(spa, "Single Page Application", "javascript and angular", "Provides all the internet banking functionality to customers via their web browser.")
442-
Container(ma, "Mobile App", "Xamarin", "Provides a limited subset ot the internet banking functionality to customers via their mobile mobile device.")
442+
Container(ma, "Mobile App", "Xamarin", "Provides a limited subset to the internet banking functionality to customers via their mobile mobile device.")
443443
ContainerDb(db, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")
444444
System_Ext(mbs, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")
445445

docs/syntax/classDiagram.md

-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ And `Link` can be one of:
425425

426426
A namespace groups classes.
427427

428-
Code:
429-
430428
```mermaid-example
431429
classDiagram
432430
namespace BaseShapes {

docs/syntax/flowchart.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ flowchart TB
467467
A & B--> C & D
468468
```
469469

470-
If you describe the same diagram using the the basic syntax, it will take four lines. A
470+
If you describe the same diagram using the basic syntax, it will take four lines. A
471471
word of warning, one could go overboard with this making the flowchart harder to read in
472472
markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
473473
This goes for expressive syntaxes as well.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "10.2.4",
55
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
66
"type": "module",
7-
"packageManager": "pnpm@8.9.2",
7+
"packageManager": "pnpm@8.10.2",
88
"keywords": [
99
"diagram",
1010
"markdown",

packages/mermaid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mermaid",
3-
"version": "10.6.0",
3+
"version": "10.6.1",
44
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
55
"type": "module",
66
"module": "./dist/mermaid.core.mjs",

packages/mermaid/src/Diagram.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { log } from './logger.js';
33
import { getDiagram, registerDiagram } from './diagram-api/diagramAPI.js';
44
import { detectType, getDiagramLoader } from './diagram-api/detectType.js';
55
import { UnknownDiagramError } from './errors.js';
6+
import { encodeEntities } from './utils.js';
7+
68
import type { DetailedError } from './utils.js';
79
import type { DiagramDefinition, DiagramMetadata } from './diagram-api/types.js';
810

@@ -21,6 +23,7 @@ export class Diagram {
2123

2224
private detectError?: UnknownDiagramError;
2325
constructor(public text: string, public metadata: Pick<DiagramMetadata, 'title'> = {}) {
26+
this.text = encodeEntities(text);
2427
this.text += '\n';
2528
const cnf = configApi.getConfig();
2629
try {

packages/mermaid/src/dagre-wrapper/createLabel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { select } from 'd3';
22
import { log } from '../logger.js';
33
import { getConfig } from '../diagram-api/diagramAPI.js';
44
import { evaluate } from '../diagrams/common/common.js';
5-
import { decodeEntities } from '../mermaidAPI.js';
5+
import { decodeEntities } from '../utils.js';
66

77
/**
88
* @param dom

packages/mermaid/src/dagre-wrapper/shapes/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import createLabel from '../createLabel.js';
22
import { createText } from '../../rendering-util/createText.js';
33
import { getConfig } from '../../diagram-api/diagramAPI.js';
4-
import { decodeEntities } from '../../mermaidAPI.js';
54
import { select } from 'd3';
65
import { evaluate, sanitizeText } from '../../diagrams/common/common.js';
6+
import { decodeEntities } from '../../utils.js';
77

88
export const labelHelper = async (parent, node, _classes, isNode) => {
99
let classes;

packages/mermaid/src/diagram.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,18 @@ Expecting 'TXT', got 'NEWLINE'"
6969
'"No diagram type detected matching given configuration for text: thor TD; A-->B"'
7070
);
7171
});
72+
73+
test('should consider entity codes when present in diagram defination', async () => {
74+
const diagram = await getDiagramFromText(`sequenceDiagram
75+
A->>B: I #9829; you!
76+
B->>A: I #9829; you #infin; times more!`);
77+
// @ts-ignore: we need to add types for sequenceDb which will be done in separate PR
78+
const messages = diagram.db?.getMessages?.();
79+
if (!messages) {
80+
throw new Error('Messages not found!');
81+
}
82+
83+
expect(messages[0].message).toBe('I fl°°9829¶ß you!');
84+
expect(messages[1].message).toBe('I fl°°9829¶ß you fl°infin¶ß times more!');
85+
});
7286
});

packages/mermaid/src/diagrams/flowchart/parser/flow-text.spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ describe('[Text] when parsing', () => {
535535
expect(vert['A'].text).toBe('this is an ellipse');
536536
});
537537

538+
it('should not freeze when ellipse text has a `(`', function () {
539+
expect(() => flow.parser.parse('graph\nX(- My Text (')).toThrowError();
540+
});
541+
538542
it('should handle text in diamond vertices with space', function () {
539543
const res = flow.parser.parse('graph TD;A(chimpansen hoppar)-->C;');
540544

packages/mermaid/src/diagrams/flowchart/parser/flow.jison

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ that id.
134134
<*>\s*\~\~[\~]+\s* return 'LINK';
135135

136136
<ellipseText>[-/\)][\)] { this.popState(); return '-)'; }
137-
<ellipseText>[^\(\)\[\]\{\}]|-/!\)+ return "TEXT"
137+
<ellipseText>[^\(\)\[\]\{\}]|-\!\)+ return "TEXT"
138138
<*>"(-" { this.pushState("ellipseText"); return '(-'; }
139139

140140
<text>"])" { this.popState(); return 'STADIUMEND'; }

packages/mermaid/src/diagrams/gantt/styles.js

+16-25
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const getStyles = (options) =>
22
`
33
.mermaid-main-font {
4-
font-family: "trebuchet ms", verdana, arial, sans-serif;
5-
font-family: var(--mermaid-font-family);
4+
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
65
}
6+
77
.exclude-range {
88
fill: ${options.excludeBkgColor};
99
}
@@ -45,11 +45,7 @@ const getStyles = (options) =>
4545
4646
.sectionTitle {
4747
text-anchor: start;
48-
// font-size: ${options.ganttFontSize};
49-
// text-height: 14px;
50-
font-family: 'trebuchet ms', verdana, arial, sans-serif;
51-
font-family: var(--mermaid-font-family);
52-
48+
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
5349
}
5450
5551
@@ -59,10 +55,11 @@ const getStyles = (options) =>
5955
stroke: ${options.gridColor};
6056
opacity: 0.8;
6157
shape-rendering: crispEdges;
62-
text {
63-
font-family: ${options.fontFamily};
64-
fill: ${options.textColor};
65-
}
58+
}
59+
60+
.grid .tick text {
61+
font-family: ${options.fontFamily};
62+
fill: ${options.textColor};
6663
}
6764
6865
.grid path {
@@ -89,33 +86,27 @@ const getStyles = (options) =>
8986
9087
.taskText {
9188
text-anchor: middle;
92-
font-family: 'trebuchet ms', verdana, arial, sans-serif;
93-
font-family: var(--mermaid-font-family);
89+
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
9490
}
9591
96-
// .taskText:not([font-size]) {
97-
// font-size: ${options.ganttFontSize};
98-
// }
99-
10092
.taskTextOutsideRight {
10193
fill: ${options.taskTextDarkColor};
10294
text-anchor: start;
103-
// font-size: ${options.ganttFontSize};
104-
font-family: 'trebuchet ms', verdana, arial, sans-serif;
105-
font-family: var(--mermaid-font-family);
106-
95+
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
10796
}
10897
10998
.taskTextOutsideLeft {
11099
fill: ${options.taskTextDarkColor};
111100
text-anchor: end;
112-
// font-size: ${options.ganttFontSize};
113101
}
114102
103+
115104
/* Special case clickable */
105+
116106
.task.clickable {
117107
cursor: pointer;
118108
}
109+
119110
.taskText.clickable {
120111
cursor: pointer;
121112
fill: ${options.taskTextClickableColor} !important;
@@ -134,6 +125,7 @@ const getStyles = (options) =>
134125
font-weight: bold;
135126
}
136127
128+
137129
/* Specific task settings for the sections*/
138130
139131
.taskText0,
@@ -255,9 +247,8 @@ const getStyles = (options) =>
255247
.titleText {
256248
text-anchor: middle;
257249
font-size: 18px;
258-
fill: ${options.textColor} ;
259-
font-family: 'trebuchet ms', verdana, arial, sans-serif;
260-
font-family: var(--mermaid-font-family);
250+
fill: ${options.titleColor || options.textColor};
251+
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
261252
}
262253
`;
263254

0 commit comments

Comments
 (0)