mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
Compare commits
1 Commits
v9.2.1
...
sidv/mindm
Author | SHA1 | Date | |
---|---|---|---|
![]() |
87cdc03e84 |
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: 'Status: Triage, Type: Bug / Error'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Code Sample**
|
||||||
|
If applicable, add the code sample or a link to the [live editor](https://mermaid.live).
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
|
||||||
|
- Device: [e.g. iPhone6]
|
||||||
|
- OS: [e.g. iOS8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
69
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
69
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,69 +0,0 @@
|
|||||||
name: Bug Report
|
|
||||||
description: Create a report to help us improve
|
|
||||||
labels:
|
|
||||||
- 'Status: Triage'
|
|
||||||
- 'Type: Bug / Error'
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |-
|
|
||||||
## Security vulnerabilities
|
|
||||||
Please refer our [Security Policy](https://github.com/mermaid-js/.github/blob/main/SECURITY.md) and report to keep vulnerabilities confidential so we can release fixes first.
|
|
||||||
|
|
||||||
## Before you submit...
|
|
||||||
We like to help you, but in order to do that should you make a few things first:
|
|
||||||
|
|
||||||
- Use a clear and concise title
|
|
||||||
- Fill out the text fields with as much detail as possible.
|
|
||||||
- Never be shy to give us screenshots and/or code samples. It will help!
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Description
|
|
||||||
description: Give a clear and concise description of what the bug is.
|
|
||||||
placeholder: When I do ... does ... happen.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: Give a step-by-step example on how to reproduce the bug.
|
|
||||||
placeholder: |-
|
|
||||||
1. Do this
|
|
||||||
2. Do that
|
|
||||||
3. ...
|
|
||||||
4. Bug!
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Screenshots
|
|
||||||
description: If applicable, add screenshots to help explain your issue.
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Code Sample
|
|
||||||
description: |-
|
|
||||||
If applicable, add the code sample or a link to the [Live Editor](https://mermaid.live).
|
|
||||||
Any text pasted here will be rendered as a Code block.
|
|
||||||
render: text
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Setup
|
|
||||||
description: |-
|
|
||||||
Please fill out the below info.
|
|
||||||
Note that you only need to fill out one and not both sections.
|
|
||||||
value: |-
|
|
||||||
**Desktop**
|
|
||||||
|
|
||||||
- OS and Version: [Windows, Linux, Mac, ...]
|
|
||||||
- Browser and Version: [Chrome, Edge, Firefox]
|
|
||||||
|
|
||||||
**Smartphone**
|
|
||||||
|
|
||||||
- Device: [Samsung, iPhone, ...]
|
|
||||||
- OS and Version: [Android, iOS, ...]
|
|
||||||
- Browser and Version: [Chrome, Safari, ...]
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional Context
|
|
||||||
description: Anything else to add?
|
|
17
.github/ISSUE_TEMPLATE/config.yml
vendored
17
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,17 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: GitHub Discussions
|
|
||||||
url: https://github.com/mermaid-js/mermaid/discussions
|
|
||||||
about: Ask the Community questions or share your own graphs in our discussions.
|
|
||||||
- name: Security Vulnerability
|
|
||||||
url: https://github.com/mermaid-js/.github/blob/main/SECURITY.md
|
|
||||||
about: Report security issues confidentially.
|
|
||||||
- name: Slack
|
|
||||||
url: https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE
|
|
||||||
about: Join our Community on Slack for Help and a casual chat.
|
|
||||||
- name: Documentation
|
|
||||||
url: https://mermaid-js.github.io
|
|
||||||
about: Read our documentation for all that Mermaid.js can offer.
|
|
||||||
- name: Live Editor
|
|
||||||
url: https://mermaid.live
|
|
||||||
about: Try the live editor to preview graphs in no time.
|
|
42
.github/ISSUE_TEMPLATE/diagram_proposal.yml
vendored
42
.github/ISSUE_TEMPLATE/diagram_proposal.yml
vendored
@@ -1,42 +0,0 @@
|
|||||||
name: Diagram Proposal
|
|
||||||
description: Suggest a new Diagram Type to add to Mermaid.
|
|
||||||
labels:
|
|
||||||
- 'Status: Triage'
|
|
||||||
- 'Type: Enhancement'
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |-
|
|
||||||
## Before you submit...
|
|
||||||
First of all, thank you for proposing a new Diagram to us.
|
|
||||||
We are always happy about new ideas to improve Mermaid.js wherever possible.
|
|
||||||
|
|
||||||
To get the fastest and best response possible, make sure you do the following:
|
|
||||||
|
|
||||||
- Use a clear and concise title
|
|
||||||
- Fill out the text fields with as much detail as possible.
|
|
||||||
- Never be shy to give us screenshots and/or code samples. It will help!
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Proposal
|
|
||||||
description: A clear and concise description of what should be added to Mermaid.js.
|
|
||||||
placeholder: Mermaid.js should add ... because ...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Use Cases
|
|
||||||
description: If applicable, give some use cases for where this diagram would be useful.
|
|
||||||
placeholder: The Diagram could be used for ...
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Screenshots
|
|
||||||
description: If applicable, add screenshots to show possible examples of how the diagram may look like.
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Code Sample
|
|
||||||
description: |-
|
|
||||||
If applicable, add a code sample for how to implement this new diagram.
|
|
||||||
The text will automatically be rendered as JavaScript code.
|
|
||||||
render: javascript
|
|
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: 'Status: Triage, Type: Enhancement'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
16
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: Question
|
||||||
|
about: Get some help from the community.
|
||||||
|
title: ''
|
||||||
|
labels: 'Help wanted!, Type: Other'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## Help us help you!
|
||||||
|
|
||||||
|
You want an answer. Here are some ways to get it quicker:
|
||||||
|
|
||||||
|
- Use a clear and concise title.
|
||||||
|
- Try to pose a clear and concise question.
|
||||||
|
- Include as much, or as little, code as necessary.
|
||||||
|
- Don't be shy to give us some screenshots, if it helps!
|
34
.github/ISSUE_TEMPLATE/syntax_proposal.yml
vendored
34
.github/ISSUE_TEMPLATE/syntax_proposal.yml
vendored
@@ -1,34 +0,0 @@
|
|||||||
name: Syntax Proposal
|
|
||||||
description: Suggest a new Syntax to add to Mermaid.js.
|
|
||||||
labels:
|
|
||||||
- 'Status: Triage'
|
|
||||||
- 'Type: Enhancement'
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |-
|
|
||||||
## Before you submit...
|
|
||||||
First of all, thank you for proposing a new Syntax to us.
|
|
||||||
We are always happy about new ideas to improve Mermaid.js wherever possible.
|
|
||||||
|
|
||||||
To get the fastest and best response possible, make sure you do the following:
|
|
||||||
|
|
||||||
- Use a clear and concise title
|
|
||||||
- Fill out the text fields with as much detail as possible. Examples are always welcome.
|
|
||||||
- Never be shy to give us screenshots and/or code samples. It will help!
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Proposal
|
|
||||||
description: A clear and concise description of what Syntax should be added to Mermaid.js.
|
|
||||||
placeholder: Mermaid.js should add ... because ...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Example
|
|
||||||
description: If applicable, provide an example of the new Syntax.
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Screenshots
|
|
||||||
description: If applicable, add screenshots to show possible examples of how the theme may look like.
|
|
42
.github/ISSUE_TEMPLATE/theme_proposal.yml
vendored
42
.github/ISSUE_TEMPLATE/theme_proposal.yml
vendored
@@ -1,42 +0,0 @@
|
|||||||
name: Theme Proposal
|
|
||||||
description: Suggest a new theme to add to Mermaid.js.
|
|
||||||
labels:
|
|
||||||
- 'Status: Triage'
|
|
||||||
- 'Type: Enhancement'
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |-
|
|
||||||
## Before you submit...
|
|
||||||
First of all, thank you for proposing a new Theme to us.
|
|
||||||
We are always happy about new ideas to improve Mermaid.js wherever possible.
|
|
||||||
|
|
||||||
To get the fastest and best response possible, make sure you do the following:
|
|
||||||
|
|
||||||
- Use a clear and concise title
|
|
||||||
- Fill out the text fields with as much detail as possible. Examples are always welcome!
|
|
||||||
- Never be shy to give us screenshots and/or code samples. It will help!
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Proposal
|
|
||||||
description: A clear and concise description of what theme should be added to Mermaid.js.
|
|
||||||
placeholder: Mermaid.js should add ... because ...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Colors
|
|
||||||
description: |-
|
|
||||||
A detailed list of the different colour values to use.
|
|
||||||
A list of currently used variable names can be found [here](https://mermaid-js.github.io/mermaid/#/theming?id=theme-variables-reference-table)
|
|
||||||
placeholder: |-
|
|
||||||
- background: #f4f4f4
|
|
||||||
- primaryColor: #fff4dd
|
|
||||||
- ...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Screenshots
|
|
||||||
description: If applicable, add screenshots to show possible examples of how the theme may look like.
|
|
@@ -1,15 +1,7 @@
|
|||||||
import express, { NextFunction, Request, Response } from 'express';
|
import express from 'express';
|
||||||
import { createServer as createViteServer } from 'vite';
|
import { createServer as createViteServer } from 'vite';
|
||||||
// import { getBuildConfig } from './build';
|
// import { getBuildConfig } from './build';
|
||||||
|
|
||||||
const cors = (req: Request, res: Response, next: NextFunction) => {
|
|
||||||
res.header('Access-Control-Allow-Origin', '*');
|
|
||||||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
|
||||||
res.header('Access-Control-Allow-Headers', 'Content-Type');
|
|
||||||
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
|
|
||||||
async function createServer() {
|
async function createServer() {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -20,7 +12,6 @@ async function createServer() {
|
|||||||
appType: 'custom', // don't include Vite's default HTML handling middlewares
|
appType: 'custom', // don't include Vite's default HTML handling middlewares
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(cors);
|
|
||||||
app.use(express.static('./packages/mermaid/dist'));
|
app.use(express.static('./packages/mermaid/dist'));
|
||||||
app.use(express.static('./packages/mermaid-example-diagram/dist'));
|
app.use(express.static('./packages/mermaid-example-diagram/dist'));
|
||||||
app.use(express.static('./packages/mermaid-mindmap/dist'));
|
app.use(express.static('./packages/mermaid-mindmap/dist'));
|
||||||
|
@@ -15,5 +15,5 @@ module.exports = defineConfig({
|
|||||||
// { deviceName: 'Pixel 2', screenOrientation: 'portrait' },
|
// { deviceName: 'Pixel 2', screenOrientation: 'portrait' },
|
||||||
],
|
],
|
||||||
// set batch name to the configuration
|
// set batch name to the configuration
|
||||||
// batchName: `Mermaid ${process.env.APPLI_BRANCH ?? "'no APPLI_BRANCH set'"}`,
|
batchName: `Mermaid ${process.env.APPLI_BRANCH ?? "'no APPLI_BRANCH set'"}`,
|
||||||
});
|
});
|
||||||
|
@@ -2,8 +2,6 @@ const utf8ToB64 = (str) => {
|
|||||||
return window.btoa(unescape(encodeURIComponent(str)));
|
return window.btoa(unescape(encodeURIComponent(str)));
|
||||||
};
|
};
|
||||||
|
|
||||||
const batchId = 'mermid-batch' + new Date().getTime();
|
|
||||||
|
|
||||||
export const mermaidUrl = (graphStr, options, api) => {
|
export const mermaidUrl = (graphStr, options, api) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
code: graphStr,
|
code: graphStr,
|
||||||
@@ -52,12 +50,9 @@ export const imgSnapshotTest = (graphStr, _options, api = false, validation) =>
|
|||||||
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
|
||||||
if (useAppli) {
|
if (useAppli) {
|
||||||
cy.log('Opening eyes ' + Cypress.spec.name + ' --- ' + name);
|
|
||||||
cy.eyesOpen({
|
cy.eyesOpen({
|
||||||
appName: 'Mermaid',
|
appName: 'Mermaid',
|
||||||
testName: name,
|
testName: name,
|
||||||
batchName: Cypress.spec.name,
|
|
||||||
batchId: batchId + Cypress.spec.name,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,9 +64,7 @@ export const imgSnapshotTest = (graphStr, _options, api = false, validation) =>
|
|||||||
// Default name to test title
|
// Default name to test title
|
||||||
|
|
||||||
if (useAppli) {
|
if (useAppli) {
|
||||||
cy.log('Check eyes' + Cypress.spec.name);
|
|
||||||
cy.eyesCheckWindow('Click!');
|
cy.eyesCheckWindow('Click!');
|
||||||
cy.log('Closing eyes: ' + Cypress.spec.name);
|
|
||||||
cy.eyesClose();
|
cy.eyesClose();
|
||||||
} else {
|
} else {
|
||||||
cy.matchImageSnapshot(name);
|
cy.matchImageSnapshot(name);
|
||||||
@@ -107,12 +100,9 @@ export const urlSnapshotTest = (url, _options, api = false, validation) => {
|
|||||||
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
|
||||||
if (useAppli) {
|
if (useAppli) {
|
||||||
cy.log('Opening eyes 2' + Cypress.spec.name);
|
|
||||||
cy.eyesOpen({
|
cy.eyesOpen({
|
||||||
appName: 'Mermaid',
|
appName: 'Mermaid',
|
||||||
testName: name,
|
testName: name,
|
||||||
batchName: Cypress.spec.name,
|
|
||||||
batchId: batchId + Cypress.spec.name,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,9 +112,7 @@ export const urlSnapshotTest = (url, _options, api = false, validation) => {
|
|||||||
// Default name to test title
|
// Default name to test title
|
||||||
|
|
||||||
if (useAppli) {
|
if (useAppli) {
|
||||||
cy.log('Check eyes 2' + Cypress.spec.name);
|
|
||||||
cy.eyesCheckWindow('Click!');
|
cy.eyesCheckWindow('Click!');
|
||||||
cy.log('Closing eyes 2' + Cypress.spec.name);
|
|
||||||
cy.eyesClose();
|
cy.eyesClose();
|
||||||
} else {
|
} else {
|
||||||
cy.matchImageSnapshot(name);
|
cy.matchImageSnapshot(name);
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
// import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
// import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9.2.0/dist/mermaid.esm.min.mjs';
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc6/dist/mermaid.esm.min.mjs';
|
||||||
// import mermaid from 'http://localhost:9000/mermaid.esm.mjs';
|
// import mermaid from 'http://localhost:9000/mermaid.esm.mjs';
|
||||||
console.log(mermaid); // eslint-disable-line
|
console.log(mermaid); // eslint-disable-line
|
||||||
window.mermaid = mermaid;
|
window.mermaid = mermaid;
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
themeCSS: '.label { font-family: Source Sans Pro,Helvetica Neue,Arial,sans-serif; }',
|
themeCSS: '.label { font-family: Source Sans Pro,Helvetica Neue,Arial,sans-serif; }',
|
||||||
lazyLoadedDiagrams: [
|
lazyLoadedDiagrams: [
|
||||||
'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.2.0/dist/mermaid-mindmap-detector.esm.mjs',
|
'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.2.0-rc3/dist/mermaid-mindmap-detector.esm.mjs',
|
||||||
// 'http://localhost:9000/mermaid-mindmap-detector.esm.mjs',
|
// 'http://localhost:9000/mermaid-mindmap-detector.esm.mjs',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:mermaid": "ts-node-esm --transpileOnly --project=.vite/tsconfig.json .vite/build.ts --mermaid",
|
"build:mermaid": "ts-node-esm --transpileOnly --project=.vite/tsconfig.json .vite/build.ts --mermaid",
|
||||||
"build:vite": "ts-node-esm --transpileOnly --project=.vite/tsconfig.json .vite/build.ts",
|
"build:vite": "ts-node-esm --transpileOnly --project=.vite/tsconfig.json .vite/build.ts",
|
||||||
"build:types": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly",
|
"build:types": "concurrently \"tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly\" \"tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly\"",
|
||||||
"build:watch": "pnpm build:vite --watch",
|
"build:watch": "pnpm build:vite --watch",
|
||||||
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
|
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
|
||||||
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
|
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mermaid-js/mermaid-mindmap",
|
"name": "@mermaid-js/mermaid-mindmap",
|
||||||
"version": "9.2.0",
|
"version": "9.2.0-rc3",
|
||||||
"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.",
|
||||||
"main": "dist/mermaid-mindmap.core.mjs",
|
"main": "dist/mermaid-mindmap.core.mjs",
|
||||||
"module": "dist/mermaid-mindmap.core.mjs",
|
"module": "dist/mermaid-mindmap.core.mjs",
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import type { MermaidConfig } from 'mermaid';
|
import type { MermaidConfig } from 'mermaid/dist/config.type';
|
||||||
|
|
||||||
const warning = (s: string) => {
|
const warning = (s: string) => {
|
||||||
// Todo remove debug code
|
// Todo remove debug code
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/** Created by knut on 23-07-2022. */
|
/** Created by knut on 15-01-14. */
|
||||||
import { sanitizeText, getConfig, log } from './mermaidUtils';
|
import { sanitizeText, getConfig, log } from './mermaidUtils';
|
||||||
import type { DetailedError } from 'mermaid';
|
import type { DetailedError } from 'mermaid/dist/utils';
|
||||||
|
|
||||||
interface Node {
|
interface Node {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -17,9 +17,11 @@ interface Node {
|
|||||||
|
|
||||||
let nodes: Node[] = [];
|
let nodes: Node[] = [];
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
let elements: Record<number, HTMLElement> = {};
|
||||||
export const clear = () => {
|
export const clear = () => {
|
||||||
nodes = [];
|
nodes = [];
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
elements = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getParent = function (level: number) {
|
const getParent = function (level: number) {
|
||||||
@@ -105,6 +107,10 @@ export const getType = (startStr: string, endStr: string): number => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setElementForId = (id: number, element: HTMLElement) => {
|
||||||
|
elements[id] = element;
|
||||||
|
};
|
||||||
|
|
||||||
export const decorateNode = (decoration: { icon: string; class: string }) => {
|
export const decorateNode = (decoration: { icon: string; class: string }) => {
|
||||||
const node = nodes[nodes.length - 1];
|
const node = nodes[nodes.length - 1];
|
||||||
if (decoration && decoration.icon) {
|
if (decoration && decoration.icon) {
|
||||||
@@ -144,3 +150,5 @@ export const setErrorHandler = (handler: ParseErrorFunction) => {
|
|||||||
export const getLogger = () => log;
|
export const getLogger = () => log;
|
||||||
|
|
||||||
export const getNodeById = (id: number): Node => nodes[id];
|
export const getNodeById = (id: number): Node => nodes[id];
|
||||||
|
export const getElementById = (id: number | string): HTMLElement =>
|
||||||
|
elements[typeof id === 'string' ? parseInt(id) : id];
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
/** Created by knut on 23-07-2022. */
|
/** 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';
|
||||||
import svgDraw, { getElementById, clearElementRefs } from './svgDraw';
|
import svgDraw from './svgDraw';
|
||||||
import cytoscape from 'cytoscape';
|
import cytoscape from 'cytoscape';
|
||||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
import coseBilkent from 'cytoscape-cose-bilkent';
|
||||||
|
import * as db from './mindmapDb';
|
||||||
|
|
||||||
// Inject the layout algorithm into cytoscape
|
// Inject the layout algorithm into cytoscape
|
||||||
cytoscape.use(coseBilkent);
|
cytoscape.use(coseBilkent);
|
||||||
@@ -154,7 +155,7 @@ function positionNodes(cy) {
|
|||||||
data.x = node.position().x;
|
data.x = node.position().x;
|
||||||
data.y = node.position().y;
|
data.y = node.position().y;
|
||||||
svgDraw.positionNode(data);
|
svgDraw.positionNode(data);
|
||||||
const el = getElementById(data.nodeId);
|
const el = db.getElementById(data.nodeId);
|
||||||
log.info('Id:', id, 'Position: (', node.position().x, ', ', node.position().y, ')', data);
|
log.info('Id:', id, 'Position: (', node.position().x, ', ', node.position().y, ')', data);
|
||||||
el.attr(
|
el.attr(
|
||||||
'transform',
|
'transform',
|
||||||
@@ -178,7 +179,6 @@ export const draw = async (text, id, version, diagObj) => {
|
|||||||
|
|
||||||
// This is done only for throwing the error if the text is not valid.
|
// This is done only for throwing the error if the text is not valid.
|
||||||
diagObj.db.clear();
|
diagObj.db.clear();
|
||||||
clearElementRefs();
|
|
||||||
// Parse the graph definition
|
// Parse the graph definition
|
||||||
diagObj.parser.parse(text);
|
diagObj.parser.parse(text);
|
||||||
|
|
||||||
|
@@ -22,10 +22,12 @@ const genSections = (options) => {
|
|||||||
}
|
}
|
||||||
.section-${i - 1} text {
|
.section-${i - 1} text {
|
||||||
fill: ${options['cScaleLabel' + i]};
|
fill: ${options['cScaleLabel' + i]};
|
||||||
|
// fill: ${options['gitInv' + i]};
|
||||||
}
|
}
|
||||||
.node-icon-${i - 1} {
|
.node-icon-${i - 1} {
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
color: ${options['cScaleLabel' + i]};
|
color: ${options['cScaleLabel' + i]};
|
||||||
|
// color: ${options['gitInv' + i]};
|
||||||
}
|
}
|
||||||
.section-edge-${i - 1}{
|
.section-edge-${i - 1}{
|
||||||
stroke: ${options['cScale' + i]};
|
stroke: ${options['cScale' + i]};
|
||||||
@@ -34,7 +36,7 @@ const genSections = (options) => {
|
|||||||
stroke-width: ${sw};
|
stroke-width: ${sw};
|
||||||
}
|
}
|
||||||
.section-${i - 1} line {
|
.section-${i - 1} line {
|
||||||
stroke: ${options['cScaleInv' + i]} ;
|
stroke: ${options['lineColor' + i]} ;
|
||||||
stroke-width: 3;
|
stroke-width: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -259,7 +259,7 @@ export const drawNode = function (elem, node, fullSection, conf) {
|
|||||||
// if (typeof node.x !== 'undefined' && typeof node.y !== 'undefined') {
|
// if (typeof node.x !== 'undefined' && typeof node.y !== 'undefined') {
|
||||||
// nodeElem.attr('transform', 'translate(' + node.x + ',' + node.y + ')');
|
// nodeElem.attr('transform', 'translate(' + node.x + ',' + node.y + ')');
|
||||||
// }
|
// }
|
||||||
setElementById(node.id, nodeElem);
|
db.setElementForId(node.id, nodeElem);
|
||||||
return node.height;
|
return node.height;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ export const drawEdge = function drawEdge(edgesElem, mindmap, parent, depth, ful
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const positionNode = function (node) {
|
export const positionNode = function (node) {
|
||||||
const nodeElem = getElementById(node.id);
|
const nodeElem = db.getElementById(node.id);
|
||||||
|
|
||||||
const x = node.x || 0;
|
const x = node.x || 0;
|
||||||
const y = node.y || 0;
|
const y = node.y || 0;
|
||||||
@@ -294,18 +294,4 @@ export const positionNode = function (node) {
|
|||||||
nodeElem.attr('transform', 'translate(' + x + ',' + y + ')');
|
nodeElem.attr('transform', 'translate(' + x + ',' + y + ')');
|
||||||
};
|
};
|
||||||
|
|
||||||
let elements = {};
|
|
||||||
|
|
||||||
const setElementById = (id, element) => {
|
|
||||||
elements[id] = element;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getElementById = (id) => {
|
|
||||||
return elements[id];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const clearElementRefs = () => {
|
|
||||||
elements = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default { drawNode, positionNode, drawEdge };
|
export default { drawNode, positionNode, drawEdge };
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mermaid",
|
"name": "mermaid",
|
||||||
"version": "9.2.0",
|
"version": "9.2.0-rc6",
|
||||||
"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.",
|
||||||
"main": "./dist/mermaid.core.mjs",
|
"main": "./dist/mermaid.core.mjs",
|
||||||
"module": "./dist/mermaid.core.mjs",
|
"module": "./dist/mermaid.core.mjs",
|
||||||
|
@@ -25,7 +25,6 @@ function parse(text: string, parseError?: Function): boolean {
|
|||||||
// 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 = {
|
||||||
render: vi.fn(),
|
render: vi.fn(),
|
||||||
renderAsync: vi.fn(),
|
|
||||||
parse,
|
parse,
|
||||||
parseDirective: vi.fn(),
|
parseDirective: vi.fn(),
|
||||||
initialize: vi.fn(),
|
initialize: vi.fn(),
|
||||||
|
@@ -54,29 +54,6 @@ describe('when using mermaid and ', function () {
|
|||||||
expect(mermaidAPI.render).toHaveBeenCalled();
|
expect(mermaidAPI.render).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('when using #initThrowsErrorsAsync', function () {
|
|
||||||
it('should throw error (but still render) if lazyLoadedDiagram fails', async () => {
|
|
||||||
const node = document.createElement('div');
|
|
||||||
node.appendChild(document.createTextNode('graph TD;\na;'));
|
|
||||||
|
|
||||||
mermaidAPI.setConfig({
|
|
||||||
lazyLoadedDiagrams: ['this-file-does-not-exist.mjs'],
|
|
||||||
});
|
|
||||||
await expect(mermaid.initThrowsErrorsAsync(undefined, node)).rejects.toThrowError(
|
|
||||||
// this error message is probably different on every platform
|
|
||||||
// this one is just for vite-note (node/jest/browser may be different)
|
|
||||||
'Failed to load this-file-does-not-exist.mjs'
|
|
||||||
);
|
|
||||||
|
|
||||||
// should still render, even if lazyLoadedDiagrams fails
|
|
||||||
expect(mermaidAPI.renderAsync).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
// we modify mermaid config in some tests, so we need to make sure to reset them
|
|
||||||
mermaidAPI.reset();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checking validity of input ', function () {
|
describe('checking validity of input ', function () {
|
||||||
it('should throw for an invalid definition', function () {
|
it('should throw for an invalid definition', function () {
|
||||||
|
@@ -2,15 +2,14 @@
|
|||||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid
|
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid
|
||||||
* functionality and to render the diagrams to svg code!
|
* functionality and to render the diagrams to svg code!
|
||||||
*/
|
*/
|
||||||
import type { MermaidConfig } from './config.type';
|
import { MermaidConfig } from './config.type';
|
||||||
import { log } from './logger';
|
import { log } from './logger';
|
||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
import { mermaidAPI } from './mermaidAPI';
|
import { mermaidAPI } from './mermaidAPI';
|
||||||
import { addDetector } from './diagram-api/detectType';
|
import { addDetector } from './diagram-api/detectType';
|
||||||
import { isDetailedError, type DetailedError } from './utils';
|
import { isDetailedError } from './utils';
|
||||||
import { registerDiagram } from './diagram-api/diagramAPI';
|
import { registerDiagram } from './diagram-api/diagramAPI';
|
||||||
|
|
||||||
export type { MermaidConfig, DetailedError };
|
|
||||||
/**
|
/**
|
||||||
* ## init
|
* ## init
|
||||||
*
|
*
|
||||||
@@ -49,6 +48,7 @@ const init = async function (
|
|||||||
try {
|
try {
|
||||||
const conf = mermaidAPI.getConfig();
|
const conf = mermaidAPI.getConfig();
|
||||||
if (conf?.lazyLoadedDiagrams && conf.lazyLoadedDiagrams.length > 0) {
|
if (conf?.lazyLoadedDiagrams && conf.lazyLoadedDiagrams.length > 0) {
|
||||||
|
await registerLazyLoadedDiagrams(conf);
|
||||||
await initThrowsErrorsAsync(config, nodes, callback);
|
await initThrowsErrorsAsync(config, nodes, callback);
|
||||||
} else {
|
} else {
|
||||||
initThrowsErrors(config, nodes, callback);
|
initThrowsErrors(config, nodes, callback);
|
||||||
@@ -64,31 +64,6 @@ const init = async function (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
||||||
const handleError = (error: unknown, errors: DetailedError[], parseError?: Function) => {
|
|
||||||
log.warn(error);
|
|
||||||
if (isDetailedError(error)) {
|
|
||||||
// handle case where error string and hash were
|
|
||||||
// wrapped in object like`const error = { str, hash };`
|
|
||||||
if (parseError) {
|
|
||||||
parseError(error.str, error.hash);
|
|
||||||
}
|
|
||||||
errors.push({ ...error, message: error.str, error });
|
|
||||||
} else {
|
|
||||||
// assume it is just error string and pass it on
|
|
||||||
if (parseError) {
|
|
||||||
parseError(error);
|
|
||||||
}
|
|
||||||
if (error instanceof Error) {
|
|
||||||
errors.push({
|
|
||||||
str: error.message,
|
|
||||||
message: error.message,
|
|
||||||
hash: error.name,
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const initThrowsErrors = function (
|
const initThrowsErrors = function (
|
||||||
config?: MermaidConfig,
|
config?: MermaidConfig,
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
@@ -97,6 +72,7 @@ const initThrowsErrors = function (
|
|||||||
callback?: Function
|
callback?: Function
|
||||||
) {
|
) {
|
||||||
const conf = mermaidAPI.getConfig();
|
const conf = mermaidAPI.getConfig();
|
||||||
|
// console.log('Starting rendering diagrams (init) - mermaid.init', conf);
|
||||||
if (config) {
|
if (config) {
|
||||||
// This is a legacy way of setting config. It is not documented and should be removed in the future.
|
// This is a legacy way of setting config. It is not documented and should be removed in the future.
|
||||||
// @ts-ignore: TODO Fix ts errors
|
// @ts-ignore: TODO Fix ts errors
|
||||||
@@ -128,7 +104,7 @@ const initThrowsErrors = function (
|
|||||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||||
|
|
||||||
let txt: string;
|
let txt: string;
|
||||||
const errors: DetailedError[] = [];
|
const errors = [];
|
||||||
|
|
||||||
// element is the current div with mermaid class
|
// element is the current div with mermaid class
|
||||||
for (const element of Array.from(nodesToProcess)) {
|
for (const element of Array.from(nodesToProcess)) {
|
||||||
@@ -168,7 +144,13 @@ const initThrowsErrors = function (
|
|||||||
element
|
element
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, errors, mermaid.parseError);
|
log.warn('Catching Error (bootstrap)', error);
|
||||||
|
// @ts-ignore: TODO Fix ts errors
|
||||||
|
const mermaidError = { error, str: error.str, hash: error.hash, message: error.str };
|
||||||
|
if (typeof mermaid.parseError === 'function') {
|
||||||
|
mermaid.parseError(mermaidError);
|
||||||
|
}
|
||||||
|
errors.push(mermaidError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
@@ -177,12 +159,10 @@ const initThrowsErrors = function (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let lazyLoadingPromise: Promise<PromiseSettledResult<void>[]> | undefined = undefined;
|
let lazyLoadingPromise: Promise<unknown> | undefined = undefined;
|
||||||
/**
|
/**
|
||||||
* This is an internal function and should not be made public, as it will likely change.
|
* @param conf
|
||||||
* @internal
|
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||||
* @param conf - Mermaid config.
|
|
||||||
* @returns An array of {@link PromiseSettledResult}, showing the status of imports.
|
|
||||||
*/
|
*/
|
||||||
const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
||||||
// Only lazy load once
|
// Only lazy load once
|
||||||
@@ -196,7 +176,7 @@ const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return await lazyLoadingPromise;
|
await lazyLoadingPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
let loadingPromise: Promise<unknown> | undefined = undefined;
|
let loadingPromise: Promise<unknown> | undefined = undefined;
|
||||||
@@ -219,20 +199,9 @@ const loadExternalDiagrams = async (conf: MermaidConfig) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equivalent to {@link init()}, except an error will be thrown on error.
|
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||||
*
|
|
||||||
* @alpha
|
|
||||||
* @deprecated This is an internal function and will very likely be modified in v10, or earlier.
|
|
||||||
* We recommend staying with {@link initThrowsErrors} if you don't need `lazyLoadedDiagrams`.
|
|
||||||
*
|
|
||||||
* @param config - **Deprecated** Mermaid sequenceConfig.
|
|
||||||
* @param nodes - One of:
|
|
||||||
* - A DOM Node
|
|
||||||
* - An array of DOM nodes (as would come from a jQuery selector)
|
|
||||||
* - A W3C selector, a la `.mermaid` (default)
|
|
||||||
* @param callback - Function that is called with the id of each generated mermaid diagram.
|
|
||||||
* @returns Resolves on success, otherwise the {@link Promise} will be rejected.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const initThrowsErrorsAsync = async function (
|
const initThrowsErrorsAsync = async function (
|
||||||
config?: MermaidConfig,
|
config?: MermaidConfig,
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
@@ -241,14 +210,7 @@ const initThrowsErrorsAsync = async function (
|
|||||||
callback?: Function
|
callback?: Function
|
||||||
) {
|
) {
|
||||||
const conf = mermaidAPI.getConfig();
|
const conf = mermaidAPI.getConfig();
|
||||||
|
// console.log('Starting rendering diagrams (init) - mermaid.init', conf);
|
||||||
const registerLazyLoadedDiagramsErrors: Error[] = [];
|
|
||||||
for (const registerResult of await registerLazyLoadedDiagrams(conf)) {
|
|
||||||
if (registerResult.status == 'rejected') {
|
|
||||||
registerLazyLoadedDiagramsErrors.push(registerResult.reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
// This is a legacy way of setting config. It is not documented and should be removed in the future.
|
// This is a legacy way of setting config. It is not documented and should be removed in the future.
|
||||||
// @ts-ignore: TODO Fix ts errors
|
// @ts-ignore: TODO Fix ts errors
|
||||||
@@ -280,7 +242,7 @@ const initThrowsErrorsAsync = async function (
|
|||||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||||
|
|
||||||
let txt: string;
|
let txt: string;
|
||||||
const errors: DetailedError[] = [];
|
const errors = [];
|
||||||
|
|
||||||
// element is the current div with mermaid class
|
// element is the current div with mermaid class
|
||||||
for (const element of Array.from(nodesToProcess)) {
|
for (const element of Array.from(nodesToProcess)) {
|
||||||
@@ -320,13 +282,18 @@ const initThrowsErrorsAsync = async function (
|
|||||||
element
|
element
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, errors, mermaid.parseError);
|
log.warn('Catching Error (bootstrap)', error);
|
||||||
|
// @ts-ignore: TODO Fix ts errors
|
||||||
|
const mermaidError = { error, str: error.str, hash: error.hash, message: error.str };
|
||||||
|
if (typeof mermaid.parseError === 'function') {
|
||||||
|
mermaid.parseError(mermaidError);
|
||||||
|
}
|
||||||
|
errors.push(mermaidError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const allErrors = [...registerLazyLoadedDiagramsErrors, ...errors];
|
if (errors.length > 0) {
|
||||||
if (allErrors.length > 0) {
|
|
||||||
// TODO: We should be throwing an error object.
|
// TODO: We should be throwing an error object.
|
||||||
throw allErrors[0];
|
throw errors[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -390,123 +357,12 @@ const parse = (txt: string) => {
|
|||||||
return mermaidAPI.parse(txt, mermaid.parseError);
|
return mermaidAPI.parse(txt, mermaid.parseError);
|
||||||
};
|
};
|
||||||
|
|
||||||
const executionQueue: (() => Promise<unknown>)[] = [];
|
|
||||||
let executionQueueRunning = false;
|
|
||||||
const executeQueue = async () => {
|
|
||||||
if (executionQueueRunning) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
executionQueueRunning = true;
|
|
||||||
while (executionQueue.length > 0) {
|
|
||||||
const f = executionQueue.shift();
|
|
||||||
if (f) {
|
|
||||||
try {
|
|
||||||
await f();
|
|
||||||
} catch (e) {
|
|
||||||
log.error('Error executing queue', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
executionQueueRunning = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param txt
|
* @param txt
|
||||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||||
*/
|
*/
|
||||||
const parseAsync = (txt: string) => {
|
const parseAsync = (txt: string) => {
|
||||||
return new Promise((resolve, reject) => {
|
return mermaidAPI.parseAsync(txt, mermaid.parseError);
|
||||||
// This promise will resolve when the mermaidAPI.render call is done.
|
|
||||||
// It will be queued first and will be executed when it is first in line
|
|
||||||
const performCall = () =>
|
|
||||||
new Promise((res, rej) => {
|
|
||||||
mermaidAPI.parseAsync(txt, mermaid.parseError).then(
|
|
||||||
(r) => {
|
|
||||||
// This resolves for the promise for the queue handling
|
|
||||||
res(r);
|
|
||||||
// This fullfills the promise sent to the value back to the original caller
|
|
||||||
resolve(r);
|
|
||||||
},
|
|
||||||
(e) => {
|
|
||||||
log.error('Error parsing', e);
|
|
||||||
rej(e);
|
|
||||||
reject(e);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
executionQueue.push(performCall);
|
|
||||||
executeQueue();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// const asynco = (id: string, delay: number) =>
|
|
||||||
// new Promise((res) => {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// // This resolves for the promise for the queue handling
|
|
||||||
// res(id);
|
|
||||||
// }, delay);
|
|
||||||
// });
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param txt
|
|
||||||
* @param id
|
|
||||||
* @param delay
|
|
||||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
|
||||||
*/
|
|
||||||
// const test1 = (id: string, delay: number) => {
|
|
||||||
// const p = new Promise((resolve, reject) => {
|
|
||||||
// // This promise will resolve when the mermaidAPI.render call is done.
|
|
||||||
// // It will be queued first and will be executed when it is first in line
|
|
||||||
// const performCall = () =>
|
|
||||||
// new Promise((res) => {
|
|
||||||
// asynco(id, delay).then((r) => {
|
|
||||||
// // This resolves for the promise for the queue handling
|
|
||||||
// res(r);
|
|
||||||
// // This fullfills the promise sent to the value back to the original caller
|
|
||||||
// resolve(r + ' result to caller');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// executionQueue.push(performCall);
|
|
||||||
// });
|
|
||||||
// return p;
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param txt
|
|
||||||
* @param id
|
|
||||||
* @param text
|
|
||||||
* @param cb
|
|
||||||
* @param container
|
|
||||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
|
||||||
*/
|
|
||||||
const renderAsync = (
|
|
||||||
id: string,
|
|
||||||
text: string,
|
|
||||||
cb: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
|
|
||||||
container?: Element
|
|
||||||
): Promise<void> => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// This promise will resolve when the mermaidAPI.render call is done.
|
|
||||||
// It will be queued first and will be executed when it is first in line
|
|
||||||
const performCall = () =>
|
|
||||||
new Promise((res, rej) => {
|
|
||||||
mermaidAPI.renderAsync(id, text, cb, container).then(
|
|
||||||
(r) => {
|
|
||||||
// This resolves for the promise for the queue handling
|
|
||||||
res(r);
|
|
||||||
// This fullfills the promise sent to the value back to the original caller
|
|
||||||
resolve(r);
|
|
||||||
},
|
|
||||||
(e) => {
|
|
||||||
log.error('Error parsing', e);
|
|
||||||
rej(e);
|
|
||||||
reject(e);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
executionQueue.push(performCall);
|
|
||||||
executeQueue();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mermaid: {
|
const mermaid: {
|
||||||
@@ -518,10 +374,8 @@ const mermaid: {
|
|||||||
parse: typeof parse;
|
parse: typeof parse;
|
||||||
parseAsync: typeof parseAsync;
|
parseAsync: typeof parseAsync;
|
||||||
render: typeof mermaidAPI.render;
|
render: typeof mermaidAPI.render;
|
||||||
renderAsync: typeof renderAsync;
|
|
||||||
init: typeof init;
|
init: typeof init;
|
||||||
initThrowsErrors: typeof initThrowsErrors;
|
initThrowsErrors: typeof initThrowsErrors;
|
||||||
initThrowsErrorsAsync: typeof initThrowsErrorsAsync;
|
|
||||||
initialize: typeof initialize;
|
initialize: typeof initialize;
|
||||||
initializeAsync: typeof initializeAsync;
|
initializeAsync: typeof initializeAsync;
|
||||||
contentLoaded: typeof contentLoaded;
|
contentLoaded: typeof contentLoaded;
|
||||||
@@ -533,10 +387,8 @@ const mermaid: {
|
|||||||
parse,
|
parse,
|
||||||
parseAsync,
|
parseAsync,
|
||||||
render: mermaidAPI.render,
|
render: mermaidAPI.render,
|
||||||
renderAsync,
|
|
||||||
init,
|
init,
|
||||||
initThrowsErrors,
|
initThrowsErrors,
|
||||||
initThrowsErrorsAsync,
|
|
||||||
initialize,
|
initialize,
|
||||||
initializeAsync,
|
initializeAsync,
|
||||||
parseError: undefined,
|
parseError: undefined,
|
||||||
|
@@ -741,13 +741,12 @@ const handleDirective = function (p: any, directive: any, type: string): void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** @param {MermaidConfig} options */
|
/** @param {MermaidConfig} options */
|
||||||
function initialize(options: MermaidConfig = {}) {
|
function initialize(options: MermaidConfig) {
|
||||||
// Handle legacy location of font-family configuration
|
// Handle legacy location of font-family configuration
|
||||||
if (options.fontFamily) {
|
if (options?.fontFamily) {
|
||||||
if (!options.themeVariables) {
|
if (!options.themeVariables?.fontFamily) {
|
||||||
options.themeVariables = {};
|
options.themeVariables = { fontFamily: options.fontFamily };
|
||||||
}
|
}
|
||||||
options.themeVariables.fontFamily = options.fontFamily;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default options
|
// Set default options
|
||||||
|
@@ -147,18 +147,11 @@ class Theme {
|
|||||||
this['cScaleInv' + i] = this['cScaleInv' + i] || adjust(this['cScale' + i], { h: 180 });
|
this['cScaleInv' + i] = this['cScaleInv' + i] || adjust(this['cScale' + i], { h: 180 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the label color for the set
|
// Setup teh label color for the set
|
||||||
this.scaleLabelColor =
|
this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
|
||||||
this.scaleLabelColor !== 'calculated' && this.scaleLabelColor
|
|
||||||
? this.scaleLabelColor
|
|
||||||
: this.labelTextColor;
|
|
||||||
|
|
||||||
if (this.labelTextColor !== 'calculated') {
|
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
||||||
this.cScaleLabel0 = this.cScaleLabel0 || invert(this.labelTextColor);
|
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
|
||||||
this.cScaleLabel3 = this.cScaleLabel3 || invert(this.labelTextColor);
|
|
||||||
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
|
||||||
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.labelTextColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flowchart variables */
|
/* Flowchart variables */
|
||||||
|
@@ -121,10 +121,7 @@ class Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup teh label color for the set
|
// Setup teh label color for the set
|
||||||
this.scaleLabelColor =
|
this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
|
||||||
this.scaleLabelColor !== 'calculated' && this.scaleLabelColor
|
|
||||||
? this.scaleLabelColor
|
|
||||||
: this.labelTextColor;
|
|
||||||
|
|
||||||
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
||||||
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
|
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
|
||||||
|
@@ -825,8 +825,6 @@ export const sanitizeCss = (str) => {
|
|||||||
export interface DetailedError {
|
export interface DetailedError {
|
||||||
str: string;
|
str: string;
|
||||||
hash: any;
|
hash: any;
|
||||||
error?: any;
|
|
||||||
message?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param error */
|
/** @param error */
|
||||||
|
Reference in New Issue
Block a user