diff --git a/.eslintrc.json b/.eslintrc.json index 73cd0df67..47ba776d8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -61,24 +61,25 @@ }, "overrides": [ { - "files": "./**/*.html", - "rules": { - "no-undef": "off", - "jsdoc/require-jsdoc": "off" - } - }, - { - "files": ["./cypress/**", "./demos/**"], + "files": ["cypress/**", "demos/**"], "rules": { "no-console": "off" } }, { - "files": ["./**/*.spec.{ts,js}", "./cypress/**", "./demos/**", "./**/docs/**"], + "files": ["*.spec.{ts,js}", "cypress/**", "demos/**", "**/docs/**"], "rules": { "jsdoc/require-jsdoc": "off", "@typescript-eslint/no-unused-vars": "off" } + }, + { + "files": ["*.html", "*.md", "**/*.md/*"], + "rules": { + "no-var": "error", + "no-undef": "off", + "@typescript-eslint/no-unused-vars": "off" + } } ] } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8bafc91a..2a70b5901 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1e08a5c16..a7ad03a7a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -16,9 +16,9 @@ jobs: name: 'Docs: Spellcheck' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 name: Check out the code - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 name: Setup node with: node-version: '16' diff --git a/.github/workflows/e2e-applitools.yml b/.github/workflows/e2e-applitools.yml index 5c515b433..da6dbdb1f 100644 --- a/.github/workflows/e2e-applitools.yml +++ b/.github/workflows/e2e-applitools.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - if: ${{ ! env.USE_APPLI }} name: Warn if not using Applitools diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8925a828d..55e06f46d 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [16.x] + node-version: [18.x] containers: [1, 2, 3, 4] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dd2f7aa3b..9adbb177c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml index ed55c847d..2b2ff559b 100644 --- a/.github/workflows/release-preview-publish.yml +++ b/.github/workflows/release-preview-publish.yml @@ -13,7 +13,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 18.x - name: Install Yarn run: npm i yarn --global diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 9cf49e282..6f0806de1 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 18.x - name: Install Yarn run: npm i yarn --global diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd058406d..6397e5305 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x] + node-version: [18.x] steps: - uses: actions/checkout@v3 diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..f87a04434 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7efa8e41..ed436a8d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,12 +6,23 @@ So you want to help? That's great! Here are a few things to know to get you started on the right path. +Below link will help you making a copy of the repository in your local system. + +https://docs.github.com/en/get-started/quickstart/fork-a-repo + +## Requirements + +- [volta](https://volta.sh/) to manage node versions. +- [Node.js](https://nodejs.org/en/). `volta install node` +- [pnpm](https://pnpm.io/) package manager. `volta install pnpm` + ## Development Installation ```bash git clone git@github.com:mermaid-js/mermaid.git cd mermaid -pnpm install +# npx is required for first install as volta support for pnpm is not added yet. +npx pnpm install pnpm test ``` @@ -39,16 +50,16 @@ Less strict here, it is OK to commit directly in the `develop` branch if you are The documentation is written in **Markdown**. For more information about Markdown [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). -### Documentation source files are in /src/docs +### Documentation source files are in [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) -The source files for the project documentation are located in the `/src/docs` directory. This is where you should make changes. -The files under `/src/docs` are processed to generate the published documentation, and the resulting files are put into the `/docs` directory. +The source files for the project documentation are located in the [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) directory. This is where you should make changes. +The files under `/packages/mermaid/src/docs` are processed to generate the published documentation, and the resulting files are put into the `/docs` directory. ```mermaid flowchart LR classDef default fill:#fff,color:black,stroke:black - source["files in /src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] + source["files in /packages/mermaid/src/docs\n(changes should be done here)"] -- automatic processing\nto generate the final documentation--> published["files in /docs\ndisplayed on the official documentation site"] ``` @@ -137,7 +148,7 @@ it('should render forks and joins', () => { Finally, if it is not in the documentation, no one will know about it and then **no one will use it**. Wouldn't that be sad? With all the effort that was put into the feature? -The source files for documentation are in `/src/docs` and are written in markdown. Just pick the right section and start typing. See the [Committing Documentation](#committing-documentation) section for more about how the documentation is generated. +The source files for documentation are in `/packages/mermaid/src/docs` and are written in markdown. Just pick the right section and start typing. See the [Committing Documentation](#committing-documentation) section for more about how the documentation is generated. #### Adding to or changing the documentation organization diff --git a/README.md b/README.md index b30d8d438..90ae1ad4c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# mermaid [](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +# mermaid -# Whoa, whats going on here? +[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [](https://twitter.com/mermaidjs_) + +# Whoa, what's going on here? We are transforming the Mermaid repository to a so called mono-repo. This is a part of the effort to decouple the diagrams from the core of mermaid. This will: diff --git a/README.zh-CN.md b/README.zh-CN.md index c00c539e0..fcaa1f523 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,4 +1,6 @@ -# mermaid [](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +# mermaid + +[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [](https://twitter.com/mermaidjs_) [English](./README.md) | 简体中文 diff --git a/__mocks__/dagre-d3.ts b/__mocks__/dagre-d3.ts index a1a677591..bf6d341dc 100644 --- a/__mocks__/dagre-d3.ts +++ b/__mocks__/dagre-d3.ts @@ -1,3 +1 @@ -import { vi } from 'vitest'; - -// export const render = vi.fn(); +// DO NOT delete this file. It is used by vitest to mock the dagre-d3 module. diff --git a/cSpell.json b/cSpell.json index 867302e3c..4747e0b0b 100644 --- a/cSpell.json +++ b/cSpell.json @@ -52,7 +52,8 @@ "Ashish", "bbox", "techn", - "cytoscape" + "cytoscape", + "ts-nocheck" ], "patterns": [ { diff --git a/cypress/platform/sidv.html b/cypress/platform/sidv.html new file mode 100644 index 000000000..c9bf56b7d --- /dev/null +++ b/cypress/platform/sidv.html @@ -0,0 +1,14 @@ + +
++ none + hello world ++ + + + diff --git a/cypress/platform/xss10.html b/cypress/platform/xss10.html index 6a027f514..b39728c84 100644 --- a/cypress/platform/xss10.html +++ b/cypress/platform/xss10.html @@ -93,7 +93,7 @@ throw new Error('XSS Succeeded'); } - var diagram = 'classDiagram\n'; + let diagram = 'classDiagram\n'; diagram += 'class Square~
` tags with `class="mermaid"`. From these tags mermaid will try to read the diagram/chart definitions and render them into SVG charts.** **Examples can be found at** [Other examples](/examples) diff --git a/docs/Setup.md b/docs/Setup.md index dec513498..82e4e2fe8 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -1561,7 +1561,7 @@ Returns **void** ```html @@ -653,10 +653,10 @@ Beginner's tip—a full example using interactive links in an HTML page:@@ -727,10 +727,10 @@ Beginner's tip—here's a full example of using interactive links in HTML: @@ -771,10 +771,10 @@ Beginner's tip—a full example using interactive links in a html context: - - - - + + + @@ -50,17 +63,22 @@ + - -``` - -**b. The embedded mermaid diagram definition inside a `
`:** +**a. The embedded mermaid diagram definition inside a ``:** ```html @@ -107,13 +97,14 @@ c. The `mermaid.initialize()` call, which dictates the appearance of diagrams an **Notes**: Every Mermaid chart/graph/diagram definition, should have separate `` tags. -**c. The `mermaid.initialize()` call.** +**b. The import of mermaid and the `mermaid.initialize()` call.** `mermaid.initialize()` call takes all the definitions contained in all the `` tags that it finds in the html body and renders them into diagrams. Example: ```html - @@ -135,11 +126,6 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac ```html - - - Here is one mermaid diagram:- - @@ -206,4 +197,4 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file, **Comments from Knut Sveidqvist, creator of mermaid:** -- In early versions of mermaid, the ` - ``` - -2. The `mermaidAPI` call, in a separate `script` tag. Example: - - ```html - - ``` - -3. A graph definition, inside `graph TD @@ -156,6 +142,11 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac B -->|tcp_456| C[Server1] B -->|tcp_456| D[Server2]+ + ``` @@ -181,8 +172,8 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file, B --> C[Server1] B --> D[Server2]` tags labeled `class=mermaid`. Example: +- A graph definition, inside `` tags labeled `class=mermaid`. Example: ```html- -@@ -66,8 +52,18 @@ The easiest way to integrate mermaid on a web page requires three elements:``` -**Following these directions, mermaid starts at page load and (when the page has loaded) it will -locate the graph definitions inside the `div` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.** +- Inclusion of the mermaid address in the html page body using a `script` tag as an ESM import, and the `mermaidAPI` call. + +Example: + +```html + +``` + +**Following these directions, mermaid starts at page load and (when the page has loaded) it will locate the graph definitions inside the `pre` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.** ## Simple full example: @@ -84,8 +80,8 @@ locate the graph definitions inside the `div` tags with `class="mermaid"` and re B-->C[fa:fa-ban forbidden] B-->D(fa:fa-spinner);