mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-31 14:16:42 +02:00
Compare commits
61 Commits
sidv/mindm
...
sidv/webpa
Author | SHA1 | Date | |
---|---|---|---|
![]() |
166dca4924 | ||
![]() |
75d276e19e | ||
![]() |
2243af1871 | ||
![]() |
41dbf0fa96 | ||
![]() |
1a5e7315c0 | ||
![]() |
da6bb9498a | ||
![]() |
1e417833f4 | ||
![]() |
97a7f1fd71 | ||
![]() |
c86d46eb8a | ||
![]() |
361dd6a96e | ||
![]() |
17adec38af | ||
![]() |
638b9d9aae | ||
![]() |
c8f6994895 | ||
![]() |
1117a80500 | ||
![]() |
5d83ec6fa2 | ||
![]() |
bab5937426 | ||
![]() |
099a26977a | ||
![]() |
0b834485a8 | ||
![]() |
41f21d4f72 | ||
![]() |
312e5f3d96 | ||
![]() |
6ef3e7f536 | ||
![]() |
4f5228aec4 | ||
![]() |
b9daa35558 | ||
![]() |
21304a9677 | ||
![]() |
3f6613ea9f | ||
![]() |
c8635c0b9b | ||
![]() |
e78ac9b92a | ||
![]() |
7a47fcfcbc | ||
![]() |
d4c19ffa59 | ||
![]() |
120940f9f4 | ||
![]() |
48b1f489fc | ||
![]() |
e62dd255bc | ||
![]() |
13110c4ed9 | ||
![]() |
327fcbf902 | ||
![]() |
81924f72c8 | ||
![]() |
5d048ce21e | ||
![]() |
1a0309fb87 | ||
![]() |
e793aae0ec | ||
![]() |
3a2669e634 | ||
![]() |
895a5eb78a | ||
![]() |
4601c90904 | ||
![]() |
8ad8d39fe4 | ||
![]() |
56a8068a7f | ||
![]() |
d17aa6ecdd | ||
![]() |
6f27363862 | ||
![]() |
5192608f7c | ||
![]() |
77f5e0d5f3 | ||
![]() |
4c311ea4b1 | ||
![]() |
bbb3712284 | ||
![]() |
1388e201e5 | ||
![]() |
125312c114 | ||
![]() |
ea314cd24a | ||
![]() |
8230c8f8b4 | ||
![]() |
d115fbc6da | ||
![]() |
2ae8bf2987 | ||
![]() |
e86d7894f5 | ||
![]() |
752a6b2cb0 | ||
![]() |
97a842e651 | ||
![]() |
c83e29c6e3 | ||
![]() |
a4af3704ba | ||
![]() |
c5d859e52e |
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,43 +0,0 @@
|
||||
---
|
||||
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
Normal file
69
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
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
Normal file
17
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
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
Normal file
42
.github/ISSUE_TEMPLATE/diagram_proposal.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
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
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,19 +0,0 @@
|
||||
---
|
||||
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
16
.github/ISSUE_TEMPLATE/question.md
vendored
@@ -1,16 +0,0 @@
|
||||
---
|
||||
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
Normal file
34
.github/ISSUE_TEMPLATE/syntax_proposal.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
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
Normal file
42
.github/ISSUE_TEMPLATE/theme_proposal.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
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.
|
3
.npmrc
3
.npmrc
@@ -1 +1,2 @@
|
||||
auto-install-peers=true
|
||||
auto-install-peers=true
|
||||
strict-peer-dependencies=false
|
@@ -1,7 +1,15 @@
|
||||
import express from 'express';
|
||||
import express, { NextFunction, Request, Response } from 'express';
|
||||
import { createServer as createViteServer } from 'vite';
|
||||
// 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() {
|
||||
const app = express();
|
||||
|
||||
@@ -12,6 +20,7 @@ async function createServer() {
|
||||
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-example-diagram/dist'));
|
||||
app.use(express.static('./packages/mermaid-mindmap/dist'));
|
||||
|
@@ -50,7 +50,7 @@
|
||||
<div id="app"></div>
|
||||
<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.2.0-rc6/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 'http://localhost:9000/mermaid.esm.mjs';
|
||||
console.log(mermaid); // eslint-disable-line
|
||||
window.mermaid = mermaid;
|
||||
@@ -61,7 +61,7 @@
|
||||
startOnLoad: true,
|
||||
themeCSS: '.label { font-family: Source Sans Pro,Helvetica Neue,Arial,sans-serif; }',
|
||||
lazyLoadedDiagrams: [
|
||||
'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.2.0-rc3/dist/mermaid-mindmap-detector.esm.mjs',
|
||||
'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.2.0/dist/mermaid-mindmap-detector.esm.mjs',
|
||||
// 'http://localhost:9000/mermaid-mindmap-detector.esm.mjs',
|
||||
],
|
||||
};
|
||||
|
16
package.json
16
package.json
@@ -3,19 +3,8 @@
|
||||
"private": true,
|
||||
"version": "9.2.0-rc4",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||
"main": "dist/mermaid.core.mjs",
|
||||
"module": "dist/mermaid.core.mjs",
|
||||
"types": "dist/mermaid.d.ts",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@7.13.2",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/mermaid.min.js",
|
||||
"import": "./dist/mermaid.core.mjs",
|
||||
"types": "./dist/mermaid.d.ts"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@@ -28,7 +17,7 @@
|
||||
"scripts": {
|
||||
"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:types": "concurrently \"tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly\" \"tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly\"",
|
||||
"build:types": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly",
|
||||
"build:watch": "pnpm build:vite --watch",
|
||||
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
|
||||
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
|
||||
@@ -147,9 +136,6 @@
|
||||
"resolutions": {
|
||||
"d3": "^7.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"sideEffects": [
|
||||
"**/*.css",
|
||||
"**/*.scss"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mermaid-js/mermaid-mindmap",
|
||||
"version": "9.2.0-rc3",
|
||||
"version": "9.2.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||
"main": "dist/mermaid-mindmap.core.mjs",
|
||||
"module": "dist/mermaid-mindmap.core.mjs",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import type { MermaidConfig } from 'mermaid/dist/config.type';
|
||||
import type { MermaidConfig } from 'mermaid';
|
||||
|
||||
const warning = (s: string) => {
|
||||
// Todo remove debug code
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** Created by knut on 15-01-14. */
|
||||
/** Created by knut on 23-07-2022. */
|
||||
import { sanitizeText, getConfig, log } from './mermaidUtils';
|
||||
import type { DetailedError } from 'mermaid/dist/utils';
|
||||
import type { DetailedError } from 'mermaid';
|
||||
|
||||
interface Node {
|
||||
id: number;
|
||||
@@ -17,11 +17,9 @@ interface Node {
|
||||
|
||||
let nodes: Node[] = [];
|
||||
let cnt = 0;
|
||||
let elements: Record<number, HTMLElement> = {};
|
||||
export const clear = () => {
|
||||
nodes = [];
|
||||
cnt = 0;
|
||||
elements = {};
|
||||
};
|
||||
|
||||
const getParent = function (level: number) {
|
||||
@@ -107,10 +105,6 @@ 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 }) => {
|
||||
const node = nodes[nodes.length - 1];
|
||||
if (decoration && decoration.icon) {
|
||||
@@ -150,5 +144,3 @@ export const setErrorHandler = (handler: ParseErrorFunction) => {
|
||||
export const getLogger = () => log;
|
||||
|
||||
export const getNodeById = (id: number): Node => nodes[id];
|
||||
export const getElementById = (id: number | string): HTMLElement =>
|
||||
elements[typeof id === 'string' ? parseInt(id) : id];
|
||||
|
@@ -1,10 +1,9 @@
|
||||
/** Created by knut on 14-12-11. */
|
||||
/** Created by knut on 23-07-2022. */
|
||||
import { select } from 'd3';
|
||||
import { log, getConfig, setupGraphViewbox } from './mermaidUtils';
|
||||
import svgDraw from './svgDraw';
|
||||
import svgDraw, { getElementById, clearElementRefs } from './svgDraw';
|
||||
import cytoscape from 'cytoscape';
|
||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
||||
import * as db from './mindmapDb';
|
||||
|
||||
// Inject the layout algorithm into cytoscape
|
||||
cytoscape.use(coseBilkent);
|
||||
@@ -155,7 +154,7 @@ function positionNodes(cy) {
|
||||
data.x = node.position().x;
|
||||
data.y = node.position().y;
|
||||
svgDraw.positionNode(data);
|
||||
const el = db.getElementById(data.nodeId);
|
||||
const el = getElementById(data.nodeId);
|
||||
log.info('Id:', id, 'Position: (', node.position().x, ', ', node.position().y, ')', data);
|
||||
el.attr(
|
||||
'transform',
|
||||
@@ -179,6 +178,7 @@ export const draw = async (text, id, version, diagObj) => {
|
||||
|
||||
// This is done only for throwing the error if the text is not valid.
|
||||
diagObj.db.clear();
|
||||
clearElementRefs();
|
||||
// Parse the graph definition
|
||||
diagObj.parser.parse(text);
|
||||
|
||||
|
@@ -22,12 +22,10 @@ const genSections = (options) => {
|
||||
}
|
||||
.section-${i - 1} text {
|
||||
fill: ${options['cScaleLabel' + i]};
|
||||
// fill: ${options['gitInv' + i]};
|
||||
}
|
||||
.node-icon-${i - 1} {
|
||||
font-size: 40px;
|
||||
color: ${options['cScaleLabel' + i]};
|
||||
// color: ${options['gitInv' + i]};
|
||||
}
|
||||
.section-edge-${i - 1}{
|
||||
stroke: ${options['cScale' + i]};
|
||||
@@ -36,7 +34,7 @@ const genSections = (options) => {
|
||||
stroke-width: ${sw};
|
||||
}
|
||||
.section-${i - 1} line {
|
||||
stroke: ${options['lineColor' + i]} ;
|
||||
stroke: ${options['cScaleInv' + i]} ;
|
||||
stroke-width: 3;
|
||||
}
|
||||
|
||||
|
@@ -259,7 +259,7 @@ export const drawNode = function (elem, node, fullSection, conf) {
|
||||
// if (typeof node.x !== 'undefined' && typeof node.y !== 'undefined') {
|
||||
// nodeElem.attr('transform', 'translate(' + node.x + ',' + node.y + ')');
|
||||
// }
|
||||
db.setElementForId(node.id, nodeElem);
|
||||
setElementById(node.id, nodeElem);
|
||||
return node.height;
|
||||
};
|
||||
|
||||
@@ -286,7 +286,7 @@ export const drawEdge = function drawEdge(edgesElem, mindmap, parent, depth, ful
|
||||
};
|
||||
|
||||
export const positionNode = function (node) {
|
||||
const nodeElem = db.getElementById(node.id);
|
||||
const nodeElem = getElementById(node.id);
|
||||
|
||||
const x = node.x || 0;
|
||||
const y = node.y || 0;
|
||||
@@ -294,4 +294,18 @@ export const positionNode = function (node) {
|
||||
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 };
|
||||
|
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "mermaid",
|
||||
"version": "9.2.0-rc6",
|
||||
"version": "9.2.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||
"main": "./dist/mermaid.core.mjs",
|
||||
"main": "./dist/mermaid.min.js",
|
||||
"module": "./dist/mermaid.core.mjs",
|
||||
"types": "./dist/mermaid.d.ts",
|
||||
"type": "module",
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/mermaid.min.js",
|
||||
|
@@ -25,6 +25,7 @@ function parse(text: string, parseError?: Function): boolean {
|
||||
// original version cannot be modified since it was frozen with `Object.freeze()`
|
||||
export const mermaidAPI = {
|
||||
render: vi.fn(),
|
||||
renderAsync: vi.fn(),
|
||||
parse,
|
||||
parseDirective: vi.fn(),
|
||||
initialize: vi.fn(),
|
||||
|
@@ -54,6 +54,29 @@ describe('when using mermaid and ', function () {
|
||||
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 () {
|
||||
it('should throw for an invalid definition', function () {
|
||||
|
@@ -2,14 +2,15 @@
|
||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid
|
||||
* functionality and to render the diagrams to svg code!
|
||||
*/
|
||||
import { MermaidConfig } from './config.type';
|
||||
import type { MermaidConfig } from './config.type';
|
||||
import { log } from './logger';
|
||||
import utils from './utils';
|
||||
import { mermaidAPI } from './mermaidAPI';
|
||||
import { addDetector } from './diagram-api/detectType';
|
||||
import { isDetailedError } from './utils';
|
||||
import { isDetailedError, type DetailedError } from './utils';
|
||||
import { registerDiagram } from './diagram-api/diagramAPI';
|
||||
|
||||
export type { MermaidConfig, DetailedError };
|
||||
/**
|
||||
* ## init
|
||||
*
|
||||
@@ -48,7 +49,6 @@ const init = async function (
|
||||
try {
|
||||
const conf = mermaidAPI.getConfig();
|
||||
if (conf?.lazyLoadedDiagrams && conf.lazyLoadedDiagrams.length > 0) {
|
||||
await registerLazyLoadedDiagrams(conf);
|
||||
await initThrowsErrorsAsync(config, nodes, callback);
|
||||
} else {
|
||||
initThrowsErrors(config, nodes, callback);
|
||||
@@ -64,6 +64,31 @@ 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 (
|
||||
config?: MermaidConfig,
|
||||
// eslint-disable-next-line no-undef
|
||||
@@ -72,7 +97,6 @@ const initThrowsErrors = function (
|
||||
callback?: Function
|
||||
) {
|
||||
const conf = mermaidAPI.getConfig();
|
||||
// console.log('Starting rendering diagrams (init) - mermaid.init', conf);
|
||||
if (config) {
|
||||
// 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
|
||||
@@ -104,7 +128,7 @@ const initThrowsErrors = function (
|
||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||
|
||||
let txt: string;
|
||||
const errors = [];
|
||||
const errors: DetailedError[] = [];
|
||||
|
||||
// element is the current div with mermaid class
|
||||
for (const element of Array.from(nodesToProcess)) {
|
||||
@@ -144,13 +168,7 @@ const initThrowsErrors = function (
|
||||
element
|
||||
);
|
||||
} catch (error) {
|
||||
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);
|
||||
handleError(error, errors, mermaid.parseError);
|
||||
}
|
||||
}
|
||||
if (errors.length > 0) {
|
||||
@@ -159,10 +177,12 @@ const initThrowsErrors = function (
|
||||
}
|
||||
};
|
||||
|
||||
let lazyLoadingPromise: Promise<unknown> | undefined = undefined;
|
||||
let lazyLoadingPromise: Promise<PromiseSettledResult<void>[]> | undefined = undefined;
|
||||
/**
|
||||
* @param conf
|
||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||
* This is an internal function and should not be made public, as it will likely change.
|
||||
* @internal
|
||||
* @param conf - Mermaid config.
|
||||
* @returns An array of {@link PromiseSettledResult}, showing the status of imports.
|
||||
*/
|
||||
const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
||||
// Only lazy load once
|
||||
@@ -176,7 +196,7 @@ const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
||||
})
|
||||
);
|
||||
}
|
||||
await lazyLoadingPromise;
|
||||
return await lazyLoadingPromise;
|
||||
};
|
||||
|
||||
let loadingPromise: Promise<unknown> | undefined = undefined;
|
||||
@@ -199,9 +219,20 @@ const loadExternalDiagrams = async (conf: MermaidConfig) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||
* Equivalent to {@link init()}, except an error will be thrown on error.
|
||||
*
|
||||
* @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 (
|
||||
config?: MermaidConfig,
|
||||
// eslint-disable-next-line no-undef
|
||||
@@ -210,7 +241,14 @@ const initThrowsErrorsAsync = async function (
|
||||
callback?: Function
|
||||
) {
|
||||
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) {
|
||||
// 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
|
||||
@@ -242,7 +280,7 @@ const initThrowsErrorsAsync = async function (
|
||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||
|
||||
let txt: string;
|
||||
const errors = [];
|
||||
const errors: DetailedError[] = [];
|
||||
|
||||
// element is the current div with mermaid class
|
||||
for (const element of Array.from(nodesToProcess)) {
|
||||
@@ -282,18 +320,13 @@ const initThrowsErrorsAsync = async function (
|
||||
element
|
||||
);
|
||||
} catch (error) {
|
||||
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);
|
||||
handleError(error, errors, mermaid.parseError);
|
||||
}
|
||||
}
|
||||
if (errors.length > 0) {
|
||||
const allErrors = [...registerLazyLoadedDiagramsErrors, ...errors];
|
||||
if (allErrors.length > 0) {
|
||||
// TODO: We should be throwing an error object.
|
||||
throw errors[0];
|
||||
throw allErrors[0];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,12 +390,123 @@ const parse = (txt: string) => {
|
||||
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
|
||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||
*/
|
||||
const parseAsync = (txt: string) => {
|
||||
return mermaidAPI.parseAsync(txt, mermaid.parseError);
|
||||
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.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<string> => {
|
||||
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: {
|
||||
@@ -374,8 +518,10 @@ const mermaid: {
|
||||
parse: typeof parse;
|
||||
parseAsync: typeof parseAsync;
|
||||
render: typeof mermaidAPI.render;
|
||||
renderAsync: typeof renderAsync;
|
||||
init: typeof init;
|
||||
initThrowsErrors: typeof initThrowsErrors;
|
||||
initThrowsErrorsAsync: typeof initThrowsErrorsAsync;
|
||||
initialize: typeof initialize;
|
||||
initializeAsync: typeof initializeAsync;
|
||||
contentLoaded: typeof contentLoaded;
|
||||
@@ -387,8 +533,10 @@ const mermaid: {
|
||||
parse,
|
||||
parseAsync,
|
||||
render: mermaidAPI.render,
|
||||
renderAsync,
|
||||
init,
|
||||
initThrowsErrors,
|
||||
initThrowsErrorsAsync,
|
||||
initialize,
|
||||
initializeAsync,
|
||||
parseError: undefined,
|
||||
|
@@ -115,19 +115,19 @@ export const decodeEntities = function (text: string): string {
|
||||
*
|
||||
* @param {string} id The id of the element to be rendered
|
||||
* @param {string} text The graph definition
|
||||
* @param {(svgCode: string, bindFunctions?: (element: Element) => void) => void} cb Callback which
|
||||
* @param cb - Optional callback which
|
||||
* is called after rendering is finished with the svg code as inparam.
|
||||
* @param {Element} container Selector to element in which a div with the graph temporarily will be
|
||||
* inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
|
||||
* element will be removed when rendering is completed.
|
||||
* @returns {void}
|
||||
* @returns Returns the rendered element as a string containing the SVG definition.
|
||||
*/
|
||||
const render = function (
|
||||
id: string,
|
||||
text: string,
|
||||
cb: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
|
||||
cb?: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
|
||||
container?: Element
|
||||
): void {
|
||||
): string {
|
||||
addDiagrams();
|
||||
configApi.reset();
|
||||
text = text.replace(/\r\n?/g, '\n'); // parser problems on CRLF ignore all CR and leave LF;;
|
||||
@@ -401,9 +401,9 @@ const render = function (
|
||||
const renderAsync = async function (
|
||||
id: string,
|
||||
text: string,
|
||||
cb: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
|
||||
cb?: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
|
||||
container?: Element
|
||||
): Promise<void> {
|
||||
): Promise<string> {
|
||||
addDiagrams();
|
||||
configApi.reset();
|
||||
text = text.replace(/\r\n?/g, '\n'); // parser problems on CRLF ignore all CR and leave LF;;
|
||||
@@ -741,12 +741,13 @@ const handleDirective = function (p: any, directive: any, type: string): void {
|
||||
};
|
||||
|
||||
/** @param {MermaidConfig} options */
|
||||
function initialize(options: MermaidConfig) {
|
||||
function initialize(options: MermaidConfig = {}) {
|
||||
// Handle legacy location of font-family configuration
|
||||
if (options?.fontFamily) {
|
||||
if (!options.themeVariables?.fontFamily) {
|
||||
options.themeVariables = { fontFamily: options.fontFamily };
|
||||
if (options.fontFamily) {
|
||||
if (!options.themeVariables) {
|
||||
options.themeVariables = {};
|
||||
}
|
||||
options.themeVariables.fontFamily = options.fontFamily;
|
||||
}
|
||||
|
||||
// Set default options
|
||||
|
@@ -147,11 +147,18 @@ class Theme {
|
||||
this['cScaleInv' + i] = this['cScaleInv' + i] || adjust(this['cScale' + i], { h: 180 });
|
||||
}
|
||||
|
||||
// Setup teh label color for the set
|
||||
this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
|
||||
// Setup the label color for the set
|
||||
this.scaleLabelColor =
|
||||
this.scaleLabelColor !== 'calculated' && this.scaleLabelColor
|
||||
? this.scaleLabelColor
|
||||
: this.labelTextColor;
|
||||
|
||||
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
||||
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
|
||||
if (this.labelTextColor !== 'calculated') {
|
||||
this.cScaleLabel0 = this.cScaleLabel0 || invert(this.labelTextColor);
|
||||
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 */
|
||||
|
@@ -121,7 +121,10 @@ class Theme {
|
||||
}
|
||||
|
||||
// Setup teh label color for the set
|
||||
this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
|
||||
this.scaleLabelColor =
|
||||
this.scaleLabelColor !== 'calculated' && this.scaleLabelColor
|
||||
? this.scaleLabelColor
|
||||
: this.labelTextColor;
|
||||
|
||||
for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
|
||||
this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
|
||||
|
@@ -825,6 +825,8 @@ export const sanitizeCss = (str) => {
|
||||
export interface DetailedError {
|
||||
str: string;
|
||||
hash: any;
|
||||
error?: any;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
/** @param error */
|
||||
|
968
pnpm-lock.yaml
generated
968
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
packages:
|
||||
# all packages in direct subdirs of packages/
|
||||
- 'packages/*'
|
||||
- 'tests/*'
|
||||
|
22
tests/webpack/package.json
Normal file
22
tests/webpack/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "webpack",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"module": "commonjs",
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"serve": "webpack serve"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^4.11.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"mermaid": "workspace:*"
|
||||
}
|
||||
}
|
10
tests/webpack/public/index.html
Normal file
10
tests/webpack/public/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Getting Started</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./main.js"></script>
|
||||
</body>
|
||||
</html>
|
6
tests/webpack/src/index.js
Normal file
6
tests/webpack/src/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/* eslint-disable no-console */
|
||||
const mermaid = require('mermaid');
|
||||
// import mermaid from 'mermaid';
|
||||
|
||||
console.log(mermaid);
|
9
tests/webpack/webpack.config.js
Normal file
9
tests/webpack/webpack.config.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
filename: 'main.js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user