diff --git a/.build/jsonSchema.ts b/.build/jsonSchema.ts index d29ef7920a..6fd8ca3f54 100644 --- a/.build/jsonSchema.ts +++ b/.build/jsonSchema.ts @@ -1,7 +1,6 @@ import { load, JSON_SCHEMA } from 'js-yaml'; import assert from 'node:assert'; import Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js'; - import type { MermaidConfig, BaseDiagramConfig } from '../packages/mermaid/src/config.type.js'; /** @@ -24,6 +23,8 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [ 'gitGraph', 'c4', 'sankey', + 'block', + 'packet', ] as const; /** diff --git a/.build/langium-cli.d.ts b/.build/langium-cli.d.ts deleted file mode 100644 index a1cfe25f89..0000000000 --- a/.build/langium-cli.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module 'langium-cli' { - export interface GenerateOptions { - file?: string; - mode?: 'development' | 'production'; - watch?: boolean; - } - - export function generate(options: GenerateOptions): Promise; -} diff --git a/.build/types.ts b/.build/types.ts index d9f10d21ae..4192407824 100644 --- a/.build/types.ts +++ b/.build/types.ts @@ -8,6 +8,8 @@ const buildType = (packageName: string) => { out.length > 0 && console.log(out.toString()); } catch (e) { console.error(e); + e.stdout.length > 0 && console.error(e.stdout.toString()); + e.stderr.length > 0 && console.error(e.stderr.toString()); } }; diff --git a/.commitlintrc.json b/.commitlintrc.json deleted file mode 100644 index c30e5a970b..0000000000 --- a/.commitlintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@commitlint/config-conventional"] -} diff --git a/.cspell/code-terms.txt b/.cspell/code-terms.txt new file mode 100644 index 0000000000..fa063616a7 --- /dev/null +++ b/.cspell/code-terms.txt @@ -0,0 +1,140 @@ +# This file contains coding related terms +ALPHANUM +antiscript +APPLYCLASS +ARROWHEADSTYLE +ARROWTYPE +autonumber +axisl-line +Bigdecimal +birel +BIREL +bqstring +BQUOTE +bramp +BRKT +callbackargs +callbackname +classdef +classdefid +classentity +classname +COLONSEP +COMPOSIT_STATE +concat +controlx +controly +CSSCLASS +CYLINDEREND +CYLINDERSTART +datakey +DEND +descr +distp +distq +divs +docref +DOMID +doublecircle +DOUBLECIRCLEEND +DOUBLECIRCLESTART +DQUOTE +DSTART +edgesep +EMPTYSTR +enddate +ERDIAGRAM +flatmap +forwardable +frontmatter +funs +gantt +GENERICTYPE +getBoundarys +grammr +graphtype +iife +interp +introdcued +INVTRAPEND +INVTRAPSTART +JDBC +jison +Kaufmann +keyify +LABELPOS +LABELTYPE +lcov +LEFTOF +Lexa +linebreak +LINETYPE +LINKSTYLE +LLABEL +loglevel +LOGMSG +lookaheads +mdast +metafile +minlen +Mstartx +MULT +NODIR +NSTR +outdir +Qcontrolx +reinit +rels +reqs +rewritelinks +rgba +RIGHTOF +sankey +sequencenumber +shrc +signaltype +someclass +SPACELINE +SPACELIST +STADIUMEND +STADIUMSTART +startdate +startx +starty +STMNT +stopx +stopy +strikethrough +stringifying +struct +STYLECLASS +STYLEOPTS +subcomponent +subcomponents +SUBROUTINEEND +SUBROUTINESTART +Subschemas +substr +TAGEND +TAGSTART +techn +TESTSTR +TEXTDATA +TEXTLENGTH +titlevalue +topbar +TRAPEND +TRAPSTART +ts-nocheck +tsdoc +typeof +typestr +unshift +verifymethod +VERIFYMTHD +WARN_DOCSDIR_DOESNT_MATCH +xhost +yaxis +yfunc +yytext +zenuml diff --git a/.cspell/contributors.txt b/.cspell/contributors.txt new file mode 100644 index 0000000000..bd3ad9da24 --- /dev/null +++ b/.cspell/contributors.txt @@ -0,0 +1,8 @@ +# Contributors to mermaidjs, one per line +Ashish Jain +cpettitt +Dong Cai +Nikolay Rozhkov +Peng Xiao +subhash-halder +Vinod Sidharth diff --git a/.cspell/cspell.config.yaml b/.cspell/cspell.config.yaml new file mode 100644 index 0000000000..33d6901936 --- /dev/null +++ b/.cspell/cspell.config.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json + +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json + +dictionaryDefinitions: + - name: code-terms + path: ./code-terms.txt + description: A list of coding related terms. + addWords: true + - name: mermaid-terms + path: ./mermaid-terms.txt + description: A list of terms related to the mermaid project. + addWords: true + - name: misc-terms + path: ./misc-terms.txt + description: A list of miscellaneous terms. + - name: 3rd-party-terms + path: ./libraries.txt + description: A list of 3rd party terms from dependencies. + addWords: true + - name: contributors + path: ./contributors.txt + description: A list of contributors to the mermaid project. + type: 'W' + addWords: true + + # cspell:disable + - name: suggestions + words: + - none + suggestWords: + - seperator:separator + - vertice:vertex + # cspell:enable + +patterns: + - name: character-set-cyrillic + pattern: '/\p{Script_Extensions=Cyrillic}+/gu' + - name: svg-block + pattern: '' + - name: json-property + pattern: '/"[\w/@-]+":/g' + +dictionaries: + - mermaid-terms + - suggestions + - contributors + +ignorePaths: + - '*.txt' # do not spell check local dictionaries + +# cspell:dictionary misc-terms diff --git a/.cspell/libraries.txt b/.cspell/libraries.txt new file mode 100644 index 0000000000..9d29261868 --- /dev/null +++ b/.cspell/libraries.txt @@ -0,0 +1,71 @@ +# Add third party library terms below +acyclicer +Antlr +Appli +applitools +Asciidoctor +Astah +automerge +bilkent +bisheng +Blazor +codedoc +Codemia +codepaths +csstree +cytoscape +cytoscape-cose-bilkent +dagre +dagre-d3 +Deepdwn +Docsify +Docsy +DokuWiki +dompurify +elkjs +fontawesome +Foswiki +Gitea +graphlib +Grav +iconify +Inkdrop +jiti +jsdocs +jsfiddle +jsonschema +katex +khroma +langium +mathml +matplotlib +mdbook +Mermerd +mkdocs +Nextra +nodenext +npmjs +pageview +pathe +phpbb +pixelmatch +Podlite +presetAttributify +pyplot +redmine +rehype +rscratch +sparkline +sphinxcontrib +ssim +stylis +Swimm +tsbuildinfo +Tuleap +Typora +unocss +unplugin +unstub +vite +vitest +Zune diff --git a/.cspell/mermaid-terms.txt b/.cspell/mermaid-terms.txt new file mode 100644 index 0000000000..3fa5eff269 --- /dev/null +++ b/.cspell/mermaid-terms.txt @@ -0,0 +1,39 @@ +Adamiecki +arrowend +bmatrix +braintree +catmull +compositTitleSize +doublecircle +elems +gantt +gitgraph +gzipped +knsv +Knut +marginx +marginy +Markdownish +mermaidjs +mindmap +mindmaps +multigraph +nodesep +NOTEGROUP +Pinterest +rankdir +ranksep +rect +rects +sandboxed +siebling +statediagram +substate +Sveidqvist +unfixable +Viewbox +viewports +visio +vitepress +xlink +xychart diff --git a/.cspell/misc-terms.txt b/.cspell/misc-terms.txt new file mode 100644 index 0000000000..467e48891e --- /dev/null +++ b/.cspell/misc-terms.txt @@ -0,0 +1 @@ +newbranch diff --git a/.esbuild/build.ts b/.esbuild/build.ts index 3e829d7193..3c87f9d621 100644 --- a/.esbuild/build.ts +++ b/.esbuild/build.ts @@ -1,8 +1,8 @@ import { build } from 'esbuild'; import { mkdir, writeFile } from 'node:fs/promises'; -import { MermaidBuildOptions, defaultOptions, getBuildConfig } from './util.js'; import { packageOptions } from '../.build/common.js'; import { generateLangium } from '../.build/generateLangium.js'; +import { MermaidBuildOptions, defaultOptions, getBuildConfig } from './util.js'; const shouldVisualize = process.argv.includes('--visualize'); @@ -56,7 +56,7 @@ const main = async () => { await generateLangium(); await mkdir('stats').catch(() => {}); const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[]; - // it should build `parser` before `mermaid` because it's a dependecy + // it should build `parser` before `mermaid` because it's a dependency for (const pkg of packageNames) { await buildPackage(pkg).catch(handler); } diff --git a/.esbuild/util.ts b/.esbuild/util.ts index 1efe3bc901..5c21cbf452 100644 --- a/.esbuild/util.ts +++ b/.esbuild/util.ts @@ -65,6 +65,9 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => { minify, logLevel: 'info', chunkNames: `chunks/${outFileName}/[name]-[hash]`, + define: { + 'import.meta.vitest': 'undefined', + }, }); if (core) { diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 49e1aaaa66..dceb314c8e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -14,7 +14,7 @@ module.exports = { }, tsconfigRootDir: __dirname, sourceType: 'module', - ecmaVersion: 2020, + ecmaVersion: 2022, allowAutomaticSingleRunInference: true, project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], parser: '@typescript-eslint/parser', @@ -23,7 +23,7 @@ module.exports = { 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:json/recommended', - 'plugin:markdown/recommended', + 'plugin:markdown/recommended-legacy', 'plugin:@cspell/recommended', 'prettier', ], @@ -63,13 +63,24 @@ module.exports = { minimumDescriptionLength: 10, }, ], + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'typeLike', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: false, + }, + }, + ], 'json/*': ['error', 'allowComments'], '@cspell/spellchecker': [ 'error', { - checkIdentifiers: false, - checkStrings: false, - checkStringTemplates: false, + checkIdentifiers: true, + checkStrings: true, + checkStringTemplates: true, }, ], 'no-empty': [ @@ -148,6 +159,19 @@ module.exports = { '@typescript-eslint/no-unused-vars': 'off', }, }, + { + files: ['*.spec.{ts,js}', 'tests/**', 'cypress/**/*.js'], + rules: { + '@cspell/spellchecker': [ + 'error', + { + checkIdentifiers: false, + checkStrings: false, + checkStringTemplates: false, + }, + ], + }, + }, { files: ['*.html', '*.md', '**/*.md/*'], rules: { diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 7e0c78ff1e..6be6f3b5d8 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,9 +3,9 @@ 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: 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: Discord + url: https://discord.gg/AgrbSrBer3 + about: Join our Community on Discord for Help and a casual chat. - name: Documentation url: https://mermaid.js.org about: Read our documentation for all that Mermaid.js can offer. diff --git a/.github/lychee.toml b/.github/lychee.toml index b13e536161..c5a2f0e452 100644 --- a/.github/lychee.toml +++ b/.github/lychee.toml @@ -34,8 +34,14 @@ exclude = [ # Don't check files that are generated during the build via `pnpm docs:code` 'packages/mermaid/src/docs/config/setup/*', -# Ignore slack invite -"https://join.slack.com/" +# Ignore Discord invite +"https://discord.gg", + +# BundlePhobia has frequent downtime +"https://bundlephobia.com", + +# Chrome webstore migration issue. Temporary +"https://chromewebstore.google.com" ] # Exclude all private IPs from checking. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ff34d24fd0..cfd22a2935 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,7 @@ Describe the way your implementation works or what design decisions you made if Make sure you -- [ ] :book: have read the [contribution guidelines](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) +- [ ] :book: have read the [contribution guidelines](https://mermaid.js.org/community/contributing.html) - [ ] :computer: have added necessary unit/e2e tests. -- [ ] :notebook: have added documentation. Make sure [`MERMAID_RELEASE_VERSION`](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/community/development.md#3-update-documentation) is used for all new features. +- [ ] :notebook: have added documentation. Make sure [`MERMAID_RELEASE_VERSION`](https://mermaid.js.org/community/contributing.html#update-documentation) is used for all new features. - [ ] :bookmark: targeted `develop` branch diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index acfb1887e9..87607bc2ff 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -24,7 +24,7 @@ jobs: uses: actions/setup-node@v4 with: cache: pnpm - node-version: 18 + node-version-file: '.node-version' - name: Install Packages run: pnpm install --frozen-lockfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 605dea9ab3..e0ab766079 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,20 +15,17 @@ permissions: jobs: build-mermaid: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: cache: pnpm - node-version: ${{ matrix.node-version }} + node-version-file: '.node-version' - name: Install Packages run: | diff --git a/.github/workflows/e2e-applitools.yml b/.github/workflows/e2e-applitools.yml index 543fb5dbb4..1238fe3713 100644 --- a/.github/workflows/e2e-applitools.yml +++ b/.github/workflows/e2e-applitools.yml @@ -21,24 +21,24 @@ env: jobs: e2e-applitools: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] + container: + image: cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1 + options: --user 1001 steps: - if: ${{ ! env.USE_APPLI }} name: Warn if not using Applitools run: | - echo "::error,title=Not using Applitols::APPLITOOLS_API_KEY is empty, disabling Applitools for this run." + echo "::error,title=Not using Applitools::APPLITOOLS_API_KEY is empty, disabling Applitools for this run." - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version-file: '.node-version' - if: ${{ env.USE_APPLI }} name: Notify applitools of new batch diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 71806a9c46..4d3152d533 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,20 +1,96 @@ +# We use github cache to save snapshots between runs. +# For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used. +# If a snapshot for a given Hash is not found, we checkout that commit, run the tests and cache the snapshots. +# These are then downloaded before running the E2E, providing the reference snapshots. +# If there are any errors, the diff image is uploaded to artifacts, and the user is notified. + name: E2E on: push: + branches-ignore: + - 'gh-readonly-queue/**' pull_request: merge_group: permissions: contents: read +env: + # For PRs and MergeQueues, the target commit is used, and for push events to non-develop branches, github.event.previous is used if available. Otherwise, 'develop' is used. + targetHash: >- + ${{ + github.event.pull_request.base.sha || + github.event.merge_group.base_sha || + ( + ( + (github.event_name == 'push' && github.ref == 'refs/heads/develop') || + github.event.before == '0000000000000000000000000000000000000000' + ) && 'develop' + ) || + github.event.before + }} jobs: + cache: + runs-on: ubuntu-latest + container: + image: cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1 + options: --user 1001 + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.node-version' + - name: Cache snapshots + id: cache-snapshot + uses: actions/cache@v4 + with: + save-always: true + path: ./cypress/snapshots + key: ${{ runner.os }}-snapshots-${{ env.targetHash }} + + # If a snapshot for a given Hash is not found, we checkout that commit, run the tests and cache the snapshots. + - name: Switch to base branch + if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} + uses: actions/checkout@v4 + with: + ref: ${{ env.targetHash }} + + - name: Install dependencies + if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} + uses: cypress-io/github-action@v6 + with: + # just perform install + runTests: false + + - name: Calculate bundle size + if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true'}} + run: | + pnpm run build:viz + mkdir -p cypress/snapshots/stats/base + mv stats cypress/snapshots/stats/base + + - name: Cypress run + uses: cypress-io/github-action@v6 + id: cypress-snapshot-gen + if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} + with: + install: false + start: pnpm run dev + wait-on: 'http://localhost:9000' + browser: chrome + e2e: runs-on: ubuntu-latest + container: + image: cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1 + options: --user 1001 + needs: cache strategy: fail-fast: false matrix: - node-version: [18.x] containers: [1, 2, 3, 4] steps: - uses: actions/checkout@v4 @@ -22,22 +98,46 @@ jobs: - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version-file: '.node-version' + + # These cached snapshots are downloaded, providing the reference snapshots. + - name: Cache snapshots + id: cache-snapshot + uses: actions/cache/restore@v3 + with: + path: ./cypress/snapshots + key: ${{ runner.os }}-snapshots-${{ env.targetHash }} + + - name: Install dependencies + uses: cypress-io/github-action@v6 + with: + runTests: false + + - name: Output size diff + if: ${{ matrix.containers == 1 }} + run: | + pnpm run build:viz + mv stats cypress/snapshots/stats/head + echo '## Bundle size difference' >> "$GITHUB_STEP_SUMMARY" + echo '' >> "$GITHUB_STEP_SUMMARY" + npx tsx scripts/size.ts >> "$GITHUB_STEP_SUMMARY" # Install NPM dependencies, cache them correctly # and run all Cypress tests - name: Cypress run - uses: cypress-io/github-action@v4 + uses: cypress-io/github-action@v6 id: cypress # If CYPRESS_RECORD_KEY is set, run in parallel on all containers # Otherwise (e.g. if running from fork), we run on a single container only if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }} with: + install: false start: pnpm run dev:coverage wait-on: 'http://localhost:9000' + browser: chrome # Disable recording if we don't have an API key # e.g. if this action was run from a fork record: ${{ secrets.CYPRESS_RECORD_KEY != '' }} @@ -46,6 +146,7 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} VITEST_COVERAGE: true CYPRESS_COMMIT: ${{ github.sha }} + - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 # Run step only pushes to develop and pull_requests @@ -57,9 +158,55 @@ jobs: fail_ci_if_error: false verbose: true token: 6845cc80-77ee-4e17-85a1-026cd95e0766 + + # We upload the artifacts into numbered archives to prevent overwriting - name: Upload Artifacts - uses: actions/upload-artifact@v3 - if: ${{ failure() && steps.cypress.conclusion == 'failure' }} + uses: actions/upload-artifact@v4 + if: ${{ always() }} + with: + name: snapshots-${{ matrix.containers }} + retention-days: 1 + path: ./cypress/snapshots + + combineArtifacts: + needs: e2e + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + # Download all snapshot artifacts and merge them into a single folder + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + path: snapshots + pattern: snapshots-* + merge-multiple: true + + # For successful push events, we save the snapshots cache + - name: Save snapshots cache + id: cache-upload + if: ${{ github.event_name == 'push' && needs.e2e.result != 'failure' }} + uses: actions/cache/save@v3 + with: + path: ./snapshots + key: ${{ runner.os }}-snapshots-${{ github.event.after }} + + - name: Flatten images to a folder + if: ${{ needs.e2e.result == 'failure' }} + run: | + mkdir errors + cd snapshots + find . -mindepth 2 -type d -name "*__diff_output__*" -exec sh -c 'mv "$0"/*.png ../errors/' {} \; + + - name: Upload Error snapshots + if: ${{ needs.e2e.result == 'failure' }} + uses: actions/upload-artifact@v4 + id: upload-artifacts with: name: error-snapshots - path: cypress/snapshots/**/__diff_output__/* + retention-days: 10 + path: errors/ + + - name: Notify Users + if: ${{ needs.e2e.result == 'failure' }} + run: | + echo "::error title=Visual tests failed::You can view images that failed by downloading the error-snapshots artifact: ${{ steps.upload-artifacts.outputs.artifact-url }}" diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index c3e2ee44fe..59d25b7c54 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -36,7 +36,7 @@ jobs: restore-keys: cache-lychee- - name: Link Checker - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.3 with: args: >- --config .github/lychee.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f0c5560a1e..8f5995d717 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,20 +16,17 @@ permissions: jobs: lint: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: cache: pnpm - node-version: ${{ matrix.node-version }} + node-version-file: '.node-version' - name: Install Packages run: | diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 05cd68aff1..6efd90c7f7 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -31,7 +31,7 @@ jobs: uses: actions/setup-node@v4 with: cache: pnpm - node-version: 18 + node-version-file: '.node-version' - name: Install Packages run: pnpm install --frozen-lockfile diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index 8ad1b13ecd..8e9c0da99e 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -3,7 +3,7 @@ name: Draft Release on: push: branches: - - develop + - master permissions: contents: read @@ -12,7 +12,7 @@ jobs: draft-release: runs-on: ubuntu-latest permissions: - contents: write # write permission is required to create a github release + contents: write # write permission is required to create a GitHub release pull-requests: read # required to read PR titles/labels steps: - name: Draft Release diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml index c6503847d9..c763430b04 100644 --- a/.github/workflows/release-preview-publish.yml +++ b/.github/workflows/release-preview-publish.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-node@v4 with: cache: pnpm - node-version: 18.x + node-version-file: '.node-version' - name: Install Packages run: | diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 69ef749402..dce461cf57 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -14,11 +14,11 @@ jobs: - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js v18 + - name: Setup Node.js uses: actions/setup-node@v4 with: cache: pnpm - node-version: 18.x + node-version-file: '.node-version' - name: Install Packages run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a18b31c9cd..7160ecc5fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,20 +8,17 @@ permissions: jobs: unit-test: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 # uses version from "packageManager" field in package.json - - name: Setup Node.js ${{ matrix.node-version }} + - name: Setup Node.js uses: actions/setup-node@v4 with: cache: pnpm - node-version: ${{ matrix.node-version }} + node-version-file: '.node-version' - name: Install Packages run: | diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml index 0a83df795d..f4fa2a982f 100644 --- a/.github/workflows/update-browserlist.yml +++ b/.github/workflows/update-browserlist.yml @@ -9,10 +9,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npx browserslist@latest --update-db + - uses: pnpm/action-setup@v2 + - run: npx update-browserslist-db@latest - name: Commit changes uses: EndBug/add-and-commit@v9 with: author_name: ${{ github.actor }} author_email: ${{ github.actor }}@users.noreply.github.com message: 'chore: update browsers list' + push: false + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + branch: update-browserslist + title: Update Browserslist diff --git a/.gitignore b/.gitignore index 5e612aabe3..a0fd1c50b8 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ stats/ demos/dev/** !/demos/dev/example.html !/demos/dev/reload.js +tsx-0/** # autogenereated by langium-cli -generated/ +generated/ \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index 59f6536e22..0000000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# . "$(dirname "$0")/_/husky.sh" - -# npx --no-install commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit index a9e30b9bec..e8191928d4 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -pnpm run pre-commit +NODE_OPTIONS=--max_old_space_size=8192 pnpm run pre-commit diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 231c91f8f4..86af4f5133 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -6,6 +6,6 @@ export default { // https://prettier.io/docs/en/cli.html#--cache 'prettier --write', ], - 'cSpell.json': ['tsx scripts/fixCSpell.ts'], + '.cspell/*.txt': ['tsx scripts/fixCSpell.ts'], '**/*.jison': ['pnpm -w run lint:jison'], }; diff --git a/.node-version b/.node-version new file mode 100644 index 0000000000..ee09fac75c --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v20.11.1 diff --git a/.npmrc b/.npmrc index 4c2f52b3be..91750f5578 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,4 @@ +registry=https://registry.npmjs.org auto-install-peers=true strict-peer-dependencies=false +package-import-method=clone-or-copy diff --git a/.prettierignore b/.prettierignore index a0cd771e33..7da0646e32 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,7 @@ dist cypress/platform/xss3.html .cache +.pnpm-store coverage # Autogenerated by PNPM pnpm-lock.yaml diff --git a/.prettierrc.json b/.prettierrc.json index 4f0588f9cf..28aa6e7660 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,5 +3,6 @@ "printWidth": 100, "singleQuote": true, "useTabs": false, - "tabWidth": 2 + "tabWidth": 2, + "trailingComma": "es5" } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9633bed665..4923342e4a 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,7 +2,7 @@ "recommendations": [ "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", - "zixuanchen.vitest-explorer", + "vitest.explorer", "luniclynx.bison" ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 3142c57605..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,78 +0,0 @@ -# Contributing - -Please read in detail about how to contribute documentation and code on the [Mermaid documentation site.](https://mermaid-js.github.io/mermaid/#/development) - ---- - -# Mermaid contribution cheat-sheet - -## 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 - -If you don't have direct access to push to mermaid repositories, make a fork first. Then clone. Or clone directly from mermaid-js: - -```bash -git clone git@github.com:mermaid-js/mermaid.git -cd mermaid -``` - -Install required packages: - -```bash -# npx is required for first install as volta support for pnpm is not added yet. -npx pnpm install -pnpm test # run unit tests -pnpm dev # starts a dev server -``` - -Open in your browser after starting the dev server. -You can also duplicate the `example.html` file in `demos/dev`, rename it and add your own mermaid code to it. -That will be served at . - -### Docker - -If you are using docker and docker-compose, you have self-documented `run` bash script, which is a convenient alias for docker-compose commands: - -```bash -./run install # npx pnpm install -./run test # pnpm test -``` - -## Testing - -```bash -# Run unit test -pnpm test -# Run unit test in watch mode -pnpm test:watch -# Run E2E test -pnpm e2e -# Debug E2E tests -pnpm dev -pnpm cypress:open # in another terminal -``` - -## Branch name format: - -```text - [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces] -``` - -eg: `feature/2945_state-diagram-new-arrow-florbs`, `bug/1123_fix_random_ugly_red_text` - -## Documentation - -Documentation is necessary for all non bugfix/refactoring changes. - -Only make changes to files that are in [`/packages/mermaid/src/docs`](packages/mermaid/src/docs) - -**_DO NOT CHANGE FILES IN `/docs` MANUALLY_** - -The `/docs` folder will be rebuilt and committed as part of a pre-commit hook. - -[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 120000 index 0000000000..885868c167 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +./packages/mermaid/src/docs/community/contributing.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..1cc9ef0306 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM node:20.11.1-alpine3.19 AS base +RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh - diff --git a/README.md b/README.md index cf21fdb8e6..d368a43499 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Generate diagrams from markdown-like text. Live Editor!

- 📖 Documentation | 🚀 Getting Started | 🌐 CDN | 🙌 Join Us + 📖 Documentation | 🚀 Getting Started | 🌐 CDN | 🙌 Join Us

简体中文 @@ -33,7 +33,7 @@ Try Live Editor previews of future releases: @@ -42,7 +42,7 @@ Try Live Editor previews of future releases: Explore Mermaid.js in depth, with real-world examples, tips & tricks from the creator... The first official book on Mermaid is available for purchase. Check it out! +Explore Mermaid.js in depth, with real-world examples, tips & tricks from the creator... The first official book on Mermaid is available for purchase. Check it out! ## Table of content @@ -53,7 +53,7 @@ Try Live Editor previews of future releases: docs - live editor] +### Flowchart [docs - live editor] ``` flowchart LR @@ -115,12 +115,12 @@ C -->|One| D[Result 1] C -->|Two| E[Result 2] ``` -### Sequence diagram [docs - live editor] +### Sequence diagram [docs - live editor] ``` sequenceDiagram Alice->>John: Hello John, how are you? -loop Healthcheck +loop HealthCheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts! @@ -132,7 +132,7 @@ Bob-->>John: Jolly good! ```mermaid sequenceDiagram Alice->>John: Hello John, how are you? -loop Healthcheck +loop HealthCheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts! @@ -141,7 +141,7 @@ John->>Bob: How about you? Bob-->>John: Jolly good! ``` -### Gantt chart [docs - live editor] +### Gantt chart [docs - live editor] ``` gantt @@ -165,7 +165,7 @@ gantt Parallel 4 : des6, after des4, 1d ``` -### Class diagram [docs - live editor] +### Class diagram [docs - live editor] ``` classDiagram @@ -207,7 +207,7 @@ class Class10 { ``` -### State diagram [docs - live editor] +### State diagram [docs - live editor] ``` stateDiagram-v2 @@ -229,7 +229,7 @@ Moving --> Crash Crash --> [*] ``` -### Pie chart [docs - live editor] +### Pie chart [docs - live editor] ``` pie @@ -247,7 +247,7 @@ pie ### Git graph [experimental - live editor] -### Bar chart (using gantt chart) [docs - live editor] +### Bar chart (using gantt chart) [docs - live editor] ``` gantt @@ -285,7 +285,7 @@ gantt 5 : 0, 5 ``` -### User Journey diagram [docs - live editor] +### User Journey diagram [docs - live editor] ``` journey @@ -311,7 +311,7 @@ gantt Sit down: 3: Me ``` -### C4 diagram [docs] +### C4 diagram [docs] ``` C4Context @@ -405,7 +405,7 @@ The above command generates files into the `dist` folder and publishes them to < Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out. -Detailed information about how to contribute can be found in the [contribution guide](CONTRIBUTING.md) +Detailed information about how to contribute can be found in the [contribution guide](https://mermaid.js.org/community/contributing.html) ## Security and safe diagrams diff --git a/README.zh-CN.md b/README.zh-CN.md index 98975ea331..942f54bff9 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -15,7 +15,7 @@ Mermaid 实时编辑器!

- 📖 文档 | 🚀 入门 | 🌐 CDN | 🙌 加入我们 + 📖 文档 | 🚀 入门 | 🌐 CDN | 🙌 加入我们

English @@ -34,7 +34,7 @@ Mermaid [![Coverage Status](https://codecov.io/github/mermaid-js/mermaid/branch/develop/graph/badge.svg)](https://app.codecov.io/github/mermaid-js/mermaid/tree/develop) [![CDN Status](https://img.shields.io/jsdelivr/npm/hm/mermaid)](https://www.jsdelivr.com/package/npm/mermaid) [![NPM Downloads](https://img.shields.io/npm/dm/mermaid)](https://www.npmjs.com/package/mermaid) -[![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[![Join our Discord!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=discord&label=discord)](https://discord.gg/AgrbSrBer3) [![Twitter Follow](https://img.shields.io/badge/Social-mermaidjs__-blue?style=social&logo=X)](https://twitter.com/mermaidjs_) @@ -43,7 +43,7 @@ Mermaid **感谢所有参与进来提交 PR,解答疑问的人们! 🙏** -Explore Mermaid.js in depth, with real-world examples, tips & tricks from the creator... The first official book on Mermaid is available for purchase. Check it out! +Explore Mermaid.js in depth, with real-world examples, tips & tricks from the creator... The first official book on Mermaid is available for purchase. Check it out! ## 关于 Mermaid @@ -57,20 +57,20 @@ Mermaid 是一个基于 Javascript 的图表绘制工具,通过解析类 Markd Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它也可以作为生产脚本(或其他代码)的一部分。

Mermaid 甚至能让非程序员也能通过 [Mermaid Live Editor](https://mermaid.live/) 轻松创建详细的图表。
-你可以访问 [教程](./docs/config/Tutorials.md) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](./docs/ecosystem/integrations-community.md) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 +你可以访问 [教程](https://mermaid.js.org/ecosystem/tutorials.html) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](https://mermaid.js.org/ecosystem/integrations-community.html) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 -如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/intro/getting-started.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). +如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](https://mermaid.js.org/intro/getting-started.html), [用法](https://mermaid.js.org/config/usage.html) 和 [教程](https://mermaid.js.org/ecosystem/tutorials.html). ## 示例 -**下面是一些可以使用 Mermaid 创建的图表示例。点击 [语法](https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference) 查看详情。** +**下面是一些可以使用 Mermaid 创建的图表示例。点击 [语法](https://mermaid.js.org/intro/syntax-reference.html) 查看详情。** -### 流程图 [文档 - live editor] +### 流程图 [文档 - live editor] ``` flowchart LR @@ -88,12 +88,12 @@ C -->|One| D[Result 1] C -->|Two| E[Result 2] ``` -### 时序图 [文档 - live editor] +### 时序图 [文档 - live editor] ``` sequenceDiagram Alice->>John: Hello John, how are you? -loop Healthcheck +loop HealthCheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts! @@ -105,7 +105,7 @@ Bob-->>John: Jolly good! ```mermaid sequenceDiagram Alice->>John: Hello John, how are you? -loop Healthcheck +loop HealthCheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts! @@ -114,7 +114,7 @@ John->>Bob: How about you? Bob-->>John: Jolly good! ``` -### 甘特图 [文档 - live editor] +### 甘特图 [文档 - live editor] ``` gantt @@ -138,7 +138,7 @@ gantt Parallel 4 : des6, after des4, 1d ``` -### 类图 [文档 - live editor] +### 类图 [文档 - live editor] ``` classDiagram @@ -178,7 +178,7 @@ class Class10 { } ``` -### 状态图 [[docs - live editor] +### 状态图 [docs - live editor] ``` stateDiagram-v2 @@ -200,7 +200,7 @@ Moving --> Crash Crash --> [*] ``` -### 饼图 [文档 - live editor] +### 饼图 [文档 - live editor] ``` pie @@ -218,7 +218,7 @@ pie ### Git 图 [实验特性 - live editor] -### 用户体验旅程图 [文档 - live editor] +### 用户体验旅程图 [文档 - live editor] ``` journey @@ -244,7 +244,7 @@ pie Sit down: 3: Me ``` -### C4 图 [文档] +### C4 图 [文档] ``` C4Context @@ -338,7 +338,7 @@ npm publish Mermaid 是一个不断发展中的社区,并且还在接收新的贡献者。有很多不同的方式可以参与进来,而且我们还在寻找额外的帮助。如果你想知道如何开始贡献,请查看 [这个 issue](https://github.com/mermaid-js/mermaid/issues/866)。 -关于如何贡献的详细信息可以在 [贡献指南](CONTRIBUTING.md) 中找到。 +关于如何贡献的详细信息可以在 [贡献指南](https://mermaid.js.org/community/contributing.html) 中找到。 ## 安全 diff --git a/__mocks__/c4Renderer.js b/__mocks__/c4Renderer.js deleted file mode 100644 index 576d5d8634..0000000000 --- a/__mocks__/c4Renderer.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Mocked C4Context diagram renderer - */ - -import { vi } from 'vitest'; - -export const drawPersonOrSystemArray = vi.fn(); -export const drawBoundary = vi.fn(); - -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - drawPersonOrSystemArray, - drawBoundary, - setConf, - draw, -}; diff --git a/__mocks__/classRenderer-v2.js b/__mocks__/classRenderer-v2.js deleted file mode 100644 index 1ad95806fc..0000000000 --- a/__mocks__/classRenderer-v2.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Mocked class diagram v2 renderer - */ - -import { vi } from 'vitest'; - -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - draw, -}; diff --git a/__mocks__/classRenderer.js b/__mocks__/classRenderer.js deleted file mode 100644 index 1c20de4b18..0000000000 --- a/__mocks__/classRenderer.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Mocked class diagram renderer - */ - -import { vi } from 'vitest'; - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - draw, -}; diff --git a/__mocks__/dagre-d3.ts b/__mocks__/dagre-d3.ts deleted file mode 100644 index bf6d341dc5..0000000000 --- a/__mocks__/dagre-d3.ts +++ /dev/null @@ -1 +0,0 @@ -// DO NOT delete this file. It is used by vitest to mock the dagre-d3 module. diff --git a/__mocks__/entity-decode/browser.ts b/__mocks__/entity-decode/browser.ts deleted file mode 100644 index bd82d79fd9..0000000000 --- a/__mocks__/entity-decode/browser.ts +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function (txt: string) { - return txt; -}; diff --git a/__mocks__/erRenderer.js b/__mocks__/erRenderer.js deleted file mode 100644 index 845d641f75..0000000000 --- a/__mocks__/erRenderer.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Mocked er diagram renderer - */ - -import { vi } from 'vitest'; - -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - draw, -}; diff --git a/__mocks__/flowRenderer-v2.js b/__mocks__/flowRenderer-v2.js deleted file mode 100644 index 89cc86031e..0000000000 --- a/__mocks__/flowRenderer-v2.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Mocked flow (flowchart) diagram v2 renderer - */ - -import { vi } from 'vitest'; - -export const setConf = vi.fn(); -export const addVertices = vi.fn(); -export const addEdges = vi.fn(); -export const getClasses = vi.fn().mockImplementation(() => { - return {}; -}); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - addVertices, - addEdges, - getClasses, - draw, -}; diff --git a/__mocks__/ganttRenderer.js b/__mocks__/ganttRenderer.js deleted file mode 100644 index 9572498321..0000000000 --- a/__mocks__/ganttRenderer.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Mocked gantt diagram renderer - */ - -import { vi } from 'vitest'; - -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - draw, -}; diff --git a/__mocks__/gitGraphRenderer.js b/__mocks__/gitGraphRenderer.js deleted file mode 100644 index 1daa82ca4c..0000000000 --- a/__mocks__/gitGraphRenderer.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Mocked git (graph) diagram renderer - */ - -import { vi } from 'vitest'; - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - draw, -}; diff --git a/__mocks__/journeyRenderer.js b/__mocks__/journeyRenderer.js deleted file mode 100644 index 2bc77c0b10..0000000000 --- a/__mocks__/journeyRenderer.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Mocked pie (picChart) diagram renderer - */ - -import { vi } from 'vitest'; -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - draw, -}; diff --git a/__mocks__/pieRenderer.ts b/__mocks__/pieRenderer.ts deleted file mode 100644 index 439800f8c5..0000000000 --- a/__mocks__/pieRenderer.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Mocked pie (picChart) diagram renderer - */ -import { vi } from 'vitest'; - -const draw = vi.fn().mockImplementation(() => ''); - -export const renderer = { draw }; diff --git a/__mocks__/requirementRenderer.js b/__mocks__/requirementRenderer.js deleted file mode 100644 index 48d8997ac1..0000000000 --- a/__mocks__/requirementRenderer.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Mocked requirement diagram renderer - */ - -import { vi } from 'vitest'; - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - draw, -}; diff --git a/__mocks__/sankeyRenderer.js b/__mocks__/sankeyRenderer.js deleted file mode 100644 index 76324c93f1..0000000000 --- a/__mocks__/sankeyRenderer.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Mocked Sankey diagram renderer - */ - -import { vi } from 'vitest'; - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - draw, -}; diff --git a/__mocks__/sequenceRenderer.js b/__mocks__/sequenceRenderer.js deleted file mode 100644 index 11080c6bbf..0000000000 --- a/__mocks__/sequenceRenderer.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Mocked sequence diagram renderer - */ - -import { vi } from 'vitest'; - -export const bounds = vi.fn(); -export const drawActors = vi.fn(); -export const drawActorsPopup = vi.fn(); - -export const setConf = vi.fn(); - -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - bounds, - drawActors, - drawActorsPopup, - setConf, - draw, -}; diff --git a/__mocks__/stateRenderer-v2.js b/__mocks__/stateRenderer-v2.js deleted file mode 100644 index a2d103b50e..0000000000 --- a/__mocks__/stateRenderer-v2.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Mocked state diagram v2 renderer - */ - -import { vi } from 'vitest'; - -export const setConf = vi.fn(); -export const getClasses = vi.fn().mockImplementation(() => { - return {}; -}); -export const stateDomId = vi.fn().mockImplementation(() => { - return 'mocked-stateDiagram-stateDomId'; -}); -export const draw = vi.fn().mockImplementation(() => { - return ''; -}); - -export default { - setConf, - getClasses, - draw, -}; diff --git a/applitools.config.js b/applitools.config.js deleted file mode 100644 index 4cf02220ac..0000000000 --- a/applitools.config.js +++ /dev/null @@ -1,19 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { defineConfig } = require('cypress'); - -module.exports = defineConfig({ - testConcurrency: 1, - browser: [ - // Add browsers with different viewports - // { width: 800, height: 600, name: 'chrome' }, - // { width: 700, height: 500, name: 'firefox' }, - // { width: 1600, height: 1200, name: 'ie11' }, - // { width: 1024, height: 768, name: 'edgechromium' }, - // { width: 800, height: 600, name: 'safari' }, - // // Add mobile emulation devices in Portrait mode - // { deviceName: 'iPhone X', screenOrientation: 'portrait' }, - // { deviceName: 'Pixel 2', screenOrientation: 'portrait' }, - ], - // set batch name to the configuration - // batchName: `Mermaid ${process.env.APPLI_BRANCH ?? "'no APPLI_BRANCH set'"}`, -}); diff --git a/cSpell.json b/cSpell.json deleted file mode 100644 index f60e7b3785..0000000000 --- a/cSpell.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "version": "0.2", - "language": "en", - "words": [ - "acyclicer", - "adamiecki", - "alois", - "aloisklink", - "antiscript", - "antlr", - "appli", - "applitools", - "asciidoctor", - "ashish", - "ashishjain", - "astah", - "bbox", - "bilkent", - "bisheng", - "blrs", - "braintree", - "brkt", - "brolin", - "brotli", - "catmull", - "città", - "classdef", - "codedoc", - "colour", - "commitlint", - "cpettitt", - "customizability", - "cuzon", - "cytoscape", - "dagre", - "deepdwn", - "descr", - "docsify", - "docsy", - "doku", - "dompurify", - "dont", - "doublecircle", - "edgechromium", - "elems", - "elkjs", - "elle", - "faber", - "flatmap", - "foswiki", - "frontmatter", - "ftplugin", - "gantt", - "gitea", - "gitgraph", - "globby", - "graphlib", - "graphviz", - "grav", - "greywolf", - "gzipped", - "huynh", - "huynhicode", - "iife", - "inkdrop", - "jaoude", - "jgreywolf", - "jison", - "jiti", - "kaufmann", - "khroma", - "klemm", - "klink", - "knsv", - "knut", - "knutsveidqvist", - "laganeckas", - "langium", - "linetype", - "lintstagedrc", - "logmsg", - "lucida", - "markdownish", - "matthieu", - "matthieumorel", - "mdast", - "mdbook", - "mermaidjs", - "mermerd", - "metafile", - "mindaugas", - "mindmap", - "mindmaps", - "mitigations", - "mkdocs", - "mmorel", - "mult", - "neurodiverse", - "nextra", - "nikolay", - "nirname", - "npmjs", - "orlandoni", - "outdir", - "pathe", - "pbrolin", - "phpbb", - "plantuml", - "playfair", - "pnpm", - "podlite", - "quence", - "radious", - "ranksep", - "rect", - "rects", - "reda", - "redmine", - "regexes", - "rehype", - "roledescription", - "rozhkov", - "sandboxed", - "sankey", - "setupgraphviewbox", - "shiki", - "sidharth", - "sidharthv", - "sphinxcontrib", - "startx", - "starty", - "statediagram", - "steph", - "stopx", - "stopy", - "stylis", - "subhash-halder", - "substate", - "sulais", - "sveidqvist", - "swimm", - "techn", - "teststr", - "textlength", - "treemap", - "ts-nocheck", - "tsdoc", - "tuleap", - "tylerlong", - "typora", - "ugge", - "unist", - "unocss", - "upvoting", - "valign", - "verdana", - "viewports", - "vinod", - "visio", - "vitepress", - "vueuse", - "xlink", - "xychart", - "yash", - "yokozuna", - "zenuml", - "zune" - ], - "patterns": [ - { "name": "Markdown links", "pattern": "\\((.*)\\)", "description": "" }, - { - "name": "Markdown code blocks", - "pattern": "/^(\\s*`{3,}).*[\\s\\S]*?^\\1/gmx", - "description": "Taken from the cSpell example at https://cspell.org/configuration/patterns/#verbose-regular-expressions" - }, - { - "name": "Inline code blocks", - "pattern": "\\`([^\\`\\r\\n]+?)\\`", - "description": "https://stackoverflow.com/questions/41274241/how-to-capture-inline-markdown-code-but-not-a-markdown-code-fence-with-regex" - }, - { "name": "Link contents", "pattern": "\\", "description": "" }, - { "name": "Snippet references", "pattern": "-- snippet:(.*)", "description": "" }, - { - "name": "Snippet references 2", - "pattern": "\\<\\[sample:(.*)", - "description": "another kind of snippet reference" - }, - { "name": "Multi-line code blocks", "pattern": "/^\\s*```[\\s\\S]*?^\\s*```/gm" }, - { - "name": "HTML Tags", - "pattern": "<[^>]*>", - "description": "Reference: https://stackoverflow.com/questions/11229831/regular-expression-to-remove-html-tags-from-a-string" - } - ], - "ignoreRegExpList": [ - "Markdown links", - "Markdown code blocks", - "Inline code blocks", - "Link contents", - "Snippet references", - "Snippet references 2", - "Multi-line code blocks", - "HTML Tags" - ], - "ignorePaths": [ - "packages/mermaid/src/docs/CHANGELOG.md", - "packages/mermaid/src/docs/.vitepress/redirect.ts", - "packages/mermaid/src/docs/.vitepress/contributor-names.json" - ] -} diff --git a/cspell.config.yaml b/cspell.config.yaml new file mode 100644 index 0000000000..885a41afd8 --- /dev/null +++ b/cspell.config.yaml @@ -0,0 +1,45 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json + +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: '0.2' +language: en-US,en-GB + +import: + - ./.cspell/cspell.config.yaml + +ignoreRegExpList: + - character-set-cyrillic + - svg-block +ignorePaths: + - '*lock.{yaml,json}' + - dist + - CHANGELOG.md + - packages/mermaid/src/docs/.vitepress/redirect.ts + - packages/mermaid/src/docs/.vitepress/contributor-names.json + - backup + - '**/*.spec.{js,ts}' # checked by eslint + - 'tests/webpack/src/index.js' # checked by eslint + - 'cypress/**/*.js' # checked by eslint + - '*.csv' + - '*.patch' + - 'docs/**/*.html' + - 'cypress/platform/**' +dictionaries: + - misc-terms +overrides: + - filename: + - '**/*.{jison,ts,mts,cjs,mjs,js,json,yaml,yml,md,html}' + - 'run' + - Dockerfile + ignoreRegExpList: + - js-unicode-escape + dictionaries: + - code-terms + - 3rd-party-terms + - fonts + - html + - lorem-ipsum + - filename: '**/package.json' + ignoreRegExpList: + - json-property +# cspell:dictionaries code-terms diff --git a/cypress.config.cjs b/cypress.config.cjs deleted file mode 100644 index 30076c56ef..0000000000 --- a/cypress.config.cjs +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ - -const { defineConfig } = require('cypress'); -const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin'); -const coverage = require('@cypress/code-coverage/task'); - -module.exports = defineConfig({ - projectId: 'n2sma2', - e2e: { - specPattern: 'cypress/integration/**/*.{js,jsx,ts,tsx}', - setupNodeEvents(on, config) { - coverage(on, config); - addMatchImageSnapshotPlugin(on, config); - // copy any needed variables from process.env to config.env - config.env.useAppli = process.env.USE_APPLI ? true : false; - - // do not forget to return the changed config object! - return config; - }, - }, - video: false, -}); - -require('@applitools/eyes-cypress')(module); diff --git a/cypress.config.ts b/cypress.config.ts new file mode 100644 index 0000000000..4182d92a87 --- /dev/null +++ b/cypress.config.ts @@ -0,0 +1,30 @@ +import { defineConfig } from 'cypress'; +import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin'; +import coverage from '@cypress/code-coverage/task'; +import eyesPlugin from '@applitools/eyes-cypress'; +export default eyesPlugin( + defineConfig({ + projectId: 'n2sma2', + viewportWidth: 1440, + viewportHeight: 1024, + e2e: { + specPattern: 'cypress/integration/**/*.{js,ts}', + setupNodeEvents(on, config) { + coverage(on, config); + on('before:browser:launch', (browser, launchOptions) => { + if (browser.name === 'chrome' && browser.isHeadless) { + launchOptions.args.push('--window-size=1440,1024', '--force-device-scale-factor=1'); + } + return launchOptions; + }); + addMatchImageSnapshotPlugin(on, config); + // copy any needed variables from process.env to config.env + config.env.useAppli = process.env.USE_APPLI ? true : false; + + // do not forget to return the changed config object! + return config; + }, + }, + video: false, + }) +); diff --git a/cypress/helpers/util.ts b/cypress/helpers/util.ts index c656f638da..aed5d7973c 100644 --- a/cypress/helpers/util.ts +++ b/cypress/helpers/util.ts @@ -10,7 +10,7 @@ interface CypressConfig { type CypressMermaidConfig = MermaidConfig & CypressConfig; interface CodeObject { - code: string; + code: string | string[]; mermaid: CypressMermaidConfig; } @@ -25,7 +25,7 @@ const batchId: string = : Cypress.env('CYPRESS_COMMIT') || Date.now().toString()); export const mermaidUrl = ( - graphStr: string, + graphStr: string | string[], options: CypressMermaidConfig, api: boolean ): string => { @@ -82,7 +82,7 @@ export const urlSnapshotTest = ( }; export const renderGraph = ( - graphStr: string, + graphStr: string | string[], options: CypressMermaidConfig = {}, api = false ): void => { diff --git a/cypress/integration/other/configuration.spec.js b/cypress/integration/other/configuration.spec.js index 7cbc5d1059..9fd0815676 100644 --- a/cypress/integration/other/configuration.spec.js +++ b/cypress/integration/other/configuration.spec.js @@ -117,7 +117,6 @@ describe('Configuration', () => { }); it('should not taint the initial configuration when using multiple directives', () => { const url = 'http://localhost:9000/regression/issue-1874.html'; - cy.viewport(1440, 1024); cy.visit(url); cy.get('svg'); @@ -126,4 +125,46 @@ describe('Configuration', () => { ); }); }); + + describe('suppressErrorRendering', () => { + beforeEach(() => { + cy.on('uncaught:exception', (err, runnable) => { + return !err.message.includes('Parse error on line'); + }); + }); + + it('should not render error diagram if suppressErrorRendering is set', () => { + const url = 'http://localhost:9000/suppressError.html?suppressErrorRendering=true'; + cy.visit(url); + cy.window().should('have.property', 'rendered', true); + cy.get('#test') + .find('svg') + .should(($svg) => { + // all failing diagrams should not appear! + expect($svg).to.have.length(2); + // none of the diagrams should be error diagrams + expect($svg).to.not.contain('Syntax error'); + }); + cy.matchImageSnapshot( + 'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set' + ); + }); + + it('should render error diagram if suppressErrorRendering is not set', () => { + const url = 'http://localhost:9000/suppressError.html'; + cy.visit(url); + cy.window().should('have.property', 'rendered', true); + cy.get('#test') + .find('svg') + .should(($svg) => { + // all five diagrams should be rendered + expect($svg).to.have.length(5); + // some of the diagrams should be error diagrams + expect($svg).to.contain('Syntax error'); + }); + cy.matchImageSnapshot( + 'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set' + ); + }); + }); }); diff --git a/cypress/integration/other/rerender.spec.js b/cypress/integration/other/rerender.spec.js index f160a2e273..d14c6257e0 100644 --- a/cypress/integration/other/rerender.spec.js +++ b/cypress/integration/other/rerender.spec.js @@ -1,14 +1,12 @@ describe('Rerendering', () => { it('should be able to render after an error has occurred', () => { const url = 'http://localhost:9000/render-after-error.html'; - cy.viewport(1440, 1024); cy.visit(url); cy.get('#graphDiv').should('exist'); }); it('should be able to render and rerender a graph via API', () => { const url = 'http://localhost:9000/rerender.html'; - cy.viewport(1440, 1024); cy.visit(url); cy.get('#graph [id^=flowchart-A]').should('have.text', 'XMas'); diff --git a/cypress/integration/rendering/block.spec.js b/cypress/integration/rendering/block.spec.js new file mode 100644 index 0000000000..9d62c642dc --- /dev/null +++ b/cypress/integration/rendering/block.spec.js @@ -0,0 +1,386 @@ +import { imgSnapshotTest } from '../../helpers/util'; +/* eslint-disable no-useless-escape */ +describe('Block diagram', () => { + it('BL1: should calculate the block widths', () => { + imgSnapshotTest( + `block-beta + columns 2 + block + id2["I am a wide one"] + id1 + end + id["Next row"] + ` + ); + }); + + it('BL2: should handle colums statement in sub-blocks', () => { + imgSnapshotTest( + `block-beta + id1["Hello"] + block + columns 3 + id2["to"] + id3["the"] + id4["World"] + id5["World"] + end + `, + {} + ); + }); + + it('BL3: should align block widths and handle colums statement in sub-blocks', () => { + imgSnapshotTest( + `block-beta + block + columns 1 + id1 + id2 + id2.1 + end + id3 + id4 + `, + {} + ); + }); + + it('BL4: should align block widths and handle colums statements in deeper sub-blocks then 1 level', () => { + imgSnapshotTest( + `block-beta + columns 1 + block + columns 1 + block + columns 3 + id1 + id2 + id2.1(("XYZ")) + end + id48 + end + id3 + `, + {} + ); + }); + + it('BL5: should align block widths and handle colums statements in deeper sub-blocks then 1 level (alt)', () => { + imgSnapshotTest( + `block-beta + columns 1 + block + id1 + id2 + block + columns 1 + id3("Wider then") + id5(("id5")) + end + end + id4 + `, + {} + ); + }); + + it('BL6: should handle block arrows and spece statements', () => { + imgSnapshotTest( + `block-beta + columns 3 + space:3 + ida idb idc + id1 id2 + blockArrowId<["Label"]>(right) + blockArrowId2<["Label"]>(left) + blockArrowId3<["Label"]>(up) + blockArrowId4<["Label"]>(down) + blockArrowId5<["Label"]>(x) + blockArrowId6<["Label"]>(y) + blockArrowId6<["Label"]>(x, down) + `, + {} + ); + }); + + it('BL7: should handle different types of edges', () => { + imgSnapshotTest( + `block-beta + columns 3 + A space:5 + A --o B + A --> C + A --x D + `, + {} + ); + }); + + it('BL8: should handle sub-blocks without columns statements', () => { + imgSnapshotTest( + `block-beta + columns 2 + C A B + block + D + E + end + `, + {} + ); + }); + + it('BL9: should handle edges from blocks in sub blocks to other blocks', () => { + imgSnapshotTest( + `block-beta + columns 3 + B space + block + D + end + D --> B + `, + {} + ); + }); + + it('BL10: should handle edges from composite blocks', () => { + imgSnapshotTest( + `block-beta + columns 3 + B space + block BL + D + end + BL --> B + `, + {} + ); + }); + + it('BL11: should handle edges to composite blocks', () => { + imgSnapshotTest( + `block-beta + columns 3 + B space + block BL + D + end + B --> BL + `, + {} + ); + }); + + it('BL12: edges should handle labels', () => { + imgSnapshotTest( + `block-beta + A + space + A -- "apa" --> E + `, + {} + ); + }); + + it('BL13: should handle block arrows in different directions', () => { + imgSnapshotTest( + `block-beta + columns 3 + space blockArrowId1<["down"]>(down) space + blockArrowId2<["right"]>(right) blockArrowId3<["Sync"]>(x, y) blockArrowId4<["left"]>(left) + space blockArrowId5<["up"]>(up) space + blockArrowId6<["x"]>(x) space blockArrowId7<["y"]>(y) + `, + {} + ); + }); + + it('BL14: should style statements and class statements', () => { + imgSnapshotTest( + `block-beta + A + B + classDef blue fill:#66f,stroke:#333,stroke-width:2px; + class A blue + style B fill:#f9F,stroke:#333,stroke-width:4px + `, + {} + ); + }); + + it('BL15: width alignment - D and E should share available space', () => { + imgSnapshotTest( + `block-beta + block + D + E + end + db("This is the text in the box") + `, + {} + ); + }); + + it('BL16: width alignment - C should be as wide as the composite block', () => { + imgSnapshotTest( + `block-beta + block + A("This is the text") + B + end + C + `, + {} + ); + }); + + it('BL16: width alignment - blocks shold be equal in width', () => { + imgSnapshotTest( + `block-beta + A("This is the text") + B + C + `, + {} + ); + }); + + it('BL17: block types 1 - square, rounded and circle', () => { + imgSnapshotTest( + `block-beta + A["square"] + B("rounded") + C(("circle")) + `, + {} + ); + }); + + it('BL18: block types 2 - odd, diamond and hexagon', () => { + imgSnapshotTest( + `block-beta + A>"rect_left_inv_arrow"] + B{"diamond"} + C{{"hexagon"}} + `, + {} + ); + }); + + it('BL19: block types 3 - stadium', () => { + imgSnapshotTest( + `block-beta + A(["stadium"]) + `, + {} + ); + }); + + it('BL20: block types 4 - lean right, lean left, trapezoid and inv trapezoid', () => { + imgSnapshotTest( + `block-beta + A[/"lean right"/] + B[\"lean left"\] + C[/"trapezoid"\] + D[\"trapezoid alt"/] + `, + {} + ); + }); + + it('BL21: block types 1 - square, rounded and circle', () => { + imgSnapshotTest( + `block-beta + A["square"] + B("rounded") + C(("circle")) + `, + {} + ); + }); + + it('BL22: sizing - it should be possible to make a block wider', () => { + imgSnapshotTest( + `block-beta + A("rounded"):2 + B:2 + C + `, + {} + ); + }); + + it('BL23: sizing - it should be possible to make a composite block wider', () => { + imgSnapshotTest( + `block-beta + block:2 + A + end + B + `, + {} + ); + }); + + it('BL24: block in the middle with space on each side', () => { + imgSnapshotTest( + `block-beta + columns 3 + space + middle["In the middle"] + space + `, + {} + ); + }); + it('BL25: space and an edge', () => { + imgSnapshotTest( + `block-beta + columns 5 + A space B + A --x B + `, + {} + ); + }); + it('BL26: block sizes for regular blocks', () => { + imgSnapshotTest( + `block-beta + columns 3 + a["A wide one"] b:2 c:2 d + `, + {} + ); + }); + it('BL27: composite block with a set width - f should use the available space', () => { + imgSnapshotTest( + `block-beta + columns 3 + a:3 + block:e:3 + f + end + g + `, + {} + ); + }); + it('BL23: composite block with a set width - f and g should split the available space', () => { + imgSnapshotTest( + `block-beta + columns 3 + a:3 + block:e:3 + f + g + end + h + i + j + `, + {} + ); + }); +}); diff --git a/cypress/integration/rendering/classDiagram-v2.spec.js b/cypress/integration/rendering/classDiagram-v2.spec.js index 37e9cada02..20a1aea0ab 100644 --- a/cypress/integration/rendering/classDiagram-v2.spec.js +++ b/cypress/integration/rendering/classDiagram-v2.spec.js @@ -571,4 +571,14 @@ class C13["With Città foreign language"] { logLevel: 1, flowchart: { htmlLabels: false } } ); }); + it('should render a simple class diagram with style definition', () => { + imgSnapshotTest( + ` + classDiagram-v2 + class Class10 + style Class10 fill:#f9f,stroke:#333,stroke-width:4px + `, + { logLevel: 1, flowchart: { htmlLabels: false } } + ); + }); }); diff --git a/cypress/integration/rendering/debug.spec.js b/cypress/integration/rendering/debug.spec.js deleted file mode 100644 index 56ad0f15f8..0000000000 --- a/cypress/integration/rendering/debug.spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import { imgSnapshotTest } from '../../helpers/util.ts'; - -describe('Flowchart', () => { - it('34: testing the label width in percy', () => { - imgSnapshotTest( - `graph TD - A[Christmas] - `, - { theme: 'forest', fontFamily: '"Noto Sans SC", sans-serif' } - ); - }); -}); diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index e23820ffa3..857d395be7 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -741,6 +741,25 @@ A ~~~ B ); }); + it('5059: Should render when subgraph contains only subgraphs, has link to outside and itself is part of a link', () => { + imgSnapshotTest( + `flowchart + + subgraph Main + subgraph Child1 + Node1 + Node2 + end + subgraph Child2 + Node3 + Node4 + end + end + Main --> Out1 + Child2 --> Out2` + ); + }); + describe('Markdown strings flowchart (#4220)', () => { describe('html labels', () => { it('With styling and classes', () => { diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 998a092c24..a0c2dbcb9e 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -92,6 +92,31 @@ describe('Gantt diagram', () => { {} ); }); + it('should handle multiple dependencies syntax with after and until', () => { + imgSnapshotTest( + ` + gantt + dateFormat YYYY-MM-DD + axisFormat %d/%m + title Adding GANTT diagram to mermaid + excludes weekdays 2014-01-10 + todayMarker off + + section team's critical event + deadline A :milestone, crit, deadlineA, 2024-02-01, 0 + deadline B :milestone, crit, deadlineB, 2024-02-15, 0 + boss on leave :bossaway, 2024-01-28, 2024-02-11 + + section new intern + onboarding :onboarding, 2024-01-02, 1w + literature review :litreview, 2024-01-02, 10d + project A :projectA, after onboarding litreview, until deadlineA bossaway + chilling :chilling, after projectA, until deadlineA + project B :projectB, after deadlineA, until deadlineB + `, + {} + ); + }); it('should FAIL redering a gantt chart for issue #1060 with invalid date', () => { imgSnapshotTest( ` @@ -245,7 +270,10 @@ describe('Gantt diagram', () => { const style = svg.attr('style'); expect(style).to.match(/^max-width: [\d.]+px;$/); const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); - expect(maxWidthValue).to.be.within(984 * 0.95, 984 * 1.05); + expect(maxWidthValue).to.be.within( + Cypress.config().viewportWidth * 0.95, + Cypress.config().viewportWidth * 1.05 + ); }); }); @@ -285,11 +313,11 @@ describe('Gantt diagram', () => { { gantt: { useMaxWidth: false } } ); cy.get('svg').should((svg) => { - // const height = parseFloat(svg.attr('height')); const width = parseFloat(svg.attr('width')); - // use within because the absolute value can be slightly different depending on the environment ±5% - // expect(height).to.be.within(484 * 0.95, 484 * 1.05); - expect(width).to.be.within(984 * 0.95, 984 * 1.05); + expect(width).to.be.within( + Cypress.config().viewportWidth * 0.95, + Cypress.config().viewportWidth * 1.05 + ); expect(svg).to.not.have.attr('style'); }); }); @@ -545,7 +573,28 @@ describe('Gantt diagram', () => { ` ); }); - + it('should render a gantt diagram exculding friday and saturday', () => { + imgSnapshotTest( + `gantt + title A Gantt Diagram + dateFormat YYYY-MM-DD + excludes weekends + weekend friday + section Section1 + A task :a1, 2024-02-28, 10d` + ); + }); + it('should render a gantt diagram exculding saturday and sunday', () => { + imgSnapshotTest( + `gantt + title A Gantt Diagram + dateFormat YYYY-MM-DD + excludes weekends + weekend saturday + section Section1 + A task :a1, 2024-02-28, 10d` + ); + }); it('should render when compact is true', () => { imgSnapshotTest( ` @@ -580,4 +629,106 @@ describe('Gantt diagram', () => { {} ); }); + + it("should render when there's a semicolon in the title", () => { + imgSnapshotTest( + ` + gantt + title ;Gantt With a Semicolon in the Title + dateFormat YYYY-MM-DD + section Section + A task :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); + + it("should render when there's a semicolon in a section is true", () => { + imgSnapshotTest( + ` + gantt + title Gantt Digram + dateFormat YYYY-MM-DD + section ;Section With a Semicolon + A task :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); + + it("should render when there's a semicolon in the task data", () => { + imgSnapshotTest( + ` + gantt + title Gantt Digram + dateFormat YYYY-MM-DD + section Section + ;A task with a semiclon :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); + + it("should render when there's a hashtag in the title", () => { + imgSnapshotTest( + ` + gantt + title #Gantt With a Hashtag in the Title + dateFormat YYYY-MM-DD + section Section + A task :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); + + it("should render when there's a hashtag in a section is true", () => { + imgSnapshotTest( + ` + gantt + title Gantt Digram + dateFormat YYYY-MM-DD + section #Section With a Hashtag + A task :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); + + it("should render when there's a hashtag in the task data", () => { + imgSnapshotTest( + ` + gantt + title Gantt Digram + dateFormat YYYY-MM-DD + section Section + #A task with a hashtag :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + another task : 24d + `, + {} + ); + }); }); diff --git a/cypress/integration/rendering/gitGraph.spec.js b/cypress/integration/rendering/gitGraph.spec.js index d3e4dd9dde..2184fecf88 100644 --- a/cypress/integration/rendering/gitGraph.spec.js +++ b/cypress/integration/rendering/gitGraph.spec.js @@ -826,4 +826,191 @@ gitGraph TB: cherry-pick id: "M" parent:"B"` ); }); + it('41: should render default GitGraph with parallelCommits set to false', () => { + imgSnapshotTest( + `gitGraph + commit id:"1-abcdefg" + commit id:"2-abcdefg" + branch develop + commit id:"3-abcdefg" + commit id:"4-abcdefg" + checkout main + branch feature + commit id:"5-abcdefg" + commit id:"6-abcdefg" + checkout main + commit id:"7-abcdefg" + commit id:"8-abcdefg" + `, + { gitGraph: { parallelCommits: false } } + ); + }); + it('42: should render GitGraph with parallel commits', () => { + imgSnapshotTest( + `gitGraph + commit id:"1-abcdefg" + commit id:"2-abcdefg" + branch develop + commit id:"3-abcdefg" + commit id:"4-abcdefg" + checkout main + branch feature + commit id:"5-abcdefg" + commit id:"6-abcdefg" + checkout main + commit id:"7-abcdefg" + commit id:"8-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('43: should render GitGraph with parallel commits | Vertical Branch', () => { + imgSnapshotTest( + `gitGraph TB: + commit id:"1-abcdefg" + commit id:"2-abcdefg" + branch develop + commit id:"3-abcdefg" + commit id:"4-abcdefg" + checkout main + branch feature + commit id:"5-abcdefg" + commit id:"6-abcdefg" + checkout main + commit id:"7-abcdefg" + commit id:"8-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('44: should render GitGraph with unconnected branches and no parallel commits', () => { + imgSnapshotTest( + `gitGraph + branch dev + branch v2 + branch feat + commit id:"1-abcdefg" + commit id:"2-abcdefg" + checkout main + commit id:"3-abcdefg" + checkout dev + commit id:"4-abcdefg" + checkout v2 + commit id:"5-abcdefg" + checkout main + commit id:"6-abcdefg" + `, + { gitGraph: { parallelCommits: false } } + ); + }); + it('45: should render GitGraph with unconnected branches and parallel commits', () => { + imgSnapshotTest( + `gitGraph + branch dev + branch v2 + branch feat + commit id:"1-abcdefg" + commit id:"2-abcdefg" + checkout main + commit id:"3-abcdefg" + checkout dev + commit id:"4-abcdefg" + checkout v2 + commit id:"5-abcdefg" + checkout main + commit id:"6-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('46: should render GitGraph with unconnected branches and parallel commits | Vertical Branch', () => { + imgSnapshotTest( + `gitGraph TB: + branch dev + branch v2 + branch feat + commit id:"1-abcdefg" + commit id:"2-abcdefg" + checkout main + commit id:"3-abcdefg" + checkout dev + commit id:"4-abcdefg" + checkout v2 + commit id:"5-abcdefg" + checkout main + commit id:"6-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('46: should render GitGraph with merge back and merge forward', () => { + imgSnapshotTest( + `gitGraph LR: + commit id:"1-abcdefg" + + branch branch-A + branch branch-B + commit id:"2-abcdefg" + + checkout branch-A + merge branch-B + + checkout branch-B + merge branch-A + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('47: should render GitGraph with merge back and merge forward | Vertical Branch', () => { + imgSnapshotTest( + `gitGraph TB: + commit id:"1-abcdefg" + + branch branch-A + branch branch-B + commit id:"2-abcdefg" + + checkout branch-A + merge branch-B + + checkout branch-B + merge branch-A + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('48: should render GitGraph with merge on a new branch | Vertical Branch', () => { + imgSnapshotTest( + `gitGraph LR: + commit id:"1-abcdefg" + + branch branch-B order: 2 + commit id:"2-abcdefg" + + branch branch-A + merge main + + checkout branch-B + merge branch-A + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('49: should render GitGraph with merge on a new branch | Vertical Branch', () => { + imgSnapshotTest( + `gitGraph TB: + commit id:"1-abcdefg" + + branch branch-B order: 2 + commit id:"2-abcdefg" + + branch branch-A + merge main + + checkout branch-B + merge branch-A + `, + { gitGraph: { parallelCommits: true } } + ); + }); }); diff --git a/cypress/integration/rendering/katex.spec.js b/cypress/integration/rendering/katex.spec.js new file mode 100644 index 0000000000..fb1d13392a --- /dev/null +++ b/cypress/integration/rendering/katex.spec.js @@ -0,0 +1,36 @@ +import { imgSnapshotTest } from '../../helpers/util'; + +describe('Katex', () => { + it('1: should render a complex Katex flowchart no htmlLabels', () => { + imgSnapshotTest( + `graph LR + A["$$f(\\relax{x}) = \\int_{-\\infty}^\\infty \\hat{f}(\\xi)\\,e^{2 \\pi i \\xi x}\\,d\\xi$$"] -->|"$$\\Bigg(\\bigg(\\Big(\\big((\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a})\\big)\\Big)\\bigg)\\Bigg)$$"| B("$$1+\\frac{e^{-2\\pi}} {1+\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}} {1+\\frac{e^{-8\\pi}} {1+\\cdots}}}}$$") + A -->|"$$\\overbrace{a+b+c}^{\\text{note}}$$"| C("$$\\phase{-78^\\circ}$$") + B --> D("$$x = \\begin{cases} a &\\text{if } b \\\\ c &\\text{if } d \\end{cases}$$") + C --> E("$$x(t)=c_1\\begin{bmatrix}-\\cos{t}+\\sin{t}\\\\ 2\\cos{t} \\end{bmatrix}e^{2t}$$")`, + { fontFamily: 'courier' } + ); + }); + it('2: should render a Katex flowchart containing the Greek alphabet', () => { + imgSnapshotTest( + `graph LR + A["$$\\alpha\\beta\\gamma\\delta\\epsilon\\zeta\\eta\\theta\\iota\\kappa\\lambda\\mu\\nu\\xi\\omicron\\pi\\rho\\sigma\\tau\\upsilon\\phi\\chi\\psi\\omega$$"] --> B["$$\\Alpha\\Beta\\Gamma\\Delta\\Epsilon\\Zeta\\Eta\\Theta\\Iota\\Kappa\\Lambda\\Mu\\Nu\\Xi\\Omicron\\Pi\\Rho\\Sigma\\Tau\\Upsilon\\Phi\\Chi\\Psi\\Omega$$"]`, + { fontFamily: 'courier' } + ); + }); + it('3: should render a Katex flowchart containing set theory symbols', () => { + imgSnapshotTest( + `graph LR + A["$$\\forall\\complement\\therefore\\emptyset\\exists\\subset\\because\\empty\\exist\\supset\\mapsto\\varnothing\\nexists\\mid\\to\\implies\\in\\land\\gets\\impliedby\\isin\\lor\\leftrightarrow\\iff\\notin\\ni\\notni\\lnot$$"] --> B["$$\\nabla\\Im\\Reals\\jmath\\partial\\image\\wp\\aleph\\Game\\weierp\\alef\\Finv\\N\\Z\\alefsym\\cnums\\natnums\\beth\\Complex\\R\\gimel\\ell\\Re\\daleth\\hbar\\real\\eth\\hslash\\reals$$"]`, + { fontFamily: 'courier' } + ); + }); + // TODO: changes made to develop between Feb 13 - Feb 23 cause this test to no longer function + // it.skip('4: should render an error box originating from Katex', () => { + // imgSnapshotTest( + // `graph LR + // A["$$\\shouldBeError$$"]`, + // { fontFamily: 'courier' } + // ); + // }); +}); diff --git a/cypress/integration/rendering/packet.spec.ts b/cypress/integration/rendering/packet.spec.ts new file mode 100644 index 0000000000..61555ea530 --- /dev/null +++ b/cypress/integration/rendering/packet.spec.ts @@ -0,0 +1,67 @@ +import { imgSnapshotTest } from '../../helpers/util'; + +describe('packet structure', () => { + it('should render a simple packet diagram', () => { + imgSnapshotTest( + `packet-beta + title Hello world + 0-10: "hello" +` + ); + }); + + it('should render a complex packet diagram', () => { + imgSnapshotTest( + `packet-beta + 0-15: "Source Port" + 16-31: "Destination Port" + 32-63: "Sequence Number" + 64-95: "Acknowledgment Number" + 96-99: "Data Offset" + 100-105: "Reserved" + 106: "URG" + 107: "ACK" + 108: "PSH" + 109: "RST" + 110: "SYN" + 111: "FIN" + 112-127: "Window" + 128-143: "Checksum" + 144-159: "Urgent Pointer" + 160-191: "(Options and Padding)" + 192-223: "data" + ` + ); + }); + + it('should render a complex packet diagram with showBits false', () => { + imgSnapshotTest( + ` + --- + title: "Packet Diagram" + config: + packet: + showBits: false + --- + packet-beta + 0-15: "Source Port" + 16-31: "Destination Port" + 32-63: "Sequence Number" + 64-95: "Acknowledgment Number" + 96-99: "Data Offset" + 100-105: "Reserved" + 106: "URG" + 107: "ACK" + 108: "PSH" + 109: "RST" + 110: "SYN" + 111: "FIN" + 112-127: "Window" + 128-143: "Checksum" + 144-159: "Urgent Pointer" + 160-191: "(Options and Padding)" + 192-223: "data" + ` + ); + }); +}); diff --git a/cypress/integration/rendering/sequencediagram.spec.js b/cypress/integration/rendering/sequencediagram.spec.js index 7659138241..1285a0832d 100644 --- a/cypress/integration/rendering/sequencediagram.spec.js +++ b/cypress/integration/rendering/sequencediagram.spec.js @@ -375,6 +375,29 @@ context('Sequence diagram', () => { {} ); }); + it('should have actor-top and actor-bottom classes on top and bottom actor box and symbol and actor-box and actor-man classes for text tags', () => { + imgSnapshotTest( + ` + sequenceDiagram + actor Bob + Alice->>Bob: Hi Bob + Bob->>Alice: Hi Alice + `, + {} + ); + cy.get('.actor').should('have.class', 'actor-top'); + cy.get('.actor-man').should('have.class', 'actor-top'); + cy.get('.actor.actor-top').should('not.have.class', 'actor-bottom'); + cy.get('.actor-man.actor-top').should('not.have.class', 'actor-bottom'); + + cy.get('.actor').should('have.class', 'actor-bottom'); + cy.get('.actor-man').should('have.class', 'actor-bottom'); + cy.get('.actor.actor-bottom').should('not.have.class', 'actor-top'); + cy.get('.actor-man.actor-bottom').should('not.have.class', 'actor-top'); + + cy.get('text.actor-box').should('include.text', 'Alice'); + cy.get('text.actor-man').should('include.text', 'Bob'); + }); it('should render long notes left of actor', () => { imgSnapshotTest( ` @@ -787,11 +810,42 @@ context('Sequence diagram', () => { note left of Alice: config: mirrorActors=true
directive: mirrorActors=false Bob->>Alice: Short as well `, - { logLevel: 0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } } + { + logLevel: 0, + sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' }, + } ); }); }); context('links', () => { + it('should support actor links', () => { + renderGraph( + ` + sequenceDiagram + link Alice: Dashboard @ https://dashboard.contoso.com/alice + link Alice: Wiki @ https://wiki.contoso.com/alice + link John: Dashboard @ https://dashboard.contoso.com/john + link John: Wiki @ https://wiki.contoso.com/john + Alice->>John: Hello John
+ John-->>Alice: Great

day! + `, + { securityLevel: 'loose' } + ); + cy.get('#actor0_popup').should((popupMenu) => { + const style = popupMenu.attr('style'); + expect(style).to.undefined; + }); + cy.get('#root-0').click(); + cy.get('#actor0_popup').should((popupMenu) => { + const style = popupMenu.attr('style'); + expect(style).to.match(/^display: block;$/); + }); + cy.get('#root-0').click(); + cy.get('#actor0_popup').should((popupMenu) => { + const style = popupMenu.attr('style'); + expect(style).to.match(/^display: none;$/); + }); + }); it('should support actor links and properties EXPERIMENTAL: USE WITH CAUTION', () => { //Be aware that the syntax for "properties" is likely to be changed. imgSnapshotTest( @@ -810,7 +864,10 @@ context('Sequence diagram', () => { a->>j: Hello John, how are you? j-->>a: Great! `, - { logLevel: 0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } } + { + logLevel: 0, + sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' }, + } ); }); it('should support actor links and properties when not mirrored EXPERIMENTAL: USE WITH CAUTION', () => { @@ -930,4 +987,36 @@ context('Sequence diagram', () => { }); }); }); + context('render after error', () => { + it('should render diagram after fixing destroy participant error', () => { + cy.on('uncaught:exception', (err) => { + return false; + }); + + renderGraph([ + `sequenceDiagram + Alice->>Bob: Hello Bob, how are you ? + Bob->>Alice: Fine, thank you. And you? + create participant Carl + Alice->>Carl: Hi Carl! + create actor D as Donald + Carl->>D: Hi! + destroy Carl + Alice-xCarl: We are too many + destroy Bo + Bob->>Alice: I agree`, + `sequenceDiagram + Alice->>Bob: Hello Bob, how are you ? + Bob->>Alice: Fine, thank you. And you? + create participant Carl + Alice->>Carl: Hi Carl! + create actor D as Donald + Carl->>D: Hi! + destroy Carl + Alice-xCarl: We are too many + destroy Bob + Bob->>Alice: I agree`, + ]); + }); + }); }); diff --git a/cypress/platform/ashish2.html b/cypress/platform/ashish2.html index 76fbd36f7e..34091d33d3 100644 --- a/cypress/platform/ashish2.html +++ b/cypress/platform/ashish2.html @@ -33,7 +33,9 @@ background-image: radial-gradient(#fff 1%, transparent 11%), radial-gradient(#fff 1%, transparent 11%); background-size: 20px 20px; - background-position: 0 0, 10px 10px; + background-position: + 0 0, + 10px 10px; background-repeat: repeat; } .malware { diff --git a/cypress/platform/click_security_loose.html b/cypress/platform/click_security_loose.html index 4cba4251d6..a581eb4036 100644 --- a/cypress/platform/click_security_loose.html +++ b/cypress/platform/click_security_loose.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/click_security_other.html b/cypress/platform/click_security_other.html index 7dc75ea884..11fd806ec5 100644 --- a/cypress/platform/click_security_other.html +++ b/cypress/platform/click_security_other.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/click_security_sandbox.html b/cypress/platform/click_security_sandbox.html index 2e03bceeb6..50e3dfb3e4 100644 --- a/cypress/platform/click_security_sandbox.html +++ b/cypress/platform/click_security_sandbox.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/click_security_strict.html b/cypress/platform/click_security_strict.html index c4ac4bd684..c2a3f84cd0 100644 --- a/cypress/platform/click_security_strict.html +++ b/cypress/platform/click_security_strict.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/css1.html b/cypress/platform/css1.html index 9e070da254..2853a93581 100644 --- a/cypress/platform/css1.html +++ b/cypress/platform/css1.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/empty.html b/cypress/platform/empty.html index 2961644d60..9713b4e552 100644 --- a/cypress/platform/empty.html +++ b/cypress/platform/empty.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/interaction.html b/cypress/platform/interaction.html index a9fe7266b0..c04be34a13 100644 --- a/cypress/platform/interaction.html +++ b/cypress/platform/interaction.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 020ea8b482..f77f6b0e7e 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -17,24 +17,30 @@ -
info
-
 graph TB
       a --> b
@@ -15,22 +29,37 @@
       c --> d
     
-
+
+ Type code to view diagram: +
+ +
+
+
info
diff --git a/demos/er.html b/demos/er.html index 027c2e2772..0b4b82bacf 100644 --- a/demos/er.html +++ b/demos/er.html @@ -1,4 +1,4 @@ - + diff --git a/demos/error.html b/demos/error.html index 2d6d1b01f5..aec051ac54 100644 --- a/demos/error.html +++ b/demos/error.html @@ -1,4 +1,4 @@ - + diff --git a/demos/flowchart-elk.html b/demos/flowchart-elk.html index 69ac2d2bc6..7c44905111 100644 --- a/demos/flowchart-elk.html +++ b/demos/flowchart-elk.html @@ -1,4 +1,4 @@ - + diff --git a/demos/flowchart.html b/demos/flowchart.html index d7032a663c..9efdf3aa33 100644 --- a/demos/flowchart.html +++ b/demos/flowchart.html @@ -1,4 +1,4 @@ - + @@ -1102,6 +1102,57 @@

flowchart


+

Sample 20

+

graph

+
+      graph LR
+      A["$$f(\relax{x}) = \int_{-\infty}^\infty \hat{f}(\xi)\,e^{2 \pi i \xi x}\,d\xi$$"] -->|"$$\Bigg(\bigg(\Big(\big((\frac{-b\pm\sqrt{b^2-4ac}}{2a})\big)\Big)\bigg)\Bigg)$$"| B("$$1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots}}}}$$")
+      A -->|"$$\overbrace{a+b+c}^{\text{note}}$$"| C("$$\phase{-78^\circ}$$")
+      B --> D("$$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$$")
+      C --> E("$$x(t)=c_1\begin{bmatrix}-\cos{t}+\sin{t}\\ 2\cos{t} \end{bmatrix}e^{2t}$$")
+    
+
+ +

flowchart

+
+      flowchart LR
+      A["$$f(\relax{x}) = \int_{-\infty}^\infty \hat{f}(\xi)\,e^{2 \pi i \xi x}\,d\xi$$"] -->|"$$\Bigg(\bigg(\Big(\big((\frac{-b\pm\sqrt{b^2-4ac}}{2a})\big)\Big)\bigg)\Bigg)$$"| B("$$1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots}}}}$$")
+      A -->|"$$\overbrace{a+b+c}^{\text{note}}$$"| C("$$\phase{-78^\circ}$$")
+      B --> D("$$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$$")
+      C --> E("$$x(t)=c_1\begin{bmatrix}-\cos{t}+\sin{t}\\ 2\cos{t} \end{bmatrix}e^{2t}$$")
+    
+
+ +

Sample 21

+

graph

+
+      graph LR
+      A["$$\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu\nu\xi\omicron\pi\rho\sigma\tau\upsilon\phi\chi\psi\omega$$"] --> B["$$\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta\Iota\Kappa\Lambda\Mu\Nu\Xi\Omicron\Pi\Rho\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega$$"]
+    
+
+ +

flowchart

+
+      graph LR
+      A["$$\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu\nu\xi\omicron\pi\rho\sigma\tau\upsilon\phi\chi\psi\omega$$"] --> B["$$\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta\Iota\Kappa\Lambda\Mu\Nu\Xi\Omicron\Pi\Rho\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega$$"]
+    
+
+ +

Sample 22

+

graph

+
+      graph LR
+      A["$$\forall\complement\therefore\emptyset\exists\subset\because\empty\exist\supset\mapsto\varnothing\nexists\mid\to\implies\in\land\gets\impliedby\isin\lor\leftrightarrow\iff\notin\ni\notni\lnot$$"] --> B["$$\nabla\Im\Reals\jmath\partial\image\wp\aleph\Game\weierp\alef\Finv\N\Z\alefsym\cnums\natnums\beth\Complex\R\gimel\ell\Re\daleth\hbar\real\eth\hslash\reals$$"]
+    
+
+ +

flowchart

+
+      graph LR
+      A["$$\forall\complement\therefore\emptyset\exists\subset\because\empty\exist\supset\mapsto\varnothing\nexists\mid\to\implies\in\land\gets\impliedby\isin\lor\leftrightarrow\iff\notin\ni\notni\lnot$$"] --> B["$$\nabla\Im\Reals\jmath\partial\image\wp\aleph\Game\weierp\alef\Finv\N\Z\alefsym\cnums\natnums\beth\Complex\R\gimel\ell\Re\daleth\hbar\real\eth\hslash\reals$$"]
+    
+
+
@@ -1524,11 +1575,11 @@ 

flowchart

F{Flow 2} == Choice 2.1 ==> H[Feedback node] H[Feedback node] ==> B[Step 1] F{Flow 2} == Choice 2.2 ==> G((Finish)) - + linkStyle 0,1,4,6,7,8,9 stroke:gold, stroke-width:4px classDef active_node fill:#0CF,stroke:#09F,stroke-width:6px - classDef unactive_node fill:#e0e0e0,stroke:#bdbdbd,stroke-width:3px + classDef unactive_node fill:#e0e0e0,stroke:#bdbdbd,stroke-width:3px classDef bugged_node fill:#F88,stroke:#F22,stroke-width:3px classDef start_node,finish_node fill:#3B1,stroke:#391,stroke-width:8px diff --git a/demos/gantt.html b/demos/gantt.html index 88f52ef5c9..53ec2b6813 100644 --- a/demos/gantt.html +++ b/demos/gantt.html @@ -1,4 +1,4 @@ - + @@ -30,6 +30,21 @@

Gantt chart diagram demos


+
+      gantt
+        title #; Gantt Diagrams Allow Semicolons and Hashtags #;!
+        accTitle: A simple sample gantt diagram
+        accDescr: 2 sections with 2 tasks each, from 2014
+        dateFormat  YYYY-MM-DD
+        section #;Section
+        #;A task           :a1, 2014-01-01, 30d
+        #;Another task     :after a1  , 20d
+        section #;Another
+        Task in sec      :2014-01-12  , 12d
+        another task      : 24d
+    
+
+
     gantt
       title Airworks roadmap
diff --git a/demos/git.html b/demos/git.html
index 92e0e68635..8eeb69a126 100644
--- a/demos/git.html
+++ b/demos/git.html
@@ -1,4 +1,4 @@
-
+
 
   
     
diff --git a/demos/index.html b/demos/index.html
index c634aad2d4..61a86a2aa0 100644
--- a/demos/index.html
+++ b/demos/index.html
@@ -1,4 +1,4 @@
-
+
 
   
     
@@ -18,6 +18,7 @@ 

Mermaid quick test and demo pages

Some of these pages have duplicates; some are slow to load because they have so many graphs.

+

You can test custom code in the development page.

If you'd like to clean up one of the pages, please feel free to submit a pull request (PR). @@ -81,6 +82,12 @@

ZenUML

  • Sankey

  • +
  • +

    Packet

    +
  • +
  • +

    Layered Blocks

    +
  • diff --git a/demos/info.html b/demos/info.html index affe9e59a1..d19d89edee 100644 --- a/demos/info.html +++ b/demos/info.html @@ -1,4 +1,4 @@ - + diff --git a/demos/journey.html b/demos/journey.html index b0131ea3fc..b467297130 100644 --- a/demos/journey.html +++ b/demos/journey.html @@ -1,4 +1,4 @@ - + diff --git a/demos/mindmap.html b/demos/mindmap.html index 2e7d477192..832af72389 100644 --- a/demos/mindmap.html +++ b/demos/mindmap.html @@ -1,4 +1,4 @@ - + diff --git a/demos/packet.html b/demos/packet.html new file mode 100644 index 0000000000..b66880f394 --- /dev/null +++ b/demos/packet.html @@ -0,0 +1,141 @@ + + + + + + Mermaid Quick Test Page + + + + + +

    Packet diagram demo

    + +
    +
    +      packet-beta
    +        0-15: "Source Port"
    +        16-31: "Destination Port"
    +        32-63: "Sequence Number"
    +        64-95: "Acknowledgment Number"
    +        96-99: "Data Offset"
    +        100-105: "Reserved"
    +        106: "URG"
    +        107: "ACK"
    +        108: "PSH"
    +        109: "RST"
    +        110: "SYN"
    +        111: "FIN"
    +        112-127: "Window"
    +        128-143: "Checksum"
    +        144-159: "Urgent Pointer"
    +        160-191: "(Options and Padding)"
    +        192-223: "data"
    +    
    + +
    +      ---
    +      config:
    +        packet:
    +          showBits: false
    +      ---
    +      packet-beta
    +        0-15: "Source Port"
    +        16-31: "Destination Port"
    +        32-63: "Sequence Number"
    +        64-95: "Acknowledgment Number"
    +        96-99: "Data Offset"
    +        100-105: "Reserved"
    +        106: "URG"
    +        107: "ACK"
    +        108: "PSH"
    +        109: "RST"
    +        110: "SYN"
    +        111: "FIN"
    +        112-127: "Window"
    +        128-143: "Checksum"
    +        144-159: "Urgent Pointer"
    +        160-191: "(Options and Padding)"
    +        192-223: "data"
    +    
    + +
    +      ---
    +      config:
    +        theme: forest
    +      ---
    +      packet-beta
    +        title Forest theme
    +        0-15: "Source Port"
    +        16-31: "Destination Port"
    +        32-63: "Sequence Number"
    +        64-95: "Acknowledgment Number"
    +        96-99: "Data Offset"
    +        100-105: "Reserved"
    +        106: "URG"
    +        107: "ACK"
    +        108: "PSH"
    +        109: "RST"
    +        110: "SYN"
    +        111: "FIN"
    +        112-127: "Window"
    +        128-143: "Checksum"
    +        144-159: "Urgent Pointer"
    +        160-191: "(Options and Padding)"
    +        192-223: "data"
    +    
    + +
    +      ---
    +      config:
    +        theme: dark
    +      ---
    +      packet-beta
    +        title Dark theme
    +        0-15: "Source Port"
    +        16-31: "Destination Port"
    +        32-63: "Sequence Number"
    +        64-95: "Acknowledgment Number"
    +        96-99: "Data Offset"
    +        100-105: "Reserved"
    +        106: "URG"
    +        107: "ACK"
    +        108: "PSH"
    +        109: "RST"
    +        110: "SYN"
    +        111: "FIN"
    +        112-127: "Window"
    +        128-143: "Checksum"
    +        144-159: "Urgent Pointer"
    +        160-191: "(Options and Padding)"
    +        192-223: "data"
    +    
    +
    + + + + + diff --git a/demos/pie.html b/demos/pie.html index ea971b9b4c..cd0deeb7f9 100644 --- a/demos/pie.html +++ b/demos/pie.html @@ -1,4 +1,4 @@ - + @@ -15,7 +15,7 @@

    Pie chart demos

    -      pie title Pets adopted by volunteers
    +      pie title Default text position: Animal adoption
             accTitle: simple pie char demo
             accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
             "Dogs": 386
    @@ -27,7 +27,7 @@ 

    Pie chart demos

           %%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
           pie
    -        title Key elements in Product X
    +        title Offset labels close to border: Product X
             accTitle: Key elements in Product X
             accDescr: This is a pie chart showing the key elements in Product X.
             "Calcium": 42.96
    @@ -36,6 +36,19 @@ 

    Pie chart demos

    "Iron": 5
    +
    +      %%{init: {"pie": {"textPosition": 0.45}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
    +      pie
    +        title Centralized labels: Languages
    +        accTitle: Key elements in Product X
    +        accDescr: This is a pie chart showing the key elements in Product X.
    +        "JavaScript": 30
    +        "Python": 25
    +        "Java": 20
    +        "C#": 15
    +        "Others": 10
    +    
    + + + +``` diff --git a/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md b/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md index 4386be9380..fa100744ed 100644 --- a/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md +++ b/docs/config/setup/interfaces/mermaidAPI.ParseOptions.md @@ -14,6 +14,9 @@ • `Optional` **suppressErrors**: `boolean` +If `true`, parse will return `false` instead of throwing error when the diagram is invalid. +The `parseError` function will not be called. + #### Defined in -[mermaidAPI.ts:60](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L60) +[mermaidAPI.ts:64](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L64) diff --git a/docs/config/setup/interfaces/mermaidAPI.ParseResult.md b/docs/config/setup/interfaces/mermaidAPI.ParseResult.md new file mode 100644 index 0000000000..9f912cc8c2 --- /dev/null +++ b/docs/config/setup/interfaces/mermaidAPI.ParseResult.md @@ -0,0 +1,21 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.ParseResult.md](../../../../packages/mermaid/src/docs/config/setup/interfaces/mermaidAPI.ParseResult.md). + +# Interface: ParseResult + +[mermaidAPI](../modules/mermaidAPI.md).ParseResult + +## Properties + +### diagramType + +• **diagramType**: `string` + +The diagram type, e.g. 'flowchart', 'sequence', etc. + +#### Defined in + +[mermaidAPI.ts:71](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L71) diff --git a/docs/config/setup/interfaces/mermaidAPI.RenderResult.md b/docs/config/setup/interfaces/mermaidAPI.RenderResult.md index 6209782f75..b5cc48038b 100644 --- a/docs/config/setup/interfaces/mermaidAPI.RenderResult.md +++ b/docs/config/setup/interfaces/mermaidAPI.RenderResult.md @@ -14,10 +14,6 @@ • `Optional` **bindFunctions**: (`element`: `Element`) => `void` -#### Type declaration - -▸ (`element`): `void` - Bind function to be called after the svg has been inserted into the DOM. This is necessary for adding event listeners to the elements in the svg. @@ -27,6 +23,10 @@ div.innerHTML = svg; bindFunctions?.(div); // To call bindFunctions only if it's present. ``` +#### Type declaration + +▸ (`element`): `void` + ##### Parameters | Name | Type | @@ -39,7 +39,19 @@ bindFunctions?.(div); // To call bindFunctions only if it's present. #### Defined in -[mermaidAPI.ts:80](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L80) +[mermaidAPI.ts:94](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L94) + +--- + +### diagramType + +• **diagramType**: `string` + +The diagram type, e.g. 'flowchart', 'sequence', etc. + +#### Defined in + +[mermaidAPI.ts:84](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L84) --- @@ -51,4 +63,4 @@ The svg code for the rendered graph. #### Defined in -[mermaidAPI.ts:70](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L70) +[mermaidAPI.ts:80](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L80) diff --git a/docs/config/setup/modules/defaultConfig.md b/docs/config/setup/modules/defaultConfig.md index 7a9b891c43..d3495bc0c3 100644 --- a/docs/config/setup/modules/defaultConfig.md +++ b/docs/config/setup/modules/defaultConfig.md @@ -14,7 +14,7 @@ #### Defined in -[defaultConfig.ts:272](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L272) +[defaultConfig.ts:275](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L275) --- diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 6f2be89c14..1a68b05bd0 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -9,6 +9,7 @@ ## Interfaces - [ParseOptions](../interfaces/mermaidAPI.ParseOptions.md) +- [ParseResult](../interfaces/mermaidAPI.ParseResult.md) - [RenderResult](../interfaces/mermaidAPI.RenderResult.md) ## References @@ -25,17 +26,79 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi) #### Defined in -[mermaidAPI.ts:64](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L64) +[mermaidAPI.ts:74](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L74) ## Variables ### mermaidAPI -• `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<`boolean`> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }> +• `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md) & { `suppressErrors`: `true` }) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md) | `false`>(`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md)> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }> + +## mermaidAPI configuration defaults + +```ts +const config = { + theme: 'default', + logLevel: 'fatal', + securityLevel: 'strict', + startOnLoad: true, + arrowMarkerAbsolute: false, + suppressErrorRendering: false, + + er: { + diagramPadding: 20, + layoutDirection: 'TB', + minEntityWidth: 100, + minEntityHeight: 75, + entityPadding: 15, + stroke: 'gray', + fill: 'honeydew', + fontSize: 12, + useMaxWidth: true, + }, + flowchart: { + diagramPadding: 8, + htmlLabels: true, + curve: 'basis', + }, + sequence: { + diagramMarginX: 50, + diagramMarginY: 10, + actorMargin: 50, + width: 150, + height: 65, + boxMargin: 10, + boxTextMargin: 5, + noteMargin: 10, + messageMargin: 35, + messageAlign: 'center', + mirrorActors: true, + bottomMarginAdj: 1, + useMaxWidth: true, + rightAngles: false, + showSequenceNumbers: false, + }, + gantt: { + titleTopMargin: 25, + barHeight: 20, + barGap: 4, + topPadding: 50, + leftPadding: 75, + gridLineStartPadding: 35, + fontSize: 11, + fontFamily: '"Open Sans", sans-serif', + numberSectionStyles: 4, + axisFormat: '%Y-%m-%d', + topAxis: false, + displayMode: '', + }, +}; +mermaid.initialize(config); +``` #### Defined in -[mermaidAPI.ts:548](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L548) +[mermaidAPI.ts:635](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L635) ## Functions @@ -66,7 +129,7 @@ Return the last node appended #### Defined in -[mermaidAPI.ts:263](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L263) +[mermaidAPI.ts:277](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L277) --- @@ -92,7 +155,7 @@ the cleaned up svgCode #### Defined in -[mermaidAPI.ts:209](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L209) +[mermaidAPI.ts:223](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L223) --- @@ -117,7 +180,7 @@ the string with all the user styles #### Defined in -[mermaidAPI.ts:139](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L139) +[mermaidAPI.ts:153](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L153) --- @@ -140,7 +203,7 @@ the string with all the user styles #### Defined in -[mermaidAPI.ts:186](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L186) +[mermaidAPI.ts:200](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L200) --- @@ -167,7 +230,7 @@ with an enclosing block that has each of the cssClasses followed by !important; #### Defined in -[mermaidAPI.ts:124](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L124) +[mermaidAPI.ts:138](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L138) --- @@ -193,7 +256,7 @@ Put the svgCode into an iFrame. Return the iFrame code #### Defined in -[mermaidAPI.ts:240](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L240) +[mermaidAPI.ts:254](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L254) --- @@ -218,4 +281,4 @@ Remove any existing elements from the given document #### Defined in -[mermaidAPI.ts:313](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L313) +[mermaidAPI.ts:327](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L327) diff --git a/docs/config/theming.md b/docs/config/theming.md index 63271a39b7..3045298f63 100644 --- a/docs/config/theming.md +++ b/docs/config/theming.md @@ -12,15 +12,15 @@ Themes can now be customized at the site-wide level, or on individual Mermaid di ## Available Themes -1. [**default**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-default.js) - This is the default theme for all diagrams. +1. [**default**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-default.js) - This is the default theme for all diagrams. -2. [**neutral**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-neutral.js) - This theme is great for black and white documents that will be printed. +2. [**neutral**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-neutral.js) - This theme is great for black and white documents that will be printed. -3. [**dark**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-dark.js) - This theme goes well with dark-colored elements or dark-mode. +3. [**dark**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-dark.js) - This theme goes well with dark-colored elements or dark-mode. -4. [**forest**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-forest.js) - This theme contains shades of green. +4. [**forest**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-forest.js) - This theme contains shades of green. -5. [**base**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-base.js) - This is the only theme that can be modified. Use this theme as the base for customizations. +5. [**base**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-base.js) - This is the only theme that can be modified. Use this theme as the base for customizations. ## Site-wide Theme @@ -65,7 +65,7 @@ Example of `init` directive setting the `theme` to `forest`: a --> b ``` -> **Reminder**: the only theme that can be customed is the `base` theme. The following section covers how to use `themeVariables` for customizations. +> **Reminder**: the only theme that can be customized is the `base` theme. The following section covers how to use `themeVariables` for customizations. ## Customizing Themes with `themeVariables` @@ -250,7 +250,7 @@ The theming engine will only recognize hex colors and not color names. So, the v | actorBkg | mainBkg | Actor Background Color | | actorBorder | primaryBorderColor | Actor Border Color | | actorTextColor | primaryTextColor | Actor Text Color | -| actorLineColor | grey | Actor Line Color | +| actorLineColor | actorBorder | Actor Line Color | | signalColor | textColor | Signal Color | | signalTextColor | textColor | Signal Text Color | | labelBoxBkgColor | actorBkg | Label Box Background Color | diff --git a/docs/config/usage.md b/docs/config/usage.md index 699171001d..d853643d37 100644 --- a/docs/config/usage.md +++ b/docs/config/usage.md @@ -20,7 +20,7 @@ Please note that you can switch versions through the dropdown box at the top rig For the majority of users, Using the [Live Editor](https://mermaid.live/) would be sufficient, however you may also opt to deploy mermaid as a dependency or using the [Mermaid API](./setup/README.md). -We have compiled some Video [Tutorials](./Tutorials.md) on how to use the Mermaid Live Editor. +We have compiled some Video [Tutorials](../ecosystem/tutorials.md) on how to use the Mermaid Live Editor. ### Installing and Hosting Mermaid on a Webpage @@ -73,7 +73,7 @@ Example: ## Simple full example: ```html - +
    @@ -286,11 +286,11 @@ const drawDiagram = async function () {
     };
     ```
     
    -1.  The graph is generated using the render call.
    -2.  After generation the render function calls the provided callback function, in this case it's called insertSvg.
    -3.  The callback function is called with two parameters, the SVG code of the generated graph and a function. This function binds events to the SVG **after** it is inserted into the DOM.
    -4.  Insert the SVG code into the DOM for presentation.
    -5.  Call the binding function that binds the events.
    +1. The graph is generated using the render call.
    +2. After generation the render function calls the provided callback function, in this case it's called insertSvg.
    +3. The callback function is called with two parameters, the SVG code of the generated graph and a function. This function binds events to the SVG **after** it is inserted into the DOM.
    +4. Insert the SVG code into the DOM for presentation.
    +5. Call the binding function that binds the events.
     
     ## Example of a marked renderer
     
    @@ -331,15 +331,17 @@ module.exports = (options) ->
     
     ## Advanced usage
     
    -**Syntax validation without rendering (Work in Progress)**
    +### Syntax validation without rendering
     
    -The **mermaid.parse(txt)** function validates graph definitions without rendering a graph. **[This function is still a work in progress](https://github.com/mermaid-js/mermaid/issues/1066), find alternatives below.**
    +The `mermaid.parse(text, parseOptions)` function validates graph definitions without rendering a graph.
     
    -The function **mermaid.parse(txt)**, takes a text string as an argument and returns true if the definition follows mermaid's syntax and
    -false if it does not. The parseError function will be called when the parse function returns false.
    +The function `mermaid.parse(text, parseOptions)`, takes a text string as an argument and returns `{ diagramType: string }` if the definition follows mermaid's syntax.
     
    -When the parser encounters invalid syntax the **mermaid.parseError** function is called. It is possible to override this
    -function in order to handle the error in an application-specific way.
    +If the definition is invalid, the function returns `false` if `parseOptions.suppressErrors` is set to `true`. Otherwise, it throws an error.
    +
    +The parseError function will be called when the parse function throws an error. It will not be called if `parseOptions.suppressErrors` is set to `true`.
    +
    +It is possible to override this function in order to handle the error in an application-specific way.
     
     The code-example below in meta code illustrates how this could work:
     
    @@ -359,26 +361,10 @@ const textFieldUpdated = async function () {
     bindEventHandler('change', 'code', textFieldUpdated);
     ```
     
    -**Alternative to mermaid.parse():**
    -One effective and more future-proof method of validating your graph definitions, is to paste and render them via the [Mermaid Live Editor](https://mermaid.live/). This will ensure that your code is compliant with the syntax of Mermaid's most recent version.
    -
     ## Configuration
     
    -Mermaid takes a number of options which lets you tweak the rendering of the diagrams. Currently there are three ways of
    -setting the options in mermaid.
    -
    -1.  Instantiation of the configuration using the initialize call
    -2.  _Using the global mermaid object_ - **Deprecated**
    -3.  _using the global mermaid_config object_ - **Deprecated**
    -4.  Instantiation of the configuration using the **mermaid.init** call- **Deprecated**
    -
    -The list above has two ways too many of doing this. Three are deprecated and will eventually be removed. The list of
    -configuration objects are described [in the mermaidAPI documentation](./setup/README.md).
    -
    -## Using the `mermaidAPI.initialize`/`mermaid.initialize` call
    -
    -The future proof way of setting the configuration is by using the initialization call to mermaid or mermaidAPI depending
    -on what kind of integration you use.
    +You can pass the required configuration to the `mermaid.initialize` call. This is the preferred way of configuring mermaid.
    +The list of configuration objects are described [in the mermaidAPI documentation](./setup/README.md).
     
     ```html
     
    +
    +
    diff --git a/packages/mermaid/src/docs/.vitepress/theme/custom.css b/packages/mermaid/src/docs/.vitepress/theme/custom.css
    index 28ef8d3385..1d72056ecb 100644
    --- a/packages/mermaid/src/docs/.vitepress/theme/custom.css
    +++ b/packages/mermaid/src/docs/.vitepress/theme/custom.css
    @@ -1,5 +1,5 @@
    -@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
    -@import url('https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css');
    +@import 'font-awesome/css/font-awesome.min.css';
    +@import '@mdi/font/css/materialdesignicons.min.css';
     
     :root {
       --vp-c-brand: #ff3670;
    diff --git a/packages/mermaid/src/docs/.vitepress/theme/index.ts b/packages/mermaid/src/docs/.vitepress/theme/index.ts
    index 6561578106..3ebb7614a1 100644
    --- a/packages/mermaid/src/docs/.vitepress/theme/index.ts
    +++ b/packages/mermaid/src/docs/.vitepress/theme/index.ts
    @@ -6,39 +6,40 @@ import Mermaid from './Mermaid.vue';
     import Contributors from '../components/Contributors.vue';
     // @ts-ignore
     import HomePage from '../components/HomePage.vue';
    -// // @ts-ignore
    -// import TopBar from '../components/TopBar.vue';
    -
    +// @ts-ignore
    +import TopBar from '../components/TopBar.vue';
     import { getRedirect } from './redirect.js';
    -
     import { h } from 'vue';
    -
     import Theme from 'vitepress/theme';
     import '../style/main.css';
     import 'uno.css';
    +import type { EnhanceAppContext } from 'vitepress';
     
     export default {
       ...DefaultTheme,
       Layout() {
         return h(Theme.Layout, null, {
           // Keeping this as comment as it took a lot of time to figure out how to add a component to the top bar.
    -      // 'home-hero-before': () => h(TopBar),
    +      'home-hero-before': () => h(TopBar),
           'home-features-after': () => h(HomePage),
         });
       },
    -  enhanceApp({ app, router }) {
    +  enhanceApp({ app, router }: EnhanceAppContext) {
         // register global components
         app.component('Mermaid', Mermaid);
         app.component('Contributors', Contributors);
         router.onBeforeRouteChange = (to) => {
           try {
    -        const newPath = getRedirect(to);
    +        const url = new URL(window.location.origin + to);
    +        const newPath = getRedirect(url);
             if (newPath) {
               console.log(`Redirecting to ${newPath} from ${window.location}`);
               // router.go isn't loading the ID properly.
               window.location.href = `/${newPath}`;
             }
    -      } catch (e) {}
    +      } catch (e) {
    +        console.error(e);
    +      }
         };
       },
     };
    diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts
    index 09c14d935b..91b6c91fee 100644
    --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts
    +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts
    @@ -38,10 +38,24 @@ test.each([
       ['https://mermaid.js.org/#/flowchart.md', 'syntax/flowchart.html'],
       // New docs, without base path, new domain
       ['https://mermaid.js.org/misc/faq.html', 'configure/faq.html'],
    +  ['https://mermaid.js.org/community/newDiagram.html', 'community/new-diagram.html'],
    +  [
    +    'https://mermaid.js.org/community/development.html',
    +    'community/contributing.html#initial-setup',
    +  ],
    +  [
    +    'https://mermaid.js.org/community/docker-development.html',
    +    'community/contributing.html#initial-setup',
    +  ],
    +  ['https://mermaid.js.org/community/code.html', 'community/contributing.html#contributing-code'],
    +  [
    +    'https://mermaid.js.org/community/documentation.html',
    +    'community/contributing.html#contributing-documentation',
    +  ],
       [
         'https://mermaid.js.org/misc/faq.html#frequently-asked-questions',
         'configure/faq.html#frequently-asked-questions',
       ], // with hash
     ])('should process url %s to %s', (link: string, path: string) => {
    -  expect(getRedirect(link)).toBe(path);
    +  expect(getRedirect(new URL(link))).toBe(path);
     });
    diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts
    index e24d2beb9d..1b04e01d5f 100644
    --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts
    +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts
    @@ -58,7 +58,7 @@ const idRedirectMap: Record = {
       'n00b-gettingstarted': 'intro/getting-started',
       'n00b-overview': 'intro/getting-started',
       'n00b-syntaxreference': 'intro/syntax-reference',
    -  newdiagram: 'community/newDiagram',
    +  newdiagram: 'community/new-diagram',
       pie: 'syntax/pie',
       plugins: '',
       quickstart: 'intro/getting-started',
    @@ -69,7 +69,7 @@ const idRedirectMap: Record = {
       statediagram: 'syntax/stateDiagram',
       themes: 'config/theming',
       theming: 'config/theming',
    -  tutorials: 'config/Tutorials',
    +  tutorials: 'ecosystem/tutorials',
       upgrading: '',
       usage: 'config/usage',
       'user-journey': 'syntax/userJourney',
    @@ -88,10 +88,15 @@ const urlRedirectMap: Record = {
       '/syntax/c4c.html': 'syntax/c4.html',
       '/ecosystem/integrations.html': 'ecosystem/integrations-community.html',
       '/ecosystem/showcases.html': 'ecosystem/integrations-create',
    -  '/config/n00b-advanced.html': 'config/advanced',
    -  '/intro/n00b-gettingStarted.html': 'intro/getting-started',
    -  '/intro/n00b-syntaxReference.html': 'intro/syntax-reference',
    -  '/community/n00b-overview.html': 'intro/getting-started',
    +  '/config/n00b-advanced.html': 'config/configuration.html',
    +  '/intro/n00b-gettingStarted.html': 'intro/getting-started.html',
    +  '/intro/n00b-syntaxReference.html': 'intro/syntax-reference.html',
    +  '/community/n00b-overview.html': 'intro/getting-started.html',
    +  '/community/newDiagram.html': 'community/new-diagram.html',
    +  '/community/development.html': 'community/contributing.html#initial-setup',
    +  '/community/docker-development.html': 'community/contributing.html#initial-setup',
    +  '/community/code.html': 'community/contributing.html#contributing-code',
    +  '/community/documentation.html': 'community/contributing.html#contributing-documentation',
     };
     
     /**
    @@ -99,8 +104,7 @@ const urlRedirectMap: Record = {
      * @param link - The old documentation URL.
      * @returns The new documentation path.
      */
    -export const getRedirect = (link: string): string | undefined => {
    -  const url = new URL(link);
    +export const getRedirect = (url: URL): string | undefined => {
       // Redirects for deprecated vitepress URLs
       if (url.pathname in urlRedirectMap) {
         return `${urlRedirectMap[url.pathname]}${url.hash}`;
    diff --git a/packages/mermaid/src/docs/community/code.md b/packages/mermaid/src/docs/community/code.md
    deleted file mode 100644
    index 93a5fcd953..0000000000
    --- a/packages/mermaid/src/docs/community/code.md
    +++ /dev/null
    @@ -1,165 +0,0 @@
    -# Contributing Code
    -
    -The basic steps for contributing code are:
    -
    -```mermaid
    -graph LR
    -    git[1. Checkout a  git branch] --> codeTest[2. Write tests and code] --> doc[3. Update documentation] --> submit[4. Submit a PR] --> review[5. Review and merge]
    -```
    -
    -1. **Create** and checkout a git branch and work on your code in the branch
    -2. Write and update **tests** (unit and perhaps even integration (e2e) tests) (If you do TDD/BDD, the order might be different.)
    -3. **Let users know** that things have changed or been added in the documents! This is often overlooked, but _critical_
    -4. **Submit** your code as a _pull request_.
    -5. Maintainers will **review** your code. If there are no changes necessary, the PR will be merged. Otherwise, make the requested changes and repeat.
    -
    -## 1. Checkout a git branch
    -
    -Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching.
    -
    -Development is done in the `develop` branch.
    -
    -Once development is done we create a `release/vX.X.X` branch from `develop` for testing.
    -
    -Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch.
    -
    -**All new work should be based on the `develop` branch.**
    -
    -**When you are ready to do work, always, ALWAYS:**
    -
    -1. Make sure you have the most up-to-date version of the `develop` branch. (fetch or pull to update it)
    -2. Check out the `develop` branch
    -3. Create a new branch for your work. Please name the branch following our naming convention below.
    -
    -We use the following naming convention for branches:
    -
    -```txt
    -   [feature | bug | chore | docs]/[issue number]_[short description using dashes ('-') or underscores ('_') instead of spaces]
    -```
    -
    -You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml)
    -
    -- The first part is the **type** of change: a feature, bug, chore, or documentation change ('docs')
    -- followed by a _slash_ (which helps to group like types together in many git tools)
    -- followed by the **issue number**
    -- followed by an _underscore_ ('\_')
    -- followed by a short text description (but use dashes ('-') or underscores ('\_') instead of spaces)
    -
    -If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized: it will help us keep changes for a diagram type together.
    -
    -**Ex: A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams**
    -
    -`feature/2945_state-diagram-new-arrow-florbs`
    -
    -**Ex: A bug described in issue 1123 that causes random ugly red text in multiple diagram types**
    -`bug/1123_fix_random_ugly_red_text`
    -
    -## 2. Write Tests
    -
    -Tests ensure that each function, module, or part of code does what it says it will do. This is critically
    -important when other changes are made to ensure that existing code is not broken (no regression).
    -
    -Just as important, the tests act as _specifications:_ they specify what the code does (or should do).
    -Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why.
    -
    -If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again.
    -(If there had been a test for the situation, the bug never would have happened in the first place.)
    -You may need to change existing tests if they were inaccurate.
    -
    -If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests.
    -
    -### Unit Tests
    -
    -Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run.
    -
    -Unit tests are mandatory all code except the renderers. (The renderers are tested with integration tests.)
    -
    -We use [Vitest](https://vitest.dev) to run unit tests.
    -
    -You can use the following command to run the unit tests:
    -
    -```sh
    -pnpm test
    -```
    -
    -When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command:
    -
    -```sh
    -pnpm test:watch
    -```
    -
    -### Integration/End-to-End (e2e) tests
    -
    -These test the rendering and visual appearance of the diagrams.
    -This ensures that the rendering of that feature in the e2e will be reviewed in the release process going forward. Less chance that it breaks!
    -
    -To start working with the e2e tests:
    -
    -1. Run `pnpm dev` to start the dev server
    -2. Start **Cypress** by running `pnpm cypress:open`.
    -
    -The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress.
    -
    -When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs.
    -
    -This is what a rendering test looks like:
    -
    -```js
    -it('should render forks and joins', () => {
    -  imgSnapshotTest(
    -    `
    -    stateDiagram
    -    state fork_state <<fork>>
    -      [*] --> fork_state
    -      fork_state --> State2
    -      fork_state --> State3
    -
    -      state join_state <<join>>
    -      State2 --> join_state
    -      State3 --> join_state
    -      join_state --> State4
    -      State4 --> [*]
    -    `,
    -    { logLevel: 0 }
    -  );
    -  cy.get('svg');
    -});
    -```
    -
    -**_[TODO - running the tests against what is expected in development. ]_**
    -
    -**_[TODO - how to generate new screenshots]_**
    -....
    -
    -## 3. Update Documentation
    -
    -If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken.
    -Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused.
    -
    -The documentation has to be updated to users know that things have changed and added!
    -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens.
    -
    -eg: `# Feature Name (v+)`
    -
    -We know it can sometimes be hard to code _and_ write user documentation.
    -
    -Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [Contributing Documentation](#contributing-documentation) section.
    -
    -Create another issue specifically for the documentation.  
    -You will need to help with the PR, but definitely ask for help if you feel stuck.
    -When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work!
    -
    -When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!)
    -
    -## 4. Submit your pull request
    -
    -**[TODO - PR titles should start with (fix | feat | ....)]**
    -
    -We make all changes via Pull Requests (PRs). As we have many Pull Requests from developers new to Mermaid, we have put in place a process wherein _knsv, Knut Sveidqvist_ is in charge of the final release process and the active maintainers are in charge of reviewing and merging most PRs.
    -
    -- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed.
    -- The maintainers will request a review from knsv, if necessary.
    -- Once the PR is approved, the maintainers will merge the PR into the `develop` branch.
    -- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process.
    -
    -**Reminder: Pull Requests should be submitted to the develop branch.**
    diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md
    new file mode 100644
    index 0000000000..195146a612
    --- /dev/null
    +++ b/packages/mermaid/src/docs/community/contributing.md
    @@ -0,0 +1,525 @@
    +# Mermaid Contributing Guide
    +
    +You decided to take part in the development? Welcome!
    +
    +We are trying to make our guidelines for you as explicit and detailed as possible.
    +
    +## Initial Setup
    +
    +Initial setup consists of 3 main steps:
    +
    +```mermaid-nocode
    +flowchart LR
    +  source --> requirements --> setup
    +
    +  source[Get the Source Code]
    +  requirements[Install the Requirements]
    +  setup[Install Packages]
    +```
    +
    +### Get the Source Code
    +
    +In GitHub, you first [**fork a mermaid repository**](https://github.com/mermaid-js/mermaid/fork) when you are going to make changes and submit pull requests.
    +
    +Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
    +
    +```tip
    +[Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
    +```
    +
    +```bash
    +git clone git@github.com/your-fork/mermaid
    +```
    +
    +Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository)
    +
    +```bash
    +cd mermaid
    +```
    +
    +### Install Requirements
    +
    +We support **development within Docker** environment along with **host setup**. You may choose it up to your preferences.
    +
    +**Host**
    +
    +These are the tools we use for working with the code and documentation:
    +
    +- [Node.js](https://nodejs.org/en/).
    +- [pnpm](https://pnpm.io/) package manager.
    +
    +The following commands must be sufficient enough to start with:
    +
    +```bash
    +curl -fsSL https://get.pnpm.io/install.sh | sh -
    +pnpm env use --global 18
    +```
    +
    +You may also need to reload `.shrc` or `.bashrc` afterwards.
    +
    +**Docker**
    +
    +[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need.
    +
    +Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed.
    +You might already have it installed, so check this by running:
    +
    +```bash
    +echo $DISPLAY
    +```
    +
    +If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one.
    +
    +### Install Packages
    +
    +**Host**
    +
    +Install packages:
    +
    +```bash
    +pnpm install
    +```
    +
    +**Docker**
    +
    +For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands.
    +
    +Make sure that `./run` script is executable:
    +
    +```bash
    +chmod +x run
    +```
    +
    +```tip
    +To get detailed help simply type `./run` or `./run help`.
    +
    +It also has short _Development quick start guide_ embedded.
    +```
    +
    +Then install packages:
    +
    +```bash
    +./run pnpm install
    +```
    +
    +### Verify Everything Works
    +
    +This step is optional, but it helps to make sure that everything in development branch was OK before you started making any changes.
    +
    +You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly:
    +
    +**Host**
    +
    +```bash
    +pnpm test
    +```
    +
    +**Docker**
    +
    +```bash
    +./run pnpm test
    +```
    +
    +The `test` script and others are in the top-level `package.json` file.
    +
    +All tests should run successfully without any errors or failures.
    +
    +```note
    +You might see _lint_ or _formatting_ warnings. Those are ok during this step.
    +```
    +
    +## Workflow
    +
    +Contributing process is very simple and straightforward:
    +
    +```mermaid-nocode
    +  flowchart LR
    +
    +  branch --> changes --> submit
    +  branch[Checkout a New Branch]
    +  changes[Make Changes]
    +  submit[Submit a PR]
    +```
    +
    +Mermaid uses a [Git Flow](https://guides.github.com/introduction/flow/)–inspired approach to branching.
    +
    +Development is done in the `develop` branch.
    +
    +```mermaid-nocode
    +---
    +config:
    +  gitGraph:
    +    mainBranchName: develop
    +---
    +gitGraph LR:
    +  commit
    +  commit
    +  branch "docs/2910_update-guidelines" order: 1
    +  commit
    +  commit
    +  commit
    +  checkout develop
    +  merge "docs/2910_update-guidelines"
    +  commit
    +```
    +
    +To prepare a new version for release the maintainers create a `release/vX.X.X` branch from `develop` for testing. Once the release happens we add a tag to the `release` branch and merge it with `master`. The live product and on-line documentation are what is in the `master` branch.
    +
    +## Checkout a New Branch
    +
    +```tip
    +All new work should be based on the `develop` branch.
    +```
    +
    +Make sure you have the most up-to-date version of the `develop` branch.
    +
    +Check out the `develop` branch, then `fetch` or `pull` to update it:
    +
    +```bash
    +git checkout develop
    +git fetch # or `git pull`
    +```
    +
    +Create a new branch for your work:
    +
    +```bash
    +git checkout -b docs/2910_update-contributing-guidelines
    +```
    +
    +We use the following naming convention for branches:
    +
    +```txt
    +[feature | bug | chore | docs]/[issue number]_[short-description]
    +```
    +
    +You can always check current [configuration of labelling and branch prefixes](https://github.com/mermaid-js/mermaid/blob/develop/.github/pr-labeler.yml)
    +
    +- The first part is the **type** of change: a `feature`, `bug`, `chore`, `docs`
    +- followed by a **slash** (`/`),which helps to group like types together in many git tools
    +- followed by the **issue number**, e.g. `2910`
    +- followed by an **underscore** (`_`)
    +- followed by a **short description** with dashes (`-`) or underscores (`_`) instead of spaces
    +
    +```mermaid-nocode
    +flowchart LR
    +  feature --> slash
    +  bug --> slash
    +  chore --> slash
    +  docs --> slash
    +  slash --> 2945 --> underscore
    +  slash --> 1123 --> underscore
    +  underscore --> short_description_1
    +  underscore --> short_description_2
    +
    +  underscore["_"]
    +  slash["/"]
    +
    +  short_description_1["state-diagram-new-arrow-florbs"]
    +  short_description_2["fix_random_ugly_red_text"]
    +```
    +
    +If your work is specific to a single diagram type, it is a good idea to put the diagram type at the start of the description. This will help us keep release notes organized by a diagram type.
    +
    +```note
    +A new feature described in issue 2945 that adds a new arrow type called 'florbs' to state diagrams
    +
    +`feature/2945_state-diagram-new-arrow-florbs`
    +```
    +
    +```tip
    +A bug described in issue 1123 that causes random ugly red text in multiple diagram types
    +
    +`bug/1123_fix_random_ugly_red_text`
    +```
    +
    +## Contributing Code
    +
    +Code is the heart of every software project. We strive to make it better. Who if not us?
    +
    +### Where is the Code Located?
    +
    +The core of Mermaid is located under `packages/mermaid/src`.
    +
    +### Running Mermaid Locally
    +
    +**Host**
    +
    +```bash
    +pnpm run dev
    +```
    +
    +**Docker**
    +
    +```bash
    +./run dev
    +```
    +
    +After starting the dev server open  in your browser.
    +
    +Now you are ready to make your changes!
    +
    +### Make Changes
    +
    +Have a look at . There is a list of demos that can be used to see and test your changes.
    +
    +If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy.
    +
    +That will be served at .
    +After making code changes, the dev server will rebuild the mermaid library and automatically reload the page.
    +
    +Edit files in `packages/mermaid/src` as required.
    +
    +### Write Tests
    +
    +Tests ensure that each function, module, or part of code does what it says it will do. This is critically important when other changes are made to ensure that existing code is not broken (no regression).
    +
    +Just as important, the tests act as _specifications:_ they specify what the code does (or should do).
    +Whenever someone is new to a section of code, they should be able to read the tests to get a thorough understanding of what it does and why.
    +
    +If you are fixing a bug, you should add tests to ensure that your code has actually fixed the bug, to specify/describe what the code is doing, and to ensure the bug doesn't happen again.
    +(If there had been a test for the situation, the bug never would have happened in the first place.)
    +You may need to change existing tests if they were inaccurate.
    +
    +If you are adding a feature, you will definitely need to add tests. Depending on the size of your feature, you may need to add integration tests.
    +
    +#### Unit Tests
    +
    +Unit tests are tests that test a single function or module. They are the easiest to write and the fastest to run.
    +
    +Unit tests are mandatory for all code except the renderers. (The renderers are tested with integration tests.)
    +
    +We use [Vitest](https://vitest.dev) to run unit tests.
    +
    +**Host**
    +
    +You can use the following command to run the unit tests:
    +
    +```sh
    +pnpm test
    +```
    +
    +When writing new tests, it's easier to have the tests automatically run as you make changes. You can do this by running the following command:
    +
    +```sh
    +pnpm test:watch
    +```
    +
    +**Docker**
    +
    +When using Docker prepend your command with `./run`:
    +
    +```sh
    +./run pnpm test
    +```
    +
    +#### Integration / End-to-End (E2E) Tests
    +
    +These test the rendering and visual appearance of the diagrams.
    +
    +This ensures that the rendering of that feature in the E2E will be reviewed in the release process going forward. Less chance that it breaks!
    +
    +To start working with the E2E tests:
    +
    +**Host**
    +
    +- Run `pnpm dev` to start the dev server
    +- Start **Cypress** by running `pnpm cypress:open`
    +
    +**Docker**
    +
    +- Enable local connections for x11 server `xhost +local:`
    +- Run `./run pnpm dev` to start the dev server
    +- Start **Cypress** by running `./run pnpm cypress:open --project .`
    +
    +The rendering tests are very straightforward to create. There is a function `imgSnapshotTest`, which takes a diagram in text form and the mermaid options, and it renders that diagram in Cypress.
    +
    +When running in CI it will take a snapshot of the rendered diagram and compare it with the snapshot from last build and flag it for review if it differs.
    +
    +This is what a rendering test looks like:
    +
    +```js
    +it('should render forks and joins', () => {
    +  imgSnapshotTest(
    +    `
    +    stateDiagram
    +    state fork_state <<fork>>
    +      [*] --> fork_state
    +      fork_state --> State2
    +      fork_state --> State3
    +
    +      state join_state <<join>>
    +      State2 --> join_state
    +      State3 --> join_state
    +      join_state --> State4
    +      State4 --> [*]
    +    `,
    +    { logLevel: 0 }
    +  );
    +});
    +```
    +
    +
    +
    +
    +### Update Documentation
    +
    +```tip
    +Our documentation is managed in `packages/mermaid/src/docs`. Details on how to edit is in the [documentation section](#contributing-documentation)
    +```
    +
    +If the users have no way to know that things have changed, then you haven't really _fixed_ anything for the users; you've just added to making Mermaid feel broken.
    +Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused.
    +
    +The documentation has to be updated for users to know that things have been changed and added!
    +If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens.
    +
    +eg: `# Feature Name (v10.8.0+)`
    +
    +We know it can sometimes be hard to code _and_ write user documentation.
    +
    +Create another issue specifically for the documentation.
    +You will need to help with the PR, but definitely ask for help if you feel stuck.
    +When it feels hard to write stuff out, explaining it to someone and having that person ask you clarifying questions can often be 80% of the work!
    +
    +When in doubt, write up and submit what you can. It can be clarified and refined later. (With documentation, something is better than nothing!)
    +
    +## Contributing Documentation
    +
    +If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature?
    +
    +### Where is the Documentation Located?
    +
    +```warning
    +DO NOT CHANGE FILES IN `/docs`
    +
    +The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually.
    +```
    +
    +Documentation is located in the [`packages/mermaid/src/docs`](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) folder. Just pick the right section and start typing.
    +
    +The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch. Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published.
    +
    +```mermaid
    +flowchart LR
    +  classDef default fill:#fff,color:black,stroke:black
    +
    +  source["Edit /packages/mermaid/src/docs"] -- automatic processing--> published["View /docs which will be published on Official Website"]
    +```
    +
    +### Running the Documentation Website Locally
    +
    +**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).**
    +
    +Start development server for the documentation site
    +
    +**Host**
    +
    +```bash
    +pnpm --filter mermaid run docs:dev
    +```
    +
    +or
    +
    +```bash
    +cd packages/mermaid
    +pnpm docs:dev
    +```
    +
    +**Docker**
    +
    +```bash
    +./run docs:dev
    +```
    +
    +Open [http://localhost:3333/](http://localhost:3333/) in your browser.
    +
    +### Formatting
    +
    +The documentation is written in Markdown. To get acquainted with its syntax [see the GitHub Markdown help page](https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax).
    +
    +You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box.
    +
    +```danger
    +Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly.
    +```
    +
    +Here are a few examples:
    +
    +````markdown
    +```note
    +This is a note
    +```
    +
    +```tip
    +This is a tip
    +```
    +
    +```warning
    +This is a warning
    +```
    +
    +```danger
    +This is a danger alert
    +```
    +````
    +
    +```note
    +This is a note
    +```
    +
    +```tip
    +This is a tip
    +```
    +
    +```warning
    +This is a warning
    +```
    +
    +```danger
    +This is a danger alert
    +```
    +
    +### Navigation
    +
    +If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation**, which is defined in [the vitepress config](../.vitepress/config.ts). The same goes to **topbar**.
    +
    +### Build Docs
    +
    +The content of `/docs` folder is built with Github Actions.
    +
    +```warning
    +So as to allow automatic compilation of documentation pages you have to enable Github Actions on your fork first
    +```
    +
    +## Submit your pull request
    +
    +````note
    +Do not forget to push your changes
    +
    +```bash
    +git push -u origin docs/2910_update-guidelines
    +```
    +````
    +
    +We make all changes via Pull Requests (PRs). Open a new one.
    +
    +Right now we are not following any strict rules about naming PRs. Give it a representative title and short description. There is also a [pull request template](https://github.com/mermaid-js/mermaid/blob/develop/.github/pull_request_template.md) which will help you with it.
    +
    +In case in its description contains a [magic comment](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) your PR will be automatically attached to the issue:
    +
    +```markdown
    +Resolves #
    +```
    +
    +## Congratulations
    +
    +You have successfully submitted your improvements! What is next?
    +
    +- PRs will be reviewed by active maintainers, who will provide feedback and request changes as needed.
    +- The maintainers will request a review from _knsv_, if necessary.
    +- Once the PR is approved, the maintainers will merge the PR into the `develop` branch.
    +- When a release is ready, the `release/x.x.x` branch will be created, extensively tested and knsv will be in charge of the release process.
    +
    +Thanks for you help!
    +
    +
    diff --git a/packages/mermaid/src/docs/community/development.md b/packages/mermaid/src/docs/community/development.md
    deleted file mode 100644
    index fc11a1f6c0..0000000000
    --- a/packages/mermaid/src/docs/community/development.md
    +++ /dev/null
    @@ -1,90 +0,0 @@
    -# Contributing to Mermaid
    -
    -> The following documentation describes how to work with Mermaid in your host environment.
    -> There's also a [Docker installation guide](../community/docker-development.md)
    -> if you prefer to work in a Docker environment.
    -
    -So you want to help? That's great!
    -
    -![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif)
    -
    -Here are a few things to get you started on the right path.
    -
    -## Get the Source Code
    -
    -In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests.
    -
    -Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
    -
    -[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentation, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories).
    -
    -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
    -
    -## Technical Requirements
    -
    -> The following documentation describes how to work with Mermaid in your host environment.
    -> There's also a [Docker installation guide](../community/docker-development.md)
    -> if you prefer to work in a Docker environment.
    -
    -These are the tools we use for working with the code and documentation:
    -
    -- [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`
    -- [npx](https://docs.npmjs.com/cli/v8/commands/npx) the packaged executor in npm. This is needed [to install pnpm.](#install-packages)
    -
    -Follow the setup steps below to install them and start the development.
    -
    -## Setup and Launch
    -
    -### Switch to project
    -
    -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository)
    -
    -```bash
    -cd mermaid
    -```
    -
    -### Install packages
    -
    -Run `npx pnpm install`. You will need `npx` for this because volta doesn't support it yet.
    -
    -```bash
    -npx pnpm install # npx is required for first install
    -```
    -
    -### Launch
    -
    -```bash
    -npx pnpm run dev
    -```
    -
    -Now you are ready to make your changes! Edit whichever files in `src` as required.
    -
    -Open  in your browser, after starting the dev server.
    -There is a list of demos that can be used to see and test your changes.
    -
    -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy.
    -
    -That will be served at .
    -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!)
    -
    -## Verify Everything is Working
    -
    -You can run the `test` script to verify that pnpm is working _and_ that the repository has been cloned correctly:
    -
    -```bash
    -pnpm test
    -```
    -
    -The `test` script and others are in the top-level `package.json` file.
    -
    -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.)
    -
    -## Last Words
    -
    -Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there.
    -
    -[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
    -
    -![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif)
    diff --git a/packages/mermaid/src/docs/community/docker-development.md b/packages/mermaid/src/docs/community/docker-development.md
    deleted file mode 100644
    index 89e08b3f70..0000000000
    --- a/packages/mermaid/src/docs/community/docker-development.md
    +++ /dev/null
    @@ -1,104 +0,0 @@
    -# Contributing to Mermaid via Docker
    -
    -> The following documentation describes how to work with Mermaid in a Docker environment.
    -> There's also a [host installation guide](../community/development.md)
    -> if you prefer to work without a Docker environment.
    -
    -So you want to help? That's great!
    -
    -![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif)
    -
    -Here are a few things to get you started on the right path.
    -
    -## Get the Source Code
    -
    -In GitHub, you first **fork** a repository when you are going to make changes and submit pull requests.
    -
    -Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
    -
    -[Fork mermaid](https://github.com/mermaid-js/mermaid/fork) to start contributing to the main project and its documentation, or [search for other repositories](https://github.com/orgs/mermaid-js/repositories).
    -
    -[Here is a GitHub document that gives an overview of the process.](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
    -
    -## Technical Requirements
    -
    -> The following documentation describes how to work with Mermaid in a Docker environment.
    -> There's also a [host installation guide](../community/development.md)
    -> if you prefer to work without a Docker environment.
    -
    -[Install Docker](https://docs.docker.com/engine/install/). And that is pretty much all you need.
    -
    -Optionally, to run GUI (Cypress) within Docker you will also need an X11 server installed.
    -You might already have it installed, so check this by running:
    -
    -```bash
    -echo $DISPLAY
    -```
    -
    -If the `$DISPLAY` variable is not empty, then an X11 server is running. Otherwise you may need to install one.
    -
    -## Setup and Launch
    -
    -### Switch to project
    -
    -Once you have cloned the repository onto your development machine, change into the `mermaid` project folder (the top level directory of the mermaid project repository)
    -
    -```bash
    -cd mermaid
    -```
    -
    -### Make `./run` executable
    -
    -For development using Docker there is a self-documented `run` bash script, which provides convenient aliases for `docker compose` commands.
    -
    -Ensure `./run` script is executable:
    -
    -```bash
    -chmod +x run
    -```
    -
    -```tip
    -To get detailed help simply type `./run` or `./run help`.
    -
    -It also has short _Development quick start guide_ embedded.
    -```
    -
    -### Install packages
    -
    -```bash
    -./run pnpm install  # Install packages
    -```
    -
    -### Launch
    -
    -```bash
    -./run dev
    -```
    -
    -Now you are ready to make your changes! Edit whichever files in `src` as required.
    -
    -Open  in your browser, after starting the dev server.
    -There is a list of demos that can be used to see and test your changes.
    -
    -If you need a specific diagram, you can duplicate the `example.html` file in `/demos/dev` and add your own mermaid code to your copy.
    -
    -That will be served at .
    -After making code changes, the dev server will rebuild the mermaid library. You will need to reload the browser page yourself to see the changes. (PRs for auto reload are welcome!)
    -
    -## Verify Everything is Working
    -
    -```bash
    -./run pnpm test
    -```
    -
    -The `test` script and others are in the top-level `package.json` file.
    -
    -All tests should run successfully without any errors or failures. (You might see _lint_ or _formatting_ warnings; those are ok during this step.)
    -
    -## Last Words
    -
    -Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there.
    -
    -[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
    -
    -![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif)
    diff --git a/packages/mermaid/src/docs/community/documentation.md b/packages/mermaid/src/docs/community/documentation.md
    deleted file mode 100644
    index 6a0df983d1..0000000000
    --- a/packages/mermaid/src/docs/community/documentation.md
    +++ /dev/null
    @@ -1,92 +0,0 @@
    -# Contributing Documentation
    -
    -**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_**
    -
    -If it is not in the documentation, it's like it never happened. Wouldn't that be sad? With all the effort that was put into the feature?
    -
    -The docs are located in the `packages/mermaid/src/docs` folder and are written in Markdown. Just pick the right section and start typing.
    -
    -The contents of [mermaid.js.org](https://mermaid.js.org/) are based on the docs from the `master` branch.
    -Updates committed to the `master` branch are reflected in the [Mermaid Docs](https://mermaid.js.org/) once published.
    -
    -## How to Contribute to Documentation
    -
    -We are a little less strict here, it is OK to commit directly in the `develop` branch if you are a collaborator.
    -
    -The documentation is located in the `packages/mermaid/src/docs` directory and organized according to relevant subfolder.
    -
    -The `docs` folder will be automatically generated when committing to `packages/mermaid/src/docs` and **should not** be edited manually.
    -
    -```mermaid
    -flowchart LR
    -  classDef default fill:#fff,color:black,stroke:black
    -
    -  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"]
    -
    -```
    -
    -You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box.
    -Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly.
    -
    -````markdown
    -```note
    -Note content
    -```
    -
    -```tip
    -Tip content
    -```
    -
    -```warning
    -Warning content
    -```
    -
    -```danger
    -Danger content
    -```
    -````
    -
    -```note
    -If the change is _only_ to the documentation, you can get your changes published to the site quicker by making a PR to the `master` branch. In that case, your branch should be based on master, not develop.
    -```
    -
    -We encourage contributions to the documentation at [packages/mermaid/src/docs in the _develop_ branch](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs).
    -
    -**_DO NOT CHANGE FILES IN `/docs`_**
    -
    -## The official documentation site
    -
    -**[The mermaid documentation site](https://mermaid.js.org/) is powered by [Vitepress](https://vitepress.vuejs.org/).**
    -
    -To run the documentation site locally:
    -
    -1.  Run `pnpm --filter mermaid run docs:dev` to start the dev server. (Or `pnpm docs:dev` inside the `packages/mermaid` directory.)
    -2.  Open [http://localhost:3333/](http://localhost:3333/) in your browser.
    -
    -Markdown is used to format the text, 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).
    -
    -To edit Docs on your computer:
    -
    -_[TODO: need to keep this in sync with [check out a git branch in Contributing Code above](#1-checkout-a-git-branch) ]_
    -
    -1.  Create a fork of the develop branch to work on.
    -2.  Find the Markdown file (.md) to edit in the `packages/mermaid/src/docs` directory.
    -3.  Make changes or add new documentation.
    -4.  Commit changes to your branch and push it to GitHub (which should create a new branch).
    -5.  Create a Pull Request from the branch of your fork.
    -
    -To edit Docs on GitHub:
    -
    -1.  Login to [GitHub.com](https://www.github.com).
    -2.  Navigate to [packages/mermaid/src/docs](https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/src/docs) in the mermaid-js repository.
    -3.  To edit a file, click the pencil icon at the top-right of the file contents panel.
    -4.  Describe what you changed in the **Propose file change** section, located at the bottom of the page.
    -5.  Submit your changes by clicking the button **Propose file change** at the bottom (by automatic creation of a fork and a new branch).
    -6.  Visit the Actions tab in Github, `https://github.com//mermaid/actions` and enable the actions for your fork. This will ensure that the documentation is built and updated in your fork.
    -7.  Create a Pull Request of your newly forked branch by clicking the green **Create Pull Request** button.
    -
    -## Documentation organization: Sidebar navigation
    -
    -If you want to propose changes to how the documentation is _organized_, such as adding a new section or re-arranging or renaming a section, you must update the **sidebar navigation.**
    -
    -The sidebar navigation is defined in [the vitepress configuration file config.ts](../.vitepress/config.ts).
    diff --git a/packages/mermaid/src/docs/community/intro.md b/packages/mermaid/src/docs/community/intro.md
    new file mode 100644
    index 0000000000..a83b96380b
    --- /dev/null
    +++ b/packages/mermaid/src/docs/community/intro.md
    @@ -0,0 +1,58 @@
    +# Getting Started
    +
    +So you want to help? That's great!
    +
    +![Image of happy people jumping with excitement](https://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif)
    +
    +Here are a few things to get you started on the right path.
    +
    +## How can I help?
    +
    +```mermaid-nocode
    +mindmap
    +  root)Contributing(
    +    Development
    +      Solving issues
    +      Adding new diagrams
    +      Handling pull requests
    +      Updating tooling
    +    Testing
    +      Verification of fixed issues
    +      Regression testing in connection with releases
    +      Testing pull requests
    +    Management
    +      Coordinating the work
    +      Classification and monitoring of incoming issues
    +```
    +
    +## Join the Development
    +
    +```tip
    +**Check out our** [**detailed contribution guide**](./contributing.md).
    +```
    +
    +Where to start:
    +
    +- You could start getting some knowledge of the code base by working on [these "good first issues"](https://github.com/mermaid-js/mermaid/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%21%22+).
    +- You could jump right in and help us fix any of [these bugs](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug+%2F+Error%22++label%3A%22Contributor+needed%22+)!
    +- You could help write and [improve the documentation](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22).
    +- You could work on a new feature! [These](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22+) are some ideas!
    +- You could confirm the bugs in [these issues](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Triage%22++label%3A%22Type%3A+Bug+%2F+Error%22).
    +
    +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3)
    +
    +## A Question Or a Suggestion?
    +
    +```tip
    +**Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
    +```
    +
    +If you have faced a vulnerability [report it to us](./security.md).
    +
    +## Last Words
    +
    +Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there.
    +
    +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3)
    +
    +![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif)
    diff --git a/packages/mermaid/src/docs/community/newDiagram.md b/packages/mermaid/src/docs/community/new-diagram-jison.md
    similarity index 97%
    rename from packages/mermaid/src/docs/community/newDiagram.md
    rename to packages/mermaid/src/docs/community/new-diagram-jison.md
    index bc43475bfc..4a9020ba84 100644
    --- a/packages/mermaid/src/docs/community/newDiagram.md
    +++ b/packages/mermaid/src/docs/community/new-diagram-jison.md
    @@ -1,4 +1,10 @@
    -# Adding a New Diagram/Chart 📊
    +# Adding a New Diagram/Chart (Deprecated) 📊
    +
    +```warning
    +JISON grammars are deprecated in mermaid. Please use Langium instead. See [New Diagram](./new-diagram.md) for more information.
    +
    +**New diagrams with JISON grammars will not be accepted.**
    +```
     
     ### Step 1: Grammar & Parsing
     
    diff --git a/packages/mermaid/src/docs/community/new-diagram.md b/packages/mermaid/src/docs/community/new-diagram.md
    new file mode 100644
    index 0000000000..16504ca322
    --- /dev/null
    +++ b/packages/mermaid/src/docs/community/new-diagram.md
    @@ -0,0 +1,108 @@
    +# Adding a New Diagram/Chart 📊
    +
    +### Examples
    +
    +Please refer to the following PRs on how to use Langium to add a new diagram grammar.
    +
    +- https://github.com/mermaid-js/mermaid/pull/4839
    +- https://github.com/mermaid-js/mermaid/pull/4751
    +
    +```warning
    +The below steps are a work in progress and will be updated soon.
    +```
    +
    +### Step 1: Grammar & Parsing
    +
    +### Step 2: Rendering
    +
    +Write a renderer that given the data found during parsing renders the diagram. To look at an example look at sequenceRenderer.js rather than the flowchart renderer as this is a more generic example.
    +
    +Place the renderer in the diagram folder.
    +
    +### Step 3: Detection of the new diagram type
    +
    +The second thing to do is to add the capability to detect the new diagram to type to the detectType in `diagram-api/detectType.ts`. The detection should return a key for the new diagram type.
    +[This key will be used to as the aria roledescription](#aria-roledescription), so it should be a word that clearly describes the diagram type.
    +For example, if your new diagram uses a UML deployment diagram, a good key would be "UMLDeploymentDiagram" because assistive technologies such as a screen reader
    +would voice that as "U-M-L Deployment diagram." Another good key would be "deploymentDiagram" because that would be voiced as "Deployment Diagram." A bad key would be "deployment" because that would not sufficiently describe the diagram.
    +
    +Note that the diagram type key does not have to be the same as the diagram keyword chosen for the [grammar](#grammar), but it is helpful if they are the same.
    +
    +### Common parts of a diagram
    +
    +There are a few features that are common between the different types of diagrams. We try to standardize the diagrams that work as similar as possible for the end user. The commonalities are:
    +
    +- Directives, a way of modifying the diagram configuration from within the diagram code.
    +- Accessibility, a way for an author to provide additional information like titles and descriptions to people accessing a text with diagrams using a screen reader.
    +- Themes, there is a common way to modify the styling of diagrams in Mermaid.
    +- Comments should follow mermaid standards
    +
    +Here are some pointers on how to handle these different areas.
    +
    +## Accessibility
    +
    +Mermaid automatically adds the following accessibility information for the diagram SVG HTML element:
    +
    +- aria-roledescription
    +- accessible title
    +- accessible description
    +
    +### aria-roledescription
    +
    +The aria-roledescription is automatically set to [the diagram type](#step-3--detection-of-the-new-diagram-type) and inserted into the SVG element.
    +
    +See [the definition of aria-roledescription](https://www.w3.org/TR/wai-aria-1.1/#aria-roledescription) in [the Accessible Rich Internet Applications W3 standard.](https://www.w3.org/WAI/standards-guidelines/aria/)
    +
    +### accessible title and description
    +
    +The syntax for accessible titles and descriptions is described in [the Accessibility documentation section.](../config/accessibility.md)
    +
    +The functions for setting title and description are provided by a common module. This is the import in flowDb.js:
    +
    +```
    +import {
    +  setAccTitle,
    +  getAccTitle,
    +  getAccDescription,
    +  setAccDescription,
    +  clear as commonClear,
    +} from '../../commonDb';
    +```
    +
    +The accessibility title and description are inserted into the SVG element in the `render` function in mermaidAPI.
    +
    +## Theming
    +
    +Mermaid supports themes and has an integrated theming engine. You can read more about how the themes can be used [in the docs](../config/theming.md).
    +
    +When adding themes to a diagram it comes down to a few important locations in the code.
    +
    +The entry point for the styling engine is in **src/styles.js**. The getStyles function will be called by Mermaid when the styles are being applied to the diagram.
    +
    +This function will in turn call a function _your diagram should provide_ returning the css for the new diagram. The diagram specific, also which is commonly also called getStyles and located in the folder for your diagram under src/diagrams and should be named styles.js. The getStyles function will be called with the theme options as an argument like in the following example:
    +
    +```js
    +const getStyles = (options) =>
    +  `
    +    .line {
    +      stroke-width: 1;
    +      stroke: ${options.lineColor};
    +      stroke-dasharray: 2;
    +    }
    +    // ...
    +    `;
    +```
    +
    +Note that you need to provide your function to the main getStyles by adding it into the themes object in **src/styles.js** like in the xyzDiagram in the provided example:
    +
    +```js
    +const themes = {
    +  flowchart,
    +  'flowchart-v2': flowchart,
    +  sequence,
    +  xyzDiagram,
    +  //...
    +};
    +```
    +
    +The actual options and values for the colors are defined in **src/theme/theme-[xyz].js**. If you provide the options your diagram needs in the existing theme files then the theming will work smoothly without hiccups.
    diff --git a/packages/mermaid/src/docs/community/questions-and-suggestions.md b/packages/mermaid/src/docs/community/questions-and-suggestions.md
    index 386e3753a1..6408d7fed1 100644
    --- a/packages/mermaid/src/docs/community/questions-and-suggestions.md
    +++ b/packages/mermaid/src/docs/community/questions-and-suggestions.md
    @@ -1,19 +1,19 @@
     # Questions or Suggestions?
     
    -**_[TODO: This section is still a WIP. It still needs MAJOR revision.]_**
    +## Search for Existing Issue
     
    -## First search to see if someone has already asked (and hopefully been answered) or suggested the same thing.
    +First search to see if someone has already asked (and hopefully been answered) or suggested the same thing.
     
     - [Search in Discussions](https://github.com/orgs/mermaid-js/discussions)
     - [Search in Issues (Open & Closed)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue)
     
     If you find an open issue or discussion thread that is similar to your question but isn't answered, you can let us know that you are also interested in it.
    -Use the GitHub reactions to add a thumbs-up to the issue or discussion thread.
    +Use the GitHub reactions to add a thumbs-up to the issue or discussion thread, or append to the issue if needed.
     
     This helps the team know the relative interest in something and helps them set priorities and assignments.
     
    -Feel free to add to the discussion on the issue or topic.
    +## Add a new Issue
     
    -If you can't find anything that already addresses your question or suggestion, _open a new issue:_
    +You have not found anything that already addresses your request, or maybe you have come up with the new idea? Feel free to open a new issue or discussion.
     
    -Log in to [GitHub.com](https://www.github.com), open or append to an issue [using the GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Documentation%22).
    +Log in to [GitHub.com](https://www.github.com), and use [GitHub issue tracker of the mermaid-js repository](https://github.com/mermaid-js/mermaid/issues). Press [https://github.com/mermaid-js/mermaid/issues/new/choose] issue, select the appropriate template and describe your problem.
    diff --git a/packages/mermaid/src/docs/community/security.md b/packages/mermaid/src/docs/community/security.md
    index e7a0db6edb..a84a106ab3 100644
    --- a/packages/mermaid/src/docs/community/security.md
    +++ b/packages/mermaid/src/docs/community/security.md
    @@ -10,7 +10,7 @@ We aim to reply within three working days, probably much sooner.
     
     You should expect a close collaboration as we work to resolve the issue you have reported. Please reach out to  again if you do not receive prompt attention and regular updates.
     
    -You may also reach out to the team via our public Slack chat channels; however, please make sure to e-mail  when reporting an issue, and avoid revealing information about vulnerabilities in public as that could that could put users at risk.
    +You may also reach out to the team via our public Discord chat channels; however, please make sure to e-mail  when reporting an issue, and avoid revealing information about vulnerabilities in public as that could that could put users at risk.
     
     ## Best practices
     
    diff --git a/packages/mermaid/src/docs/config/accessibility.md b/packages/mermaid/src/docs/config/accessibility.md
    index 559c739874..b53567f730 100644
    --- a/packages/mermaid/src/docs/config/accessibility.md
    +++ b/packages/mermaid/src/docs/config/accessibility.md
    @@ -13,7 +13,7 @@ Mermaid will automatically insert the [aria-roledescription](#aria-roledescripti
     
     The [aria-roledescription](https://www.w3.org/TR/wai-aria-1.1/#aria-roledescription) for the SVG HTML element is set to the diagram type key. (Note this may be slightly different than the keyword used for the diagram in the diagram text.)
     
    -For example: The diagram type key for a state diagram is "stateDiagram". Here (a part of) the HTML of the SVG tag that shows the automatically inserted aria-roledscription set to "stateDiagram". _(Note that some of the SVG attributes and the SVG contents are omitted for clarity.):_
    +For example: The diagram type key for a state diagram is "stateDiagram". Here (a part of) the HTML of the SVG tag that shows the automatically inserted aria-roledescription set to "stateDiagram". _(Note that some of the SVG attributes and the SVG contents are omitted for clarity.):_
     
     ```html
     
    -  
    -
    -```
    -
    -The actual mermaid file could for example look like this:
    -
    -```javascript
    -mermaid content ...
    -```
    -
    -## mermaid configuration options
    -
    -```markdown
    -(coming soon)
    -```
    diff --git a/packages/mermaid/src/docs/config/math.md b/packages/mermaid/src/docs/config/math.md
    new file mode 100644
    index 0000000000..22b398e087
    --- /dev/null
    +++ b/packages/mermaid/src/docs/config/math.md
    @@ -0,0 +1,62 @@
    +# Math Configuration (v10.9.0+)
    +
    +Mermaid supports rendering mathematical expressions through the [KaTeX](https://katex.org/) typesetter.
    +
    +## Usage
    +
    +To render math within a diagram, surround the mathematical expression with the `$$` delimiter.
    +
    +Note that at the moment, the only supported diagrams are below:
    +
    +### Flowcharts
    +
    +```mermaid
    + graph LR
    +      A["$$x^2$$"] -->|"$$\sqrt{x+3}$$"| B("$$\frac{1}{2}$$")
    +      A -->|"$$\overbrace{a+b+c}^{\text{note}}$$"| C("$$\pi r^2$$")
    +      B --> D("$$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$$")
    +      C --> E("$$x(t)=c_1\begin{bmatrix}-\cos{t}+\sin{t}\\ 2\cos{t} \end{bmatrix}e^{2t}$$")
    +```
    +
    +### Sequence
    +
    +```mermaid
    +sequenceDiagram
    +    autonumber
    +    participant 1 as $$\alpha$$
    +    participant 2 as $$\beta$$
    +    1->>2: Solve: $$\sqrt{2+2}$$
    +    2-->>1: Answer: $$2$$
    +    Note right of 2: $$\sqrt{2+2}=\sqrt{4}=2$$
    +```
    +
    +## Legacy Support
    +
    +By default, MathML is used for rendering mathematical expressions. If you have users on [unsupported browsers](https://caniuse.com/?search=mathml), `legacyMathML` can be set in the config to fall back to CSS rendering. Note that **you must provide KaTeX's stylesheets on your own** as they do not come bundled with Mermaid.
    +
    +Example with legacy mode enabled (the latest version of KaTeX's stylesheet can be found on their [docs](https://katex.org/docs/browser.html)):
    +
    +```html
    +
    +
    +
    +  
    +    
    +    
    +  
    +
    +  
    +    
    +  
    +
    +```
    diff --git a/packages/mermaid/src/docs/config/theming.md b/packages/mermaid/src/docs/config/theming.md
    index 0e08532837..3863202b42 100644
    --- a/packages/mermaid/src/docs/config/theming.md
    +++ b/packages/mermaid/src/docs/config/theming.md
    @@ -47,7 +47,7 @@ Example of `init` directive setting the `theme` to `forest`:
         a --> b
     ```
     
    -> **Reminder**: the only theme that can be customed is the `base` theme. The following section covers how to use `themeVariables` for customizations.
    +> **Reminder**: the only theme that can be customized is the `base` theme. The following section covers how to use `themeVariables` for customizations.
     
     ## Customizing Themes with `themeVariables`
     
    @@ -172,7 +172,7 @@ The theming engine will only recognize hex colors and not color names. So, the v
     | actorBkg              | mainBkg                        | Actor Background Color      |
     | actorBorder           | primaryBorderColor             | Actor Border Color          |
     | actorTextColor        | primaryTextColor               | Actor Text Color            |
    -| actorLineColor        | grey                           | Actor Line Color            |
    +| actorLineColor        | actorBorder                    | Actor Line Color            |
     | signalColor           | textColor                      | Signal Color                |
     | signalTextColor       | textColor                      | Signal Text Color           |
     | labelBoxBkgColor      | actorBkg                       | Label Box Background Color  |
    diff --git a/packages/mermaid/src/docs/config/usage.md b/packages/mermaid/src/docs/config/usage.md
    index ae3ad0f0aa..eec87e49f5 100644
    --- a/packages/mermaid/src/docs/config/usage.md
    +++ b/packages/mermaid/src/docs/config/usage.md
    @@ -14,7 +14,7 @@ Please note that you can switch versions through the dropdown box at the top rig
     
     For the majority of users, Using the [Live Editor](https://mermaid.live/) would be sufficient, however you may also opt to deploy mermaid as a dependency or using the [Mermaid API](./setup/README.md).
     
    -We have compiled some Video [Tutorials](./Tutorials.md) on how to use the Mermaid Live Editor.
    +We have compiled some Video [Tutorials](../ecosystem/tutorials.md) on how to use the Mermaid Live Editor.
     
     ### Installing and Hosting Mermaid on a Webpage
     
    @@ -67,7 +67,7 @@ Example:
     ## Simple full example:
     
     ```html
    -
    +
     
       
         
    @@ -328,15 +328,17 @@ module.exports = (options) ->
     
     ## Advanced usage
     
    -**Syntax validation without rendering (Work in Progress)**
    +### Syntax validation without rendering
     
    -The **mermaid.parse(txt)** function validates graph definitions without rendering a graph. **[This function is still a work in progress](https://github.com/mermaid-js/mermaid/issues/1066), find alternatives below.**
    +The `mermaid.parse(text, parseOptions)` function validates graph definitions without rendering a graph.
     
    -The function **mermaid.parse(txt)**, takes a text string as an argument and returns true if the definition follows mermaid's syntax and
    -false if it does not. The parseError function will be called when the parse function returns false.
    +The function `mermaid.parse(text, parseOptions)`, takes a text string as an argument and returns `{ diagramType: string }` if the definition follows mermaid's syntax.
     
    -When the parser encounters invalid syntax the **mermaid.parseError** function is called. It is possible to override this
    -function in order to handle the error in an application-specific way.
    +If the definition is invalid, the function returns `false` if `parseOptions.suppressErrors` is set to `true`. Otherwise, it throws an error.
    +
    +The parseError function will be called when the parse function throws an error. It will not be called if `parseOptions.suppressErrors` is set to `true`.
    +
    +It is possible to override this function in order to handle the error in an application-specific way.
     
     The code-example below in meta code illustrates how this could work:
     
    @@ -356,26 +358,10 @@ const textFieldUpdated = async function () {
     bindEventHandler('change', 'code', textFieldUpdated);
     ```
     
    -**Alternative to mermaid.parse():**
    -One effective and more future-proof method of validating your graph definitions, is to paste and render them via the [Mermaid Live Editor](https://mermaid.live/). This will ensure that your code is compliant with the syntax of Mermaid's most recent version.
    -
     ## Configuration
     
    -Mermaid takes a number of options which lets you tweak the rendering of the diagrams. Currently there are three ways of
    -setting the options in mermaid.
    -
    -1. Instantiation of the configuration using the initialize call
    -2. _Using the global mermaid object_ - **Deprecated**
    -3. _using the global mermaid_config object_ - **Deprecated**
    -4. Instantiation of the configuration using the **mermaid.init** call- **Deprecated**
    -
    -The list above has two ways too many of doing this. Three are deprecated and will eventually be removed. The list of
    -configuration objects are described [in the mermaidAPI documentation](./setup/README.md).
    -
    -## Using the `mermaidAPI.initialize`/`mermaid.initialize` call
    -
    -The future proof way of setting the configuration is by using the initialization call to mermaid or mermaidAPI depending
    -on what kind of integration you use.
    +You can pass the required configuration to the `mermaid.initialize` call. This is the preferred way of configuring mermaid.
    +The list of configuration objects are described [in the mermaidAPI documentation](./setup/README.md).
     
     ```html