Compare commits

..

3 Commits

Author SHA1 Message Date
darshanr0107
d2774269cf fix: test case diagram code
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
2025-11-05 19:27:09 +05:30
darshanr0107
015af7603e chore: add changeset
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
2025-10-17 12:49:15 +05:30
darshanr0107
c810fab231 fix: handle backslash parsing in math formulas within new shape syntax
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
2025-10-17 12:43:59 +05:30
59 changed files with 1457 additions and 2507 deletions

View File

@@ -1,5 +0,0 @@
---
'mermaid': patch
---
fix: Correct viewBox casing and make SVGs responsive

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
chore: Fix mindmap rendering in docs and apply tidytree layout

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: Handle backslash parsing in math formulas within new flowchart shape syntax

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: Ensure edge label color is applied when using classDef with edge IDs

View File

@@ -1,5 +0,0 @@
---
'mermaid': patch
---
fix: Allow IDs starting with L, R, T, or B in parser

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: Resolve gantt chart crash due to invalid array length

View File

@@ -0,0 +1,5 @@
---
'mermaid': minor
---
feat: Add IDs in architecture diagrams

View File

@@ -0,0 +1,9 @@
---
'mermaid': patch
---
chore: revert marked dependency from ^15.0.7 to ^16.0.0
- Reverted marked package version to ^16.0.0 for better compatibility
- This is a dependency update that maintains API compatibility
- All tests pass with the updated version

View File

@@ -1,5 +0,0 @@
---
'mermaid': minor
---
feat: allow to put notes in namespaces on classDiagram

View File

@@ -1,5 +1,3 @@
!viewbox
# It should be viewBox
# This file contains coding related terms # This file contains coding related terms
ALPHANUM ALPHANUM
antiscript antiscript

View File

@@ -64,7 +64,6 @@ rscratch
shiki shiki
Slidev Slidev
sparkline sparkline
speccharts
sphinxcontrib sphinxcontrib
ssim ssim
stylis stylis

View File

@@ -71,9 +71,6 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
const external: string[] = ['require', 'fs', 'path']; const external: string[] = ['require', 'fs', 'path'];
const outFileName = getFileName(name, options); const outFileName = getFileName(name, options);
const { dependencies, version } = JSON.parse(
readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8')
);
const output: BuildOptions = buildOptions({ const output: BuildOptions = buildOptions({
...rest, ...rest,
absWorkingDir: resolve(__dirname, `../packages/${packageName}`), absWorkingDir: resolve(__dirname, `../packages/${packageName}`),
@@ -85,13 +82,15 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
chunkNames: `chunks/${outFileName}/[name]-[hash]`, chunkNames: `chunks/${outFileName}/[name]-[hash]`,
define: { define: {
// This needs to be stringified for esbuild // This needs to be stringified for esbuild
'injected.includeLargeFeatures': `${includeLargeFeatures}`, includeLargeFeatures: `${includeLargeFeatures}`,
'injected.version': `'${version}'`,
'import.meta.vitest': 'undefined', 'import.meta.vitest': 'undefined',
}, },
}); });
if (core) { if (core) {
const { dependencies } = JSON.parse(
readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8')
);
// Core build is used to generate file without bundled dependencies. // Core build is used to generate file without bundled dependencies.
// This is used by downstream projects to bundle dependencies themselves. // This is used by downstream projects to bundle dependencies themselves.
// Ignore dependencies and any dependencies of dependencies // Ignore dependencies and any dependencies of dependencies

View File

@@ -58,7 +58,7 @@ jobs:
echo "EOF" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT
- name: Commit and create pull request - name: Commit and create pull request
uses: peter-evans/create-pull-request@0edc001d28a2959cd7a6b505629f1d82f0a6e67d uses: peter-evans/create-pull-request@915d841dae6a4f191bb78faf61a257411d7be4d2
with: with:
add-paths: | add-paths: |
cypress/timings.json cypress/timings.json

View File

@@ -42,4 +42,5 @@ jobs:
publish: pnpm changeset:publish publish: pnpm changeset:publish
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true NPM_CONFIG_PROVENANCE: true

View File

@@ -20,7 +20,7 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- name: Run analysis - name: Run analysis
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
with: with:
results_file: results.sarif results_file: results.sarif
results_format: sarif results_format: sarif

View File

@@ -1,7 +1,7 @@
name: Validate pnpm-lock.yaml name: Validate pnpm-lock.yaml
on: on:
pull_request_target: pull_request:
paths: paths:
- 'pnpm-lock.yaml' - 'pnpm-lock.yaml'
- '**/package.json' - '**/package.json'
@@ -15,8 +15,13 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- name: Validate pnpm-lock.yaml entries - name: Validate pnpm-lock.yaml entries
id: validate # give this step an ID so we can reference its outputs id: validate # give this step an ID so we can reference its outputs
@@ -50,41 +55,16 @@ jobs:
exit 1 exit 1
fi fi
- name: Find existing lockfile validation comment
if: always()
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Lockfile Validation Failed'
- name: Comment on PR if validation failed - name: Comment on PR if validation failed
if: failure() if: failure()
uses: peter-evans/create-or-update-comment@v5 uses: peter-evans/create-or-update-comment@v4
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: | body: |
❌ **Lockfile Validation Failed**
The following issue(s) were detected: The following issue(s) were detected:
${{ steps.validate.outputs.errors }} ${{ steps.validate.outputs.errors }}
Please address these and push an update. Please address these and push an update.
_Posted automatically by GitHub Actions_ _Posted automatically by GitHub Actions_
- name: Delete comment if validation passed
if: success() && steps.find-comment.outputs.comment-id != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ steps.find-comment.outputs.comment-id }},
});

View File

@@ -78,8 +78,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
}, },
define: { define: {
'import.meta.vitest': 'undefined', 'import.meta.vitest': 'undefined',
'injected.includeLargeFeatures': 'true',
'injected.version': `'0.0.0'`,
}, },
resolve: { resolve: {
extensions: [], extensions: [],
@@ -96,6 +94,10 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
}), }),
...visualizerOptions(packageName, core), ...visualizerOptions(packageName, core),
], ],
define: {
// Needs to be string
includeLargeFeatures: 'true',
},
}; };
if (watch && config.build) { if (watch && config.build) {

View File

@@ -5,7 +5,7 @@ USER 0:0
RUN corepack enable \ RUN corepack enable \
&& corepack enable pnpm && corepack enable pnpm
RUN apk add --no-cache git~=2.43 \ RUN apk add --no-cache git~=2.43.4 \
&& git config --add --system safe.directory /mermaid && git config --add --system safe.directory /mermaid
ENV NODE_OPTIONS="--max_old_space_size=8192" ENV NODE_OPTIONS="--max_old_space_size=8192"

View File

@@ -99,8 +99,6 @@ export const openURLAndVerifyRendering = (
cy.visit(url); cy.visit(url);
cy.window().should('have.property', 'rendered', true); cy.window().should('have.property', 'rendered', true);
cy.get('svg').should('be.visible'); cy.get('svg').should('be.visible');
// cspell:ignore viewbox
cy.get('svg').should('not.have.attr', 'viewbox');
if (validation) { if (validation) {
cy.get('svg').should(validation); cy.get('svg').should(validation);

View File

@@ -562,20 +562,6 @@ class C13["With Città foreign language"]
` `
); );
}); });
it('should add notes in namespaces', function () {
imgSnapshotTest(
`
classDiagram
note "This is a outer note"
note for C1 "This is a outer note for C1"
namespace Namespace1 {
note "This is a inner note"
note for C1 "This is a inner note for C1"
class C1
}
`
);
});
it('should render a simple class diagram with no members', () => { it('should render a simple class diagram with no members', () => {
imgSnapshotTest( imgSnapshotTest(
` `

View File

@@ -709,20 +709,6 @@ class C13["With Città foreign language"]
` `
); );
}); });
it('should add notes in namespaces', function () {
imgSnapshotTest(
`
classDiagram
note "This is a outer note"
note for C1 "This is a outer note for C1"
namespace Namespace1 {
note "This is a inner note"
note for C1 "This is a inner note for C1"
class C1
}
`
);
});
it('should render a simple class diagram with no members', () => { it('should render a simple class diagram with no members', () => {
imgSnapshotTest( imgSnapshotTest(
` `

View File

@@ -445,7 +445,7 @@ ORDER ||--|{ LINE-ITEM : contains
{ logLevel: 1 } { logLevel: 1 }
); );
}); });
it('should render ER diagram with standalone numeric entities', () => { it('should render ER diagram with numeric entity names and attributes', () => {
imgSnapshotTest( imgSnapshotTest(
`erDiagram `erDiagram
PRODUCT ||--o{ ORDER-ITEM : has PRODUCT ||--o{ ORDER-ITEM : has

View File

@@ -184,7 +184,6 @@
} }
Admin --> Report : generates Admin --> Report : generates
</pre> </pre>
<hr />
<pre class="mermaid"> <pre class="mermaid">
classDiagram classDiagram
namespace Company.Project.Module { namespace Company.Project.Module {
@@ -241,20 +240,6 @@
Bike --> Square : "Logo Shape" Bike --> Square : "Logo Shape"
</pre> </pre>
<hr />
<pre class="mermaid">
classDiagram
note "This is a outer note"
note for Class1 "This is a outer note for Class1"
namespace ns {
note "This is a inner note"
note for Class1 "This is a inner note for Class1"
class Class1
class Class2
}
</pre>
<hr />
<script type="module"> <script type="module">
import mermaid from './mermaid.esm.mjs'; import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ mermaid.initialize({

View File

@@ -57,8 +57,6 @@ To add an integration to this list, see the [Integrations - create page](./integ
- [GitHub Writer](https://github.com/ckeditor/github-writer) - [GitHub Writer](https://github.com/ckeditor/github-writer)
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator) - [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅ - [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
- [GNU Octave](https://octave.org/) ✅
- [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid) - [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
- [MonsterWriter](https://www.monsterwriter.com/) ✅ - [MonsterWriter](https://www.monsterwriter.com/) ✅
- [Joplin](https://joplinapp.org) ✅ - [Joplin](https://joplinapp.org) ✅
@@ -274,7 +272,6 @@ Communication tools and platforms
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin) - [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
- [Reveal CK](https://github.com/jedcn/reveal-ck) - [Reveal CK](https://github.com/jedcn/reveal-ck)
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts)
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer) - [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
<!--- cspell:ignore Blazorade HueHive ---> <!--- cspell:ignore Blazorade HueHive --->

View File

@@ -47,7 +47,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
## Plans ## Plans
- **Free** - A free plan that includes six diagrams. - **Free** - A free plan that includes three diagrams.
- **Pro** - A paid plan that includes unlimited diagrams, access to the collaboration feature, and more. - **Pro** - A paid plan that includes unlimited diagrams, access to the collaboration feature, and more.

View File

@@ -63,21 +63,21 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@applitools/eyes-cypress": "^3.55.4", "@applitools/eyes-cypress": "^3.55.2",
"@argos-ci/cypress": "^6.1.5", "@argos-ci/cypress": "^6.1.3",
"@changesets/changelog-github": "^0.5.1", "@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.7", "@changesets/cli": "^2.29.7",
"@cspell/eslint-plugin": "^9.3.0", "@cspell/eslint-plugin": "^8.19.4",
"@cypress/code-coverage": "^3.14.7", "@cypress/code-coverage": "^3.14.6",
"@eslint/js": "^9.26.0", "@eslint/js": "^9.26.0",
"@rollup/plugin-typescript": "^12.1.4", "@rollup/plugin-typescript": "^12.1.4",
"@types/cors": "^2.8.19", "@types/cors": "^2.8.19",
"@types/express": "^5.0.5", "@types/express": "^5.0.3",
"@types/js-yaml": "^4.0.9", "@types/js-yaml": "^4.0.9",
"@types/jsdom": "^21.1.7", "@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.20", "@types/lodash": "^4.17.20",
"@types/mdast": "^4.0.4", "@types/mdast": "^4.0.4",
"@types/node": "^22.18.13", "@types/node": "^22.18.6",
"@types/rollup-plugin-visualizer": "^5.0.3", "@types/rollup-plugin-visualizer": "^5.0.3",
"@vitest/coverage-v8": "^3.2.4", "@vitest/coverage-v8": "^3.2.4",
"@vitest/spy": "^3.2.4", "@vitest/spy": "^3.2.4",
@@ -88,23 +88,23 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"cpy-cli": "^5.0.0", "cpy-cli": "^5.0.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cspell": "^9.2.2", "cspell": "^9.2.1",
"cypress": "^14.5.4", "cypress": "^14.5.4",
"cypress-image-snapshot": "^4.0.1", "cypress-image-snapshot": "^4.0.1",
"cypress-split": "^1.24.25", "cypress-split": "^1.24.23",
"esbuild": "^0.25.12", "esbuild": "^0.25.10",
"eslint": "^9.26.0", "eslint": "^9.26.0",
"eslint-config-prettier": "^10.1.8", "eslint-config-prettier": "^10.1.8",
"eslint-plugin-cypress": "^5.2.0", "eslint-plugin-cypress": "^4.3.0",
"eslint-plugin-html": "^8.1.3", "eslint-plugin-html": "^8.1.3",
"eslint-plugin-jest": "^29.0.1", "eslint-plugin-jest": "^28.14.0",
"eslint-plugin-jsdoc": "^61.1.12", "eslint-plugin-jsdoc": "^50.8.0",
"eslint-plugin-json": "^4.0.1", "eslint-plugin-json": "^4.0.1",
"eslint-plugin-lodash": "^8.0.0", "eslint-plugin-lodash": "^8.0.0",
"eslint-plugin-markdown": "^5.1.0", "eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-no-only-tests": "^3.3.0", "eslint-plugin-no-only-tests": "^3.3.0",
"eslint-plugin-tsdoc": "^0.4.0", "eslint-plugin-tsdoc": "^0.4.0",
"eslint-plugin-unicorn": "^62.0.0", "eslint-plugin-unicorn": "^59.0.1",
"express": "^5.1.0", "express": "^5.1.0",
"globals": "^16.4.0", "globals": "^16.4.0",
"globby": "^14.1.0", "globby": "^14.1.0",
@@ -121,10 +121,10 @@
"prettier": "^3.6.2", "prettier": "^3.6.2",
"prettier-plugin-jsdoc": "^1.3.3", "prettier-plugin-jsdoc": "^1.3.3",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"rollup-plugin-visualizer": "^6.0.5", "rollup-plugin-visualizer": "^6.0.3",
"start-server-and-test": "^2.1.2", "start-server-and-test": "^2.1.2",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"tsx": "^4.20.6", "tsx": "^4.20.5",
"typescript": "~5.7.3", "typescript": "~5.7.3",
"typescript-eslint": "^8.38.0", "typescript-eslint": "^8.38.0",
"vite": "^7.0.7", "vite": "^7.0.7",

View File

@@ -18,9 +18,7 @@
"elk", "elk",
"mermaid" "mermaid"
], ],
"scripts": { "scripts": {},
"clean": "rimraf dist"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/mermaid-js/mermaid" "url": "https://github.com/mermaid-js/mermaid"

View File

@@ -19,9 +19,7 @@
"mermaid", "mermaid",
"layout" "layout"
], ],
"scripts": { "scripts": {},
"clean": "rimraf dist"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/mermaid-js/mermaid" "url": "https://github.com/mermaid-js/mermaid"

View File

@@ -33,7 +33,7 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@zenuml/core": "^3.41.6" "@zenuml/core": "^3.41.4"
}, },
"devDependencies": { "devDependencies": {
"mermaid": "workspace:^" "mermaid": "workspace:^"

View File

@@ -1,30 +1,5 @@
# mermaid # mermaid
## 11.12.1
### Patch Changes
- [#7107](https://github.com/mermaid-js/mermaid/pull/7107) [`cbf8946`](https://github.com/mermaid-js/mermaid/commit/cbf89462acecac7a06f19843e8d48cb137df0753) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - fix: Updated the dependency dagre-d3-es to 7.0.13 to fix GHSA-cc8p-78qf-8p7q
## 11.12.0
### Minor Changes
- [#6921](https://github.com/mermaid-js/mermaid/pull/6921) [`764b315`](https://github.com/mermaid-js/mermaid/commit/764b315dc16d0359add7c6b8e3ef7592e9bdc09c) Thanks [@quilicicf](https://github.com/quilicicf)! - feat: Add IDs in architecture diagrams
### Patch Changes
- [#6950](https://github.com/mermaid-js/mermaid/pull/6950) [`a957908`](https://github.com/mermaid-js/mermaid/commit/a9579083bfba367a4f4678547ec37ed7b61b9f5b) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - chore: Fix mindmap rendering in docs and apply tidytree layout
- [#6826](https://github.com/mermaid-js/mermaid/pull/6826) [`1d36810`](https://github.com/mermaid-js/mermaid/commit/1d3681053b9168354e48e5763023b6305cd1ca72) Thanks [@darshanr0107](https://github.com/darshanr0107)! - fix: Ensure edge label color is applied when using classDef with edge IDs
- [#6945](https://github.com/mermaid-js/mermaid/pull/6945) [`d318f1a`](https://github.com/mermaid-js/mermaid/commit/d318f1a13cd7429334a29c70e449074ec1cb9f68) Thanks [@darshanr0107](https://github.com/darshanr0107)! - fix: Resolve gantt chart crash due to invalid array length
- [#6918](https://github.com/mermaid-js/mermaid/pull/6918) [`cfe9238`](https://github.com/mermaid-js/mermaid/commit/cfe9238882cbe95416db1feea3112456a71b6aaf) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - chore: revert marked dependency from ^15.0.7 to ^16.0.0
- Reverted marked package version to ^16.0.0 for better compatibility
- This is a dependency update that maintains API compatibility
- All tests pass with the updated version
## 11.11.0 ## 11.11.0
### Minor Changes ### Minor Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "mermaid", "name": "mermaid",
"version": "11.12.1", "version": "11.11.0",
"description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.",
"type": "module", "type": "module",
"module": "./dist/mermaid.core.mjs", "module": "./dist/mermaid.core.mjs",
@@ -76,10 +76,10 @@
"cytoscape-fcose": "^2.2.0", "cytoscape-fcose": "^2.2.0",
"d3": "^7.9.0", "d3": "^7.9.0",
"d3-sankey": "^0.12.3", "d3-sankey": "^0.12.3",
"dagre-d3-es": "7.0.13", "dagre-d3-es": "7.0.11",
"dayjs": "^1.11.19", "dayjs": "^1.11.18",
"dompurify": "^3.2.7", "dompurify": "^3.2.5",
"katex": "^0.16.25", "katex": "^0.16.22",
"khroma": "^2.1.0", "khroma": "^2.1.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"marked": "^16.3.0", "marked": "^16.3.0",
@@ -89,10 +89,10 @@
"uuid": "^11.1.0" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {
"@adobe/jsonschema2md": "^8.0.7", "@adobe/jsonschema2md": "^8.0.5",
"@iconify/types": "^2.0.0", "@iconify/types": "^2.0.0",
"@types/cytoscape": "^3.21.9", "@types/cytoscape": "^3.21.9",
"@types/cytoscape-fcose": "^2.2.5", "@types/cytoscape-fcose": "^2.2.4",
"@types/d3-sankey": "^0.12.4", "@types/d3-sankey": "^0.12.4",
"@types/d3-scale": "^4.0.9", "@types/d3-scale": "^4.0.9",
"@types/d3-scale-chromatic": "^3.1.0", "@types/d3-scale-chromatic": "^3.1.0",
@@ -101,7 +101,7 @@
"@types/jsdom": "^21.1.7", "@types/jsdom": "^21.1.7",
"@types/katex": "^0.16.7", "@types/katex": "^0.16.7",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.9",
"@types/stylis": "^4.2.7", "@types/stylis": "^4.2.7",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"ajv": "^8.17.1", "ajv": "^8.17.1",
@@ -123,7 +123,7 @@
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"start-server-and-test": "^2.1.2", "start-server-and-test": "^2.1.2",
"type-fest": "^4.41.0", "type-fest": "^4.41.0",
"typedoc": "^0.28.14", "typedoc": "^0.28.13",
"typedoc-plugin-markdown": "^4.8.1", "typedoc-plugin-markdown": "^4.8.1",
"typescript": "~5.7.3", "typescript": "~5.7.3",
"unist-util-flatmap": "^1.0.0", "unist-util-flatmap": "^1.0.0",

View File

@@ -72,7 +72,7 @@ export const addDiagrams = () => {
} }
); );
if (injected.includeLargeFeatures) { if (includeLargeFeatures) {
registerLazyLoadedDiagrams(flowchartElk, mindmap, architecture); registerLazyLoadedDiagrams(flowchartElk, mindmap, architecture);
} }

View File

@@ -17,7 +17,6 @@ import type {
ClassRelation, ClassRelation,
ClassNode, ClassNode,
ClassNote, ClassNote,
ClassNoteMap,
ClassMap, ClassMap,
NamespaceMap, NamespaceMap,
NamespaceNode, NamespaceNode,
@@ -34,16 +33,15 @@ const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
export class ClassDB implements DiagramDB { export class ClassDB implements DiagramDB {
private relations: ClassRelation[] = []; private relations: ClassRelation[] = [];
private classes: ClassMap = new Map<string, ClassNode>(); private classes = new Map<string, ClassNode>();
private readonly styleClasses = new Map<string, StyleClass>(); private readonly styleClasses = new Map<string, StyleClass>();
private notes: ClassNoteMap = new Map<string, ClassNote>(); private notes: ClassNote[] = [];
private interfaces: Interface[] = []; private interfaces: Interface[] = [];
// private static classCounter = 0; // private static classCounter = 0;
private namespaces = new Map<string, NamespaceNode>(); private namespaces = new Map<string, NamespaceNode>();
private namespaceCounter = 0; private namespaceCounter = 0;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type private functions: any[] = [];
private functions: Function[] = [];
constructor() { constructor() {
this.functions.push(this.setupToolTips.bind(this)); this.functions.push(this.setupToolTips.bind(this));
@@ -126,7 +124,7 @@ export class ClassDB implements DiagramDB {
annotations: [], annotations: [],
styles: [], styles: [],
domId: MERMAID_DOM_ID_PREFIX + name + '-' + classCounter, domId: MERMAID_DOM_ID_PREFIX + name + '-' + classCounter,
}); } as ClassNode);
classCounter++; classCounter++;
} }
@@ -157,12 +155,12 @@ export class ClassDB implements DiagramDB {
public clear() { public clear() {
this.relations = []; this.relations = [];
this.classes = new Map<string, ClassNode>(); this.classes = new Map();
this.notes = new Map<string, ClassNote>(); this.notes = [];
this.interfaces = []; this.interfaces = [];
this.functions = []; this.functions = [];
this.functions.push(this.setupToolTips.bind(this)); this.functions.push(this.setupToolTips.bind(this));
this.namespaces = new Map<string, NamespaceNode>(); this.namespaces = new Map();
this.namespaceCounter = 0; this.namespaceCounter = 0;
this.direction = 'TB'; this.direction = 'TB';
commonClear(); commonClear();
@@ -180,12 +178,7 @@ export class ClassDB implements DiagramDB {
return this.relations; return this.relations;
} }
public getNote(id: string | number): ClassNote { public getNotes() {
const key = typeof id === 'number' ? `note${id}` : id;
return this.notes.get(key)!;
}
public getNotes(): ClassNoteMap {
return this.notes; return this.notes;
} }
@@ -286,19 +279,16 @@ export class ClassDB implements DiagramDB {
} }
} }
public addNote(text: string, className: string): string { public addNote(text: string, className: string) {
const index = this.notes.size;
const note = { const note = {
id: `note${index}`, id: `note${this.notes.length}`,
class: className, class: className,
text: text, text: text,
index: index,
}; };
this.notes.set(note.id, note); this.notes.push(note);
return note.id;
} }
public cleanupLabel(label: string): string { public cleanupLabel(label: string) {
if (label.startsWith(':')) { if (label.startsWith(':')) {
label = label.substring(1); label = label.substring(1);
} }
@@ -364,7 +354,7 @@ export class ClassDB implements DiagramDB {
}); });
} }
public getTooltip(id: string, namespace?: string): string | undefined { public getTooltip(id: string, namespace?: string) {
if (namespace && this.namespaces.has(namespace)) { if (namespace && this.namespaces.has(namespace)) {
return this.namespaces.get(namespace)!.classes.get(id)!.tooltip; return this.namespaces.get(namespace)!.classes.get(id)!.tooltip;
} }
@@ -544,11 +534,10 @@ export class ClassDB implements DiagramDB {
this.namespaces.set(id, { this.namespaces.set(id, {
id: id, id: id,
classes: new Map<string, ClassNode>(), classes: new Map(),
notes: new Map<string, ClassNote>(), children: {},
children: new Map<string, NamespaceNode>(),
domId: MERMAID_DOM_ID_PREFIX + id + '-' + this.namespaceCounter, domId: MERMAID_DOM_ID_PREFIX + id + '-' + this.namespaceCounter,
}); } as NamespaceNode);
this.namespaceCounter++; this.namespaceCounter++;
} }
@@ -566,23 +555,16 @@ export class ClassDB implements DiagramDB {
* *
* @param id - ID of the namespace to add * @param id - ID of the namespace to add
* @param classNames - IDs of the class to add * @param classNames - IDs of the class to add
* @param noteNames - IDs of the notes to add
* @public * @public
*/ */
public addClassesToNamespace(id: string, classNames: string[], noteNames: string[]) { public addClassesToNamespace(id: string, classNames: string[]) {
if (!this.namespaces.has(id)) { if (!this.namespaces.has(id)) {
return; return;
} }
for (const name of classNames) { for (const name of classNames) {
const { className } = this.splitClassNameAndType(name); const { className } = this.splitClassNameAndType(name);
const classNode = this.getClass(className); this.classes.get(className)!.parent = id;
classNode.parent = id; this.namespaces.get(id)!.classes.set(className, this.classes.get(className)!);
this.namespaces.get(id)!.classes.set(className, classNode);
}
for (const noteName of noteNames) {
const noteNode = this.getNote(noteName);
noteNode.parent = id;
this.namespaces.get(id)!.notes.set(noteName, noteNode);
} }
} }
@@ -635,32 +617,36 @@ export class ClassDB implements DiagramDB {
const edges: Edge[] = []; const edges: Edge[] = [];
const config = getConfig(); const config = getConfig();
for (const namespace of this.namespaces.values()) { for (const namespaceKey of this.namespaces.keys()) {
const node: Node = { const namespace = this.namespaces.get(namespaceKey);
id: namespace.id, if (namespace) {
label: namespace.id, const node: Node = {
isGroup: true, id: namespace.id,
padding: config.class!.padding ?? 16, label: namespace.id,
// parent node must be one of [rect, roundedWithTitle, noteGroup, divider] isGroup: true,
shape: 'rect', padding: config.class!.padding ?? 16,
cssStyles: [], // parent node must be one of [rect, roundedWithTitle, noteGroup, divider]
look: config.look, shape: 'rect',
}; cssStyles: [],
nodes.push(node); look: config.look,
};
nodes.push(node);
}
} }
for (const classNode of this.classes.values()) { for (const classKey of this.classes.keys()) {
const node: Node = { const classNode = this.classes.get(classKey);
...classNode, if (classNode) {
type: undefined, const node = classNode as unknown as Node;
isGroup: false, node.parentId = classNode.parent;
parentId: classNode.parent, node.look = config.look;
look: config.look, nodes.push(node);
}; }
nodes.push(node);
} }
for (const note of this.notes.values()) { let cnt = 0;
for (const note of this.notes) {
cnt++;
const noteNode: Node = { const noteNode: Node = {
id: note.id, id: note.id,
label: note.text, label: note.text,
@@ -674,15 +660,14 @@ export class ClassDB implements DiagramDB {
`stroke: ${config.themeVariables.noteBorderColor}`, `stroke: ${config.themeVariables.noteBorderColor}`,
], ],
look: config.look, look: config.look,
parentId: note.parent,
}; };
nodes.push(noteNode); nodes.push(noteNode);
const noteClassId = this.classes.get(note.class)?.id; const noteClassId = this.classes.get(note.class)?.id ?? '';
if (noteClassId) { if (noteClassId) {
const edge: Edge = { const edge: Edge = {
id: `edgeNote${note.index}`, id: `edgeNote${cnt}`,
start: note.id, start: note.id,
end: noteClassId, end: noteClassId,
type: 'normal', type: 'normal',
@@ -712,7 +697,7 @@ export class ClassDB implements DiagramDB {
nodes.push(interfaceNode); nodes.push(interfaceNode);
} }
let cnt = 0; cnt = 0;
for (const classRelation of this.relations) { for (const classRelation of this.relations) {
cnt++; cnt++;
const edge: Edge = { const edge: Edge = {

View File

@@ -417,7 +417,7 @@ class C13["With Città foreign language"]
note "This is a keyword: ${keyword}. It truly is." note "This is a keyword: ${keyword}. It truly is."
`; `;
parser.parse(str); parser.parse(str);
expect(classDb.getNote(0).text).toEqual(`This is a keyword: ${keyword}. It truly is.`); expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
}); });
it.each(keywords)( it.each(keywords)(
@@ -427,7 +427,7 @@ class C13["With Città foreign language"]
note "${keyword}"`; note "${keyword}"`;
parser.parse(str); parser.parse(str);
expect(classDb.getNote(0).text).toEqual(`${keyword}`); expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
} }
); );
@@ -441,7 +441,7 @@ class C13["With Città foreign language"]
`; `;
parser.parse(str); parser.parse(str);
expect(classDb.getNote(0).text).toEqual(`This is a keyword: ${keyword}. It truly is.`); expect(classDb.getNotes()[0].text).toEqual(`This is a keyword: ${keyword}. It truly is.`);
}); });
it.each(keywords)( it.each(keywords)(
@@ -456,7 +456,7 @@ class C13["With Città foreign language"]
`; `;
parser.parse(str); parser.parse(str);
expect(classDb.getNote(0).text).toEqual(`${keyword}`); expect(classDb.getNotes()[0].text).toEqual(`${keyword}`);
} }
); );

View File

@@ -8,7 +8,7 @@ import utils, { getEdgeId } from '../../utils.js';
import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; import { interpolateToCurve, getStylesFromArray } from '../../utils.js';
import { setupGraphViewbox } from '../../setupGraphViewbox.js'; import { setupGraphViewbox } from '../../setupGraphViewbox.js';
import common from '../common/common.js'; import common from '../common/common.js';
import type { ClassRelation, ClassMap, ClassNoteMap, NamespaceMap } from './classTypes.js'; import type { ClassRelation, ClassNote, ClassMap, NamespaceMap } from './classTypes.js';
import type { EdgeData } from '../../types.js'; import type { EdgeData } from '../../types.js';
const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig()); const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
@@ -65,9 +65,6 @@ export const addNamespaces = function (
g.setNode(vertex.id, node); g.setNode(vertex.id, node);
addClasses(vertex.classes, g, _id, diagObj, vertex.id); addClasses(vertex.classes, g, _id, diagObj, vertex.id);
const classes: ClassMap = diagObj.db.getClasses();
const relations: ClassRelation[] = diagObj.db.getRelations();
addNotes(vertex.notes, g, relations.length + 1, classes, vertex.id);
log.info('setNode', node); log.info('setNode', node);
}); });
@@ -147,74 +144,69 @@ export const addClasses = function (
* @param classes - Classes * @param classes - Classes
*/ */
export const addNotes = function ( export const addNotes = function (
notes: ClassNoteMap, notes: ClassNote[],
g: graphlib.Graph, g: graphlib.Graph,
startEdgeId: number, startEdgeId: number,
classes: ClassMap, classes: ClassMap
parent?: string
) { ) {
log.info(notes); log.info(notes);
[...notes.values()] notes.forEach(function (note, i) {
.filter((note) => note.parent === parent) const vertex = note;
.forEach(function (vertex) {
const cssNoteStr = '';
const styles = { labelStyle: '', style: '' }; const cssNoteStr = '';
const vertexText = vertex.text; const styles = { labelStyle: '', style: '' };
const radius = 0; const vertexText = vertex.text;
const shape = 'note';
const node = {
labelStyle: styles.labelStyle,
shape: shape,
labelText: sanitizeText(vertexText),
noteData: vertex,
rx: radius,
ry: radius,
class: cssNoteStr,
style: styles.style,
id: vertex.id,
domId: vertex.id,
tooltip: '',
type: 'note',
// TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
padding: getConfig().flowchart?.padding ?? getConfig().class?.padding,
};
g.setNode(vertex.id, node);
log.info('setNode', node);
if (parent) { const radius = 0;
g.setParent(vertex.id, parent); const shape = 'note';
} const node = {
labelStyle: styles.labelStyle,
shape: shape,
labelText: sanitizeText(vertexText),
noteData: vertex,
rx: radius,
ry: radius,
class: cssNoteStr,
style: styles.style,
id: vertex.id,
domId: vertex.id,
tooltip: '',
type: 'note',
// TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
padding: getConfig().flowchart?.padding ?? getConfig().class?.padding,
};
g.setNode(vertex.id, node);
log.info('setNode', node);
if (!vertex.class || !classes.has(vertex.class)) { if (!vertex.class || !classes.has(vertex.class)) {
return; return;
} }
const edgeId = startEdgeId + vertex.index; const edgeId = startEdgeId + i;
const edgeData: EdgeData = { const edgeData: EdgeData = {
id: `edgeNote${edgeId}`, id: `edgeNote${edgeId}`,
//Set relationship style and line type //Set relationship style and line type
classes: 'relation', classes: 'relation',
pattern: 'dotted', pattern: 'dotted',
// Set link type for rendering // Set link type for rendering
arrowhead: 'none', arrowhead: 'none',
//Set edge extra labels //Set edge extra labels
startLabelRight: '', startLabelRight: '',
endLabelLeft: '', endLabelLeft: '',
//Set relation arrow types //Set relation arrow types
arrowTypeStart: 'none', arrowTypeStart: 'none',
arrowTypeEnd: 'none', arrowTypeEnd: 'none',
style: 'fill:none', style: 'fill:none',
labelStyle: '', labelStyle: '',
curve: interpolateToCurve(conf.curve, curveLinear), curve: interpolateToCurve(conf.curve, curveLinear),
}; };
// Add the edge to the graph // Add the edge to the graph
g.setEdge(vertex.id, vertex.class, edgeData, edgeId); g.setEdge(vertex.id, vertex.class, edgeData, edgeId);
}); });
}; };
/** /**
@@ -337,7 +329,7 @@ export const draw = async function (text: string, id: string, _version: string,
const namespaces: NamespaceMap = diagObj.db.getNamespaces(); const namespaces: NamespaceMap = diagObj.db.getNamespaces();
const classes: ClassMap = diagObj.db.getClasses(); const classes: ClassMap = diagObj.db.getClasses();
const relations: ClassRelation[] = diagObj.db.getRelations(); const relations: ClassRelation[] = diagObj.db.getRelations();
const notes: ClassNoteMap = diagObj.db.getNotes(); const notes: ClassNote[] = diagObj.db.getNotes();
log.info(relations); log.info(relations);
addNamespaces(namespaces, g, id, diagObj); addNamespaces(namespaces, g, id, diagObj);
addClasses(classes, g, id, diagObj); addClasses(classes, g, id, diagObj);

View File

@@ -206,7 +206,7 @@ export const draw = function (text, id, _version, diagObj) {
); );
}); });
const notes = diagObj.db.getNotes().values(); const notes = diagObj.db.getNotes();
notes.forEach(function (note) { notes.forEach(function (note) {
log.debug(`Adding note: ${JSON.stringify(note)}`); log.debug(`Adding note: ${JSON.stringify(note)}`);
const node = svgDraw.drawNote(diagram, note, conf, diagObj); const node = svgDraw.drawNote(diagram, note, conf, diagObj);

View File

@@ -5,7 +5,7 @@ export interface ClassNode {
id: string; id: string;
type: string; type: string;
label: string; label: string;
shape: 'classBox'; shape: string;
text: string; text: string;
cssClasses: string; cssClasses: string;
methods: ClassMember[]; methods: ClassMember[];
@@ -149,8 +149,6 @@ export interface ClassNote {
id: string; id: string;
class: string; class: string;
text: string; text: string;
index: number;
parent?: string;
} }
export interface ClassRelation { export interface ClassRelation {
@@ -179,7 +177,6 @@ export interface NamespaceNode {
id: string; id: string;
domId: string; domId: string;
classes: ClassMap; classes: ClassMap;
notes: ClassNoteMap;
children: NamespaceMap; children: NamespaceMap;
} }
@@ -190,5 +187,4 @@ export interface StyleClass {
} }
export type ClassMap = Map<string, ClassNode>; export type ClassMap = Map<string, ClassNode>;
export type ClassNoteMap = Map<string, ClassNote>;
export type NamespaceMap = Map<string, NamespaceNode>; export type NamespaceMap = Map<string, NamespaceNode>;

View File

@@ -275,8 +275,8 @@ statement
; ;
namespaceStatement namespaceStatement
: namespaceIdentifier STRUCT_START classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $3[0], $3[1]); } : namespaceIdentifier STRUCT_START classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $3); }
| namespaceIdentifier STRUCT_START NEWLINE classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $4[0], $4[1]); } | namespaceIdentifier STRUCT_START NEWLINE classStatements STRUCT_STOP { yy.addClassesToNamespace($1, $4); }
; ;
namespaceIdentifier namespaceIdentifier
@@ -284,12 +284,9 @@ namespaceIdentifier
; ;
classStatements classStatements
: classStatement {$$=[[$1], []]} : classStatement {$$=[$1]}
| classStatement NEWLINE {$$=[[$1], []]} | classStatement NEWLINE {$$=[$1]}
| classStatement NEWLINE classStatements {$3[0].unshift($1); $$=$3} | classStatement NEWLINE classStatements {$3.unshift($1); $$=$3}
| noteStatement {$$=[[], [$1]]}
| noteStatement NEWLINE {$$=[[], [$1]]}
| noteStatement NEWLINE classStatements {$3[1].unshift($1); $$=$3}
; ;
classStatement classStatement
@@ -336,8 +333,8 @@ relationStatement
; ;
noteStatement noteStatement
: NOTE_FOR className noteText { $$ = yy.addNote($3, $2); } : NOTE_FOR className noteText { yy.addNote($3, $2); }
| NOTE noteText { $$ = yy.addNote($2); } | NOTE noteText { yy.addNote($2); }
; ;
classDefStatement classDefStatement

View File

@@ -333,7 +333,7 @@ const renderKatexUnsanitized = async (text: string, config: MermaidConfig): Prom
return text.replace(katexRegex, 'MathML is unsupported in this environment.'); return text.replace(katexRegex, 'MathML is unsupported in this environment.');
} }
if (injected.includeLargeFeatures) { if (includeLargeFeatures) {
const { default: katex } = await import('katex'); const { default: katex } = await import('katex');
const outputMode = const outputMode =
config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML) config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML)

View File

@@ -144,6 +144,18 @@ describe('when parsing directions', function () {
expect(data4Layout.nodes[0].shape).toEqual('rounded'); expect(data4Layout.nodes[0].shape).toEqual('rounded');
expect(data4Layout.nodes[0].label).toEqual('DD'); expect(data4Layout.nodes[0].label).toEqual('DD');
}); });
it('should handle mathematical formulas with backslashes in quoted strings', function () {
/* eslint-disable no-useless-escape */
const res = flow.parser.parse(`flowchart RL
H@{ shape: rect, label: "$$\sin x$$"}`);
/* eslint-enable no-useless-escape */
const data4Layout = flow.parser.yy.getData();
expect(data4Layout.nodes.length).toBe(1);
expect(data4Layout.nodes[0].shape).toEqual('rect');
expect(data4Layout.nodes[0].label).toEqual('$$sin x$$');
});
it('should be possible to link to a node with more data', function () { it('should be possible to link to a node with more data', function () {
const res = flow.parser.parse(`flowchart TB const res = flow.parser.parse(`flowchart TB
A --> D@{ A --> D@{

View File

@@ -53,6 +53,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multilin
// console.log('shapeData', yytext); // console.log('shapeData', yytext);
const re = /\n\s*/g; const re = /\n\s*/g;
yytext = yytext.replace(re,"<br/>"); yytext = yytext.replace(re,"<br/>");
yytext = yytext.replace(/\\/g, "\\\\");
return 'SHAPE_DATA'} return 'SHAPE_DATA'}
<shapeData>[^}^"]+ { <shapeData>[^}^"]+ {
// console.log('shapeData', yytext); // console.log('shapeData', yytext);

View File

@@ -1,7 +1,8 @@
import type { InfoFields, InfoDB } from './infoTypes.js'; import type { InfoFields, InfoDB } from './infoTypes.js';
import packageJson from '../../../package.json' assert { type: 'json' };
export const DEFAULT_INFO_DB: InfoFields = { export const DEFAULT_INFO_DB: InfoFields = {
version: injected.version + (injected.includeLargeFeatures ? '' : '-tiny'), version: packageJson.version + (includeLargeFeatures ? '' : '-tiny'),
} as const; } as const;
export const getVersion = (): string => DEFAULT_INFO_DB.version; export const getVersion = (): string => DEFAULT_INFO_DB.version;

View File

@@ -16,7 +16,7 @@ const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
const svgWidth = bitWidth * bitsPerRow + 2; const svgWidth = bitWidth * bitsPerRow + 2;
const svg: SVG = selectSvgElement(id); const svg: SVG = selectSvgElement(id);
svg.attr('viewBox', `0 0 ${svgWidth} ${svgHeight}`); svg.attr('viewbox', `0 0 ${svgWidth} ${svgHeight}`);
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth); configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
for (const [word, packet] of words.entries()) { for (const [word, packet] of words.entries()) {

View File

@@ -2,7 +2,6 @@ import type { Diagram } from '../../Diagram.js';
import type { RadarDiagramConfig } from '../../config.type.js'; import type { RadarDiagramConfig } from '../../config.type.js';
import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js'; import type { DiagramRenderer, DrawDefinition, SVG, SVGGroup } from '../../diagram-api/types.js';
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js'; import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
import { configureSvgSize } from '../../setupGraphViewbox.js';
import type { RadarDB, RadarAxis, RadarCurve } from './types.js'; import type { RadarDB, RadarAxis, RadarCurve } from './types.js';
const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => { const draw: DrawDefinition = (_text, id, _version, diagram: Diagram) => {
@@ -54,9 +53,11 @@ const drawFrame = (svg: SVG, config: Required<RadarDiagramConfig>): SVGGroup =>
x: config.marginLeft + config.width / 2, x: config.marginLeft + config.width / 2,
y: config.marginTop + config.height / 2, y: config.marginTop + config.height / 2,
}; };
configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth ?? true); // Initialize the SVG
svg
svg.attr('viewBox', `0 0 ${totalWidth} ${totalHeight}`); .attr('viewbox', `0 0 ${totalWidth} ${totalHeight}`)
.attr('width', totalWidth)
.attr('height', totalHeight);
// g element to center the radar chart // g element to center the radar chart
return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`); return svg.append('g').attr('transform', `translate(${center.x}, ${center.y})`);
}; };

View File

@@ -1,6 +1,6 @@
import type { MarkdownOptions } from 'vitepress'; import type { MarkdownOptions } from 'vitepress';
import { defineConfig } from 'vitepress'; import { defineConfig } from 'vitepress';
import packageJson from '../../../package.json' with { type: 'json' }; import packageJson from '../../../package.json' assert { type: 'json' };
import { addCanonicalUrls } from './canonical-urls.js'; import { addCanonicalUrls } from './canonical-urls.js';
import MermaidExample from './mermaid-markdown-all.js'; import MermaidExample from './mermaid-markdown-all.js';

View File

@@ -52,8 +52,6 @@ To add an integration to this list, see the [Integrations - create page](./integ
- [GitHub Writer](https://github.com/ckeditor/github-writer) - [GitHub Writer](https://github.com/ckeditor/github-writer)
- [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator) - [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator)
- [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅ - [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅
- [GNU Octave](https://octave.org/) ✅
- [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅
- [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid) - [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid)
- [MonsterWriter](https://www.monsterwriter.com/) ✅ - [MonsterWriter](https://www.monsterwriter.com/) ✅
- [Joplin](https://joplinapp.org) ✅ - [Joplin](https://joplinapp.org) ✅
@@ -269,7 +267,6 @@ Communication tools and platforms
- [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin) - [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin)
- [Reveal CK](https://github.com/jedcn/reveal-ck) - [Reveal CK](https://github.com/jedcn/reveal-ck)
- [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin)
- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts)
- [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer) - [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer)
<!--- cspell:ignore Blazorade HueHive ---> <!--- cspell:ignore Blazorade HueHive --->

View File

@@ -41,7 +41,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
## Plans ## Plans
- **Free** - A free plan that includes six diagrams. - **Free** - A free plan that includes three diagrams.
- **Pro** - A paid plan that includes unlimited diagrams, access to the collaboration feature, and more. - **Pro** - A paid plan that includes unlimited diagrams, access to the collaboration feature, and more.

View File

@@ -21,18 +21,18 @@
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"jiti": "^2.4.2", "jiti": "^2.4.2",
"mermaid": "workspace:^", "mermaid": "workspace:^",
"vue": "^3.5.23" "vue": "^3.5.21"
}, },
"devDependencies": { "devDependencies": {
"@iconify-json/carbon": "^1.2.14", "@iconify-json/carbon": "^1.2.13",
"@unocss/reset": "^66.5.4", "@unocss/reset": "^66.5.1",
"@vite-pwa/vitepress": "^1.0.1", "@vite-pwa/vitepress": "^1.0.0",
"@vitejs/plugin-vue": "^6.0.1", "@vitejs/plugin-vue": "^6.0.1",
"fast-glob": "^3.3.3", "fast-glob": "^3.3.3",
"https-localhost": "^4.7.1", "https-localhost": "^4.7.1",
"pathe": "^2.0.3", "pathe": "^2.0.3",
"unocss": "^66.5.4", "unocss": "^66.5.1",
"unplugin-vue-components": "^28.8.0", "unplugin-vue-components": "^28.4.1",
"vite": "^7.0.7", "vite": "^7.0.7",
"vite-plugin-pwa": "^1.0.3", "vite-plugin-pwa": "^1.0.3",
"vitepress": "1.6.4", "vitepress": "1.6.4",

View File

@@ -7,6 +7,7 @@ import { select } from 'd3';
import { compile, serialize, stringify } from 'stylis'; import { compile, serialize, stringify } from 'stylis';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import isEmpty from 'lodash-es/isEmpty.js'; import isEmpty from 'lodash-es/isEmpty.js';
import packageJson from '../package.json' assert { type: 'json' };
import { addSVGa11yTitleDescription, setA11yDiagramInfo } from './accessibility.js'; import { addSVGa11yTitleDescription, setA11yDiagramInfo } from './accessibility.js';
import assignWithDepth from './assignWithDepth.js'; import assignWithDepth from './assignWithDepth.js';
import * as configApi from './config.js'; import * as configApi from './config.js';
@@ -420,12 +421,12 @@ const render = async function (
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
// Draw the diagram with the renderer // Draw the diagram with the renderer
try { try {
await diag.renderer.draw(text, id, injected.version, diag); await diag.renderer.draw(text, id, packageJson.version, diag);
} catch (e) { } catch (e) {
if (config.suppressErrorRendering) { if (config.suppressErrorRendering) {
removeTempElements(); removeTempElements();
} else { } else {
errorRenderer.draw(text, id, injected.version); errorRenderer.draw(text, id, packageJson.version);
} }
throw e; throw e;
} }

View File

@@ -42,7 +42,7 @@ const registerDefaultLayoutLoaders = () => {
name: 'dagre', name: 'dagre',
loader: async () => await import('./layout-algorithms/dagre/index.js'), loader: async () => await import('./layout-algorithms/dagre/index.js'),
}, },
...(injected.includeLargeFeatures ...(includeLargeFeatures
? [ ? [
{ {
name: 'cose-bilkent', name: 'cose-bilkent',

View File

@@ -1,5 +1,2 @@
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
declare var injected: { declare var includeLargeFeatures: boolean;
version: string;
includeLargeFeatures: boolean;
};

View File

@@ -1,15 +1,5 @@
# @mermaid-js/parser # @mermaid-js/parser
## 0.6.3
### Patch Changes
- [#7051](https://github.com/mermaid-js/mermaid/pull/7051) [`63df702`](https://github.com/mermaid-js/mermaid/commit/63df7021462e8dc1f2aaecb9c5febbbbde4c38e3) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - Add validation for negative values in pie charts:
Prevents crashes during parsing by validating values post-parsing.
Provides clearer, user-friendly error messages for invalid negative inputs.
## 0.6.2 ## 0.6.2
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mermaid-js/parser", "name": "@mermaid-js/parser",
"version": "0.6.3", "version": "0.6.2",
"description": "MermaidJS parser", "description": "MermaidJS parser",
"author": "Yokozuna59", "author": "Yokozuna59",
"contributors": [ "contributors": [

View File

@@ -20,11 +20,11 @@ fragment Statement:
; ;
fragment LeftPort: fragment LeftPort:
':' lhsDir=ID ':'lhsDir=ARROW_DIRECTION
; ;
fragment RightPort: fragment RightPort:
rhsDir=ID ':' rhsDir=ARROW_DIRECTION':'
; ;
fragment Arrow: fragment Arrow:
@@ -47,5 +47,6 @@ Edge:
lhsId=ID lhsGroup?=ARROW_GROUP? Arrow rhsId=ID rhsGroup?=ARROW_GROUP? EOL lhsId=ID lhsGroup?=ARROW_GROUP? Arrow rhsId=ID rhsGroup?=ARROW_GROUP? EOL
; ;
terminal ARROW_DIRECTION: 'L' | 'R' | 'T' | 'B';
terminal ARROW_GROUP: /\{group\}/; terminal ARROW_GROUP: /\{group\}/;
terminal ARROW_INTO: /<|>/; terminal ARROW_INTO: /<|>/;

View File

@@ -19,64 +19,6 @@ describe('architecture', () => {
}); });
}); });
describe('should handle services', () => {
it('should handle service with icon', () => {
const context = `architecture-beta
service TH(disk)
`;
const result = parse(context);
expectNoErrorsOrAlternatives(result);
expect(result.value.$type).toBe(Architecture);
expect(result.value.services).toHaveLength(1);
expect(result.value.services?.[0].id).toBe('TH');
expect(result.value.services?.[0].icon).toBe('disk');
});
it('should handle service with icon starting with arrow direction letters', () => {
const context = `architecture-beta
service T(disk)
service TH(database)
service L(server)
service R(cloud)
service B(internet)
service TOP(disk)
service LEFT(disk)
service RIGHT(disk)
service BOTTOM(disk)
`;
const result = parse(context);
expectNoErrorsOrAlternatives(result);
expect(result.value.$type).toBe(Architecture);
expect(result.value.services).toHaveLength(9);
});
it('should handle service with icon and title', () => {
const context = `architecture-beta
service db(database)[Database]
`;
const result = parse(context);
expectNoErrorsOrAlternatives(result);
expect(result.value.$type).toBe(Architecture);
expect(result.value.services).toHaveLength(1);
expect(result.value.services?.[0].id).toBe('db');
expect(result.value.services?.[0].icon).toBe('database');
expect(result.value.services?.[0].title).toBe('Database');
});
it('should handle service in a group', () => {
const context = `architecture-beta
group api(cloud)[API]
service db(database)[Database] in api
`;
const result = parse(context);
expectNoErrorsOrAlternatives(result);
expect(result.value.$type).toBe(Architecture);
expect(result.value.services).toHaveLength(1);
expect(result.value.services?.[0].id).toBe('db');
expect(result.value.services?.[0].in).toBe('api');
});
});
describe('should handle TitleAndAccessibilities', () => { describe('should handle TitleAndAccessibilities', () => {
it.each([ it.each([
`architecture-beta title sample title`, `architecture-beta title sample title`,

View File

@@ -1,30 +1,5 @@
# mermaid # mermaid
## 11.12.1
### Patch Changes
- [#7107](https://github.com/mermaid-js/mermaid/pull/7107) [`cbf8946`](https://github.com/mermaid-js/mermaid/commit/cbf89462acecac7a06f19843e8d48cb137df0753) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - fix: Updated the dependency dagre-d3-es to 7.0.13 to fix GHSA-cc8p-78qf-8p7q
## 11.12.0
### Minor Changes
- [#6921](https://github.com/mermaid-js/mermaid/pull/6921) [`764b315`](https://github.com/mermaid-js/mermaid/commit/764b315dc16d0359add7c6b8e3ef7592e9bdc09c) Thanks [@quilicicf](https://github.com/quilicicf)! - feat: Add IDs in architecture diagrams
### Patch Changes
- [#6950](https://github.com/mermaid-js/mermaid/pull/6950) [`a957908`](https://github.com/mermaid-js/mermaid/commit/a9579083bfba367a4f4678547ec37ed7b61b9f5b) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - chore: Fix mindmap rendering in docs and apply tidytree layout
- [#6826](https://github.com/mermaid-js/mermaid/pull/6826) [`1d36810`](https://github.com/mermaid-js/mermaid/commit/1d3681053b9168354e48e5763023b6305cd1ca72) Thanks [@darshanr0107](https://github.com/darshanr0107)! - fix: Ensure edge label color is applied when using classDef with edge IDs
- [#6945](https://github.com/mermaid-js/mermaid/pull/6945) [`d318f1a`](https://github.com/mermaid-js/mermaid/commit/d318f1a13cd7429334a29c70e449074ec1cb9f68) Thanks [@darshanr0107](https://github.com/darshanr0107)! - fix: Resolve gantt chart crash due to invalid array length
- [#6918](https://github.com/mermaid-js/mermaid/pull/6918) [`cfe9238`](https://github.com/mermaid-js/mermaid/commit/cfe9238882cbe95416db1feea3112456a71b6aaf) Thanks [@shubhamparikh2704](https://github.com/shubhamparikh2704)! - chore: revert marked dependency from ^15.0.7 to ^16.0.0
- Reverted marked package version to ^16.0.0 for better compatibility
- This is a dependency update that maintains API compatibility
- All tests pass with the updated version
## 11.11.0 ## 11.11.0
### Minor Changes ### Minor Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mermaid-js/tiny", "name": "@mermaid-js/tiny",
"version": "11.12.1", "version": "11.11.0",
"description": "Tiny version of mermaid", "description": "Tiny version of mermaid",
"type": "commonjs", "type": "commonjs",
"main": "./dist/mermaid.tiny.js", "main": "./dist/mermaid.tiny.js",

3292
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -35,8 +35,7 @@ export default defineConfig({
}, },
define: { define: {
// Needs to be string // Needs to be string
'injected.includeLargeFeatures': 'true', includeLargeFeatures: 'true',
'import.meta.vitest': 'undefined', 'import.meta.vitest': 'undefined',
packageVersion: "'0.0.0'",
}, },
}); });