mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 19:04:16 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			release/10
			...
			sidv/useUn
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | f85f4bb661 | 
| @@ -3,5 +3,4 @@ dist/** | |||||||
| docs/Setup.md | docs/Setup.md | ||||||
| cypress.config.js | cypress.config.js | ||||||
| cypress/plugins/index.js | cypress/plugins/index.js | ||||||
| coverage | coverage | ||||||
| *.json |  | ||||||
							
								
								
									
										150
									
								
								.eslintrc.cjs
									
									
									
									
									
								
							
							
						
						
									
										150
									
								
								.eslintrc.cjs
									
									
									
									
									
								
							| @@ -1,150 +0,0 @@ | |||||||
| module.exports = { |  | ||||||
|   env: { |  | ||||||
|     browser: true, |  | ||||||
|     es6: true, |  | ||||||
|     'jest/globals': true, |  | ||||||
|     node: true, |  | ||||||
|   }, |  | ||||||
|   root: true, |  | ||||||
|   parser: '@typescript-eslint/parser', |  | ||||||
|   parserOptions: { |  | ||||||
|     ecmaFeatures: { |  | ||||||
|       experimentalObjectRestSpread: true, |  | ||||||
|       jsx: true, |  | ||||||
|     }, |  | ||||||
|     tsconfigRootDir: __dirname, |  | ||||||
|     sourceType: 'module', |  | ||||||
|     ecmaVersion: 2020, |  | ||||||
|     allowAutomaticSingleRunInference: true, |  | ||||||
|     project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], |  | ||||||
|     parser: '@typescript-eslint/parser', |  | ||||||
|   }, |  | ||||||
|   extends: [ |  | ||||||
|     'eslint:recommended', |  | ||||||
|     'plugin:@typescript-eslint/recommended', |  | ||||||
|     'plugin:json/recommended', |  | ||||||
|     'plugin:markdown/recommended', |  | ||||||
|     'plugin:@cspell/recommended', |  | ||||||
|     'prettier', |  | ||||||
|   ], |  | ||||||
|   plugins: [ |  | ||||||
|     '@typescript-eslint', |  | ||||||
|     'no-only-tests', |  | ||||||
|     'html', |  | ||||||
|     'jest', |  | ||||||
|     'jsdoc', |  | ||||||
|     'json', |  | ||||||
|     '@cspell', |  | ||||||
|     'lodash', |  | ||||||
|     'unicorn', |  | ||||||
|   ], |  | ||||||
|   rules: { |  | ||||||
|     curly: 'error', |  | ||||||
|     'no-console': 'error', |  | ||||||
|     'no-prototype-builtins': 'off', |  | ||||||
|     'no-unused-vars': 'off', |  | ||||||
|     'cypress/no-async-tests': 'off', |  | ||||||
|     '@typescript-eslint/no-floating-promises': 'error', |  | ||||||
|     '@typescript-eslint/no-misused-promises': 'error', |  | ||||||
|     '@typescript-eslint/ban-ts-comment': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'ts-expect-error': 'allow-with-description', |  | ||||||
|         'ts-ignore': 'allow-with-description', |  | ||||||
|         'ts-nocheck': 'allow-with-description', |  | ||||||
|         'ts-check': 'allow-with-description', |  | ||||||
|         minimumDescriptionLength: 10, |  | ||||||
|       }, |  | ||||||
|     ], |  | ||||||
|     'json/*': ['error', 'allowComments'], |  | ||||||
|     '@cspell/spellchecker': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         checkIdentifiers: false, |  | ||||||
|         checkStrings: false, |  | ||||||
|         checkStringTemplates: false, |  | ||||||
|       }, |  | ||||||
|     ], |  | ||||||
|     'no-empty': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         allowEmptyCatch: true, |  | ||||||
|       }, |  | ||||||
|     ], |  | ||||||
|     'no-only-tests/no-only-tests': 'error', |  | ||||||
|     'lodash/import-scope': ['error', 'method'], |  | ||||||
|     'unicorn/better-regex': 'error', |  | ||||||
|     'unicorn/no-abusive-eslint-disable': 'error', |  | ||||||
|     'unicorn/no-array-push-push': 'error', |  | ||||||
|     'unicorn/no-for-loop': 'error', |  | ||||||
|     'unicorn/no-instanceof-array': 'error', |  | ||||||
|     'unicorn/no-typeof-undefined': 'error', |  | ||||||
|     'unicorn/no-unnecessary-await': 'error', |  | ||||||
|     'unicorn/no-unsafe-regex': 'warn', |  | ||||||
|     'unicorn/no-useless-promise-resolve-reject': 'error', |  | ||||||
|     'unicorn/prefer-array-find': 'error', |  | ||||||
|     'unicorn/prefer-array-flat-map': 'error', |  | ||||||
|     'unicorn/prefer-array-index-of': 'error', |  | ||||||
|     'unicorn/prefer-array-some': 'error', |  | ||||||
|     'unicorn/prefer-default-parameters': 'error', |  | ||||||
|     'unicorn/prefer-includes': 'error', |  | ||||||
|     'unicorn/prefer-negative-index': 'error', |  | ||||||
|     'unicorn/prefer-object-from-entries': 'error', |  | ||||||
|     'unicorn/prefer-string-starts-ends-with': 'error', |  | ||||||
|     'unicorn/prefer-string-trim-start-end': 'error', |  | ||||||
|     'unicorn/string-content': 'error', |  | ||||||
|     'unicorn/prefer-spread': 'error', |  | ||||||
|     'unicorn/no-lonely-if': 'error', |  | ||||||
|   }, |  | ||||||
|   overrides: [ |  | ||||||
|     { |  | ||||||
|       files: ['cypress/**', 'demos/**'], |  | ||||||
|       rules: { |  | ||||||
|         'no-console': 'off', |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       files: ['*.{js,jsx,mjs,cjs}'], |  | ||||||
|       extends: ['plugin:jsdoc/recommended'], |  | ||||||
|       rules: { |  | ||||||
|         'jsdoc/check-indentation': 'off', |  | ||||||
|         'jsdoc/check-alignment': 'off', |  | ||||||
|         'jsdoc/check-line-alignment': 'off', |  | ||||||
|         'jsdoc/multiline-blocks': 'off', |  | ||||||
|         'jsdoc/newline-after-description': 'off', |  | ||||||
|         'jsdoc/tag-lines': 'off', |  | ||||||
|         'jsdoc/require-param-description': 'off', |  | ||||||
|         'jsdoc/require-param-type': 'off', |  | ||||||
|         'jsdoc/require-returns': 'off', |  | ||||||
|         'jsdoc/require-returns-description': 'off', |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       files: ['*.{ts,tsx}'], |  | ||||||
|       plugins: ['tsdoc'], |  | ||||||
|       rules: { |  | ||||||
|         'tsdoc/syntax': 'error', |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       files: ['*.spec.{ts,js}', 'cypress/**', 'demos/**', '**/docs/**'], |  | ||||||
|       rules: { |  | ||||||
|         'jsdoc/require-jsdoc': 'off', |  | ||||||
|         '@typescript-eslint/no-unused-vars': 'off', |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       files: ['*.html', '*.md', '**/*.md/*'], |  | ||||||
|       rules: { |  | ||||||
|         'no-var': 'error', |  | ||||||
|         'no-undef': 'off', |  | ||||||
|         '@typescript-eslint/no-unused-vars': 'off', |  | ||||||
|         '@typescript-eslint/no-floating-promises': 'off', |  | ||||||
|         '@typescript-eslint/no-misused-promises': 'off', |  | ||||||
|       }, |  | ||||||
|       parserOptions: { |  | ||||||
|         project: null, |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   ], |  | ||||||
| }; |  | ||||||
							
								
								
									
										138
									
								
								.eslintrc.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								.eslintrc.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,138 @@ | |||||||
|  | { | ||||||
|  |   "env": { | ||||||
|  |     "browser": true, | ||||||
|  |     "es6": true, | ||||||
|  |     "jest/globals": true, | ||||||
|  |     "node": true | ||||||
|  |   }, | ||||||
|  |   "parser": "@typescript-eslint/parser", | ||||||
|  |   "parserOptions": { | ||||||
|  |     "ecmaFeatures": { | ||||||
|  |       "experimentalObjectRestSpread": true, | ||||||
|  |       "jsx": true | ||||||
|  |     }, | ||||||
|  |     "sourceType": "module" | ||||||
|  |   }, | ||||||
|  |   "extends": [ | ||||||
|  |     "eslint:recommended", | ||||||
|  |     "plugin:@typescript-eslint/recommended", | ||||||
|  |     "plugin:json/recommended", | ||||||
|  |     "plugin:markdown/recommended", | ||||||
|  |     "plugin:@cspell/recommended", | ||||||
|  |     "prettier" | ||||||
|  |   ], | ||||||
|  |   "plugins": [ | ||||||
|  |     "@typescript-eslint", | ||||||
|  |     "no-only-tests", | ||||||
|  |     "html", | ||||||
|  |     "jest", | ||||||
|  |     "jsdoc", | ||||||
|  |     "json", | ||||||
|  |     "@cspell", | ||||||
|  |     "lodash", | ||||||
|  |     "unicorn" | ||||||
|  |   ], | ||||||
|  |   "rules": { | ||||||
|  |     "curly": "error", | ||||||
|  |     "no-console": "error", | ||||||
|  |     "no-prototype-builtins": "off", | ||||||
|  |     "no-unused-vars": "off", | ||||||
|  |     "cypress/no-async-tests": "off", | ||||||
|  |     "@typescript-eslint/ban-ts-comment": [ | ||||||
|  |       "error", | ||||||
|  |       { | ||||||
|  |         "ts-expect-error": "allow-with-description", | ||||||
|  |         "ts-ignore": "allow-with-description", | ||||||
|  |         "ts-nocheck": "allow-with-description", | ||||||
|  |         "ts-check": "allow-with-description", | ||||||
|  |         "minimumDescriptionLength": 10 | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "json/*": ["error", "allowComments"], | ||||||
|  |     "@cspell/spellchecker": [ | ||||||
|  |       "error", | ||||||
|  |       { | ||||||
|  |         "checkIdentifiers": false, | ||||||
|  |         "checkStrings": false, | ||||||
|  |         "checkStringTemplates": false | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "no-empty": [ | ||||||
|  |       "error", | ||||||
|  |       { | ||||||
|  |         "allowEmptyCatch": true | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "no-only-tests/no-only-tests": "error", | ||||||
|  |     "lodash/import-scope": ["error", "method"], | ||||||
|  |     "unicorn/better-regex": "error", | ||||||
|  |     "unicorn/no-abusive-eslint-disable": "error", | ||||||
|  |     "unicorn/no-array-push-push": "error", | ||||||
|  |     "unicorn/no-for-loop": "error", | ||||||
|  |     "unicorn/no-null": "error", | ||||||
|  |     "unicorn/no-instanceof-array": "error", | ||||||
|  |     "unicorn/no-typeof-undefined": "error", | ||||||
|  |     "unicorn/no-unnecessary-await": "error", | ||||||
|  |     "unicorn/no-unsafe-regex": "warn", | ||||||
|  |     "unicorn/no-useless-promise-resolve-reject": "error", | ||||||
|  |     "unicorn/prefer-array-find": "error", | ||||||
|  |     "unicorn/prefer-array-flat-map": "error", | ||||||
|  |     "unicorn/prefer-array-index-of": "error", | ||||||
|  |     "unicorn/prefer-array-some": "error", | ||||||
|  |     "unicorn/prefer-default-parameters": "error", | ||||||
|  |     "unicorn/prefer-includes": "error", | ||||||
|  |     "unicorn/prefer-negative-index": "error", | ||||||
|  |     "unicorn/prefer-object-from-entries": "error", | ||||||
|  |     "unicorn/prefer-string-starts-ends-with": "error", | ||||||
|  |     "unicorn/prefer-string-trim-start-end": "error", | ||||||
|  |     "unicorn/string-content": "error", | ||||||
|  |     "unicorn/prefer-spread": "error", | ||||||
|  |     "unicorn/no-lonely-if": "error" | ||||||
|  |   }, | ||||||
|  |   "overrides": [ | ||||||
|  |     { | ||||||
|  |       "files": ["cypress/**", "demos/**"], | ||||||
|  |       "rules": { | ||||||
|  |         "no-console": "off" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "files": ["*.{js,jsx,mjs,cjs}"], | ||||||
|  |       "extends": ["plugin:jsdoc/recommended"], | ||||||
|  |       "rules": { | ||||||
|  |         "jsdoc/check-indentation": "off", | ||||||
|  |         "jsdoc/check-alignment": "off", | ||||||
|  |         "jsdoc/check-line-alignment": "off", | ||||||
|  |         "jsdoc/multiline-blocks": "off", | ||||||
|  |         "jsdoc/newline-after-description": "off", | ||||||
|  |         "jsdoc/tag-lines": "off", | ||||||
|  |         "jsdoc/require-param-description": "off", | ||||||
|  |         "jsdoc/require-param-type": "off", | ||||||
|  |         "jsdoc/require-returns": "off", | ||||||
|  |         "jsdoc/require-returns-description": "off" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "files": ["*.{ts,tsx}"], | ||||||
|  |       "plugins": ["tsdoc"], | ||||||
|  |       "rules": { | ||||||
|  |         "tsdoc/syntax": "error" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "files": ["*.spec.{ts,js}", "cypress/**", "demos/**", "**/docs/**"], | ||||||
|  |       "rules": { | ||||||
|  |         "jsdoc/require-jsdoc": "off", | ||||||
|  |         "@typescript-eslint/no-unused-vars": "off" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "files": ["*.html", "*.md", "**/*.md/*"], | ||||||
|  |       "rules": { | ||||||
|  |         "no-var": "error", | ||||||
|  |         "no-undef": "off", | ||||||
|  |         "@typescript-eslint/no-unused-vars": "off" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   ] | ||||||
|  | } | ||||||
							
								
								
									
										4
									
								
								.github/FUNDING.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/FUNDING.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,8 +1,6 @@ | |||||||
| # These are supported funding model platforms | # These are supported funding model platforms | ||||||
|  |  | ||||||
| github: | github: [knsv] | ||||||
|   - knsv |  | ||||||
|   - sidharthv96 |  | ||||||
| #patreon: # Replace with a single Patreon username | #patreon: # Replace with a single Patreon username | ||||||
| #open_collective: # Replace with a single Open Collective username | #open_collective: # Replace with a single Open Collective username | ||||||
| #ko_fi: # Replace with a single Ko-fi username | #ko_fi: # Replace with a single Ko-fi username | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| blank_issues_enabled: true | blank_issues_enabled: false | ||||||
| contact_links: | contact_links: | ||||||
|   - name: GitHub Discussions |   - name: GitHub Discussions | ||||||
|     url: https://github.com/mermaid-js/mermaid/discussions |     url: https://github.com/mermaid-js/mermaid/discussions | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/workflows/dependency-review.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/dependency-review.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,4 +17,4 @@ jobs: | |||||||
|       - name: 'Checkout Repository' |       - name: 'Checkout Repository' | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
|       - name: 'Dependency Review' |       - name: 'Dependency Review' | ||||||
|         uses: actions/dependency-review-action@v3 |         uses: actions/dependency-review-action@v2 | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,7 +32,6 @@ jobs: | |||||||
|       # and run all Cypress tests |       # and run all Cypress tests | ||||||
|       - name: Cypress run |       - name: Cypress run | ||||||
|         uses: cypress-io/github-action@v4 |         uses: cypress-io/github-action@v4 | ||||||
|         id: cypress |  | ||||||
|         # If CYPRESS_RECORD_KEY is set, run in parallel on all containers |         # 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 |         # Otherwise (e.g. if running from fork), we run on a single container only | ||||||
|         if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }} |         if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }} | ||||||
| @@ -45,10 +44,3 @@ jobs: | |||||||
|           parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }} |           parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }} | ||||||
|         env: |         env: | ||||||
|           CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} |           CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||||||
|  |  | ||||||
|       - name: Upload Artifacts |  | ||||||
|         uses: actions/upload-artifact@v3 |  | ||||||
|         if: ${{ failure() && steps.cypress.conclusion == 'failure' }} |  | ||||||
|         with: |  | ||||||
|           name: error-snapshots |  | ||||||
|           path: cypress/snapshots/**/__diff_output__/* |  | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								.github/workflows/lint.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/lint.yml
									
									
									
									
										vendored
									
									
								
							| @@ -37,20 +37,7 @@ jobs: | |||||||
|           CYPRESS_CACHE_FOLDER: .cache/Cypress |           CYPRESS_CACHE_FOLDER: .cache/Cypress | ||||||
|  |  | ||||||
|       - name: Run Linting |       - name: Run Linting | ||||||
|         shell: bash |         run: pnpm run lint | ||||||
|         run: | |  | ||||||
|           if ! pnpm run lint; then |  | ||||||
|               # print a nice error message on lint failure |  | ||||||
|               ERROR_MESSAGE='Running `pnpm run lint` failed.' |  | ||||||
|               ERROR_MESSAGE+=' Running `pnpm run lint:fix` may fix this issue. ' |  | ||||||
|               ERROR_MESSAGE+=" If this error doesn't occur on your local machine," |  | ||||||
|               ERROR_MESSAGE+=' make sure your packages are up-to-date by running `pnpm install`.' |  | ||||||
|               ERROR_MESSAGE+=' You may also need to delete your prettier cache by running' |  | ||||||
|               ERROR_MESSAGE+=' `rm ./node_modules/.cache/prettier/.prettier-cache`.' |  | ||||||
|               echo "::error title=Lint failure::${ERROR_MESSAGE}" |  | ||||||
|               # make sure to return an error exitcode so that GitHub actions shows a red-cross |  | ||||||
|               exit 1 |  | ||||||
|           fi |  | ||||||
|  |  | ||||||
|       - name: Verify Docs |       - name: Verify Docs | ||||||
|         id: verifyDocs |         id: verifyDocs | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/workflows/pr-labeler.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/pr-labeler.yml
									
									
									
									
										vendored
									
									
								
							| @@ -8,6 +8,6 @@ jobs: | |||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     steps: |     steps: | ||||||
|       - name: Label PR |       - name: Label PR | ||||||
|         uses: TimonVS/pr-labeler-action@v4 |         uses: TimonVS/pr-labeler-action@v3 | ||||||
|         env: |         env: | ||||||
|           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								.github/workflows/publish-docs.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/publish-docs.yml
									
									
									
									
										vendored
									
									
								
							| @@ -5,7 +5,6 @@ on: | |||||||
|   push: |   push: | ||||||
|     branches: |     branches: | ||||||
|       - master |       - master | ||||||
|   pull_request: |  | ||||||
|  |  | ||||||
|   # Allows you to run this workflow manually from the Actions tab |   # Allows you to run this workflow manually from the Actions tab | ||||||
|   workflow_dispatch: |   workflow_dispatch: | ||||||
| @@ -41,7 +40,7 @@ jobs: | |||||||
|         run: pnpm install --frozen-lockfile |         run: pnpm install --frozen-lockfile | ||||||
|  |  | ||||||
|       - name: Setup Pages |       - name: Setup Pages | ||||||
|         uses: actions/configure-pages@v3 |         uses: actions/configure-pages@v2 | ||||||
|  |  | ||||||
|       - name: Run Build |       - name: Run Build | ||||||
|         run: pnpm --filter mermaid run docs:build:vitepress |         run: pnpm --filter mermaid run docs:build:vitepress | ||||||
| @@ -53,7 +52,6 @@ jobs: | |||||||
|  |  | ||||||
|   # Deployment job |   # Deployment job | ||||||
|   deploy: |   deploy: | ||||||
|     if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} |  | ||||||
|     environment: |     environment: | ||||||
|       name: github-pages |       name: github-pages | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								.github/workflows/release-publish.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								.github/workflows/release-publish.yml
									
									
									
									
										vendored
									
									
								
							| @@ -11,21 +11,18 @@ jobs: | |||||||
|       - uses: actions/checkout@v3 |       - uses: actions/checkout@v3 | ||||||
|       - uses: fregante/setup-git-user@v1 |       - uses: fregante/setup-git-user@v1 | ||||||
|  |  | ||||||
|       - uses: pnpm/action-setup@v2 |       - name: Setup Node.js | ||||||
|         # uses version from "packageManager" field in package.json |  | ||||||
|  |  | ||||||
|       - name: Setup Node.js v18 |  | ||||||
|         uses: actions/setup-node@v3 |         uses: actions/setup-node@v3 | ||||||
|         with: |         with: | ||||||
|           cache: pnpm |  | ||||||
|           node-version: 18.x |           node-version: 18.x | ||||||
|  |       - name: Install Yarn | ||||||
|  |         run: npm i yarn --global | ||||||
|  |  | ||||||
|  |       - name: Install Json | ||||||
|  |         run: npm i json --global | ||||||
|  |  | ||||||
|       - name: Install Packages |       - name: Install Packages | ||||||
|         run: | |         run: yarn install --frozen-lockfile | ||||||
|           pnpm install --frozen-lockfile |  | ||||||
|           npm i json --global |  | ||||||
|         env: |  | ||||||
|           CYPRESS_CACHE_FOLDER: .cache/Cypress |  | ||||||
|  |  | ||||||
|       - name: Prepare release |       - name: Prepare release | ||||||
|         run: | |         run: | | ||||||
| @@ -34,7 +31,7 @@ jobs: | |||||||
|           git checkout -t origin/release/$VERSION |           git checkout -t origin/release/$VERSION | ||||||
|           npm version --no-git-tag-version --allow-same-version $VERSION |           npm version --no-git-tag-version --allow-same-version $VERSION | ||||||
|           git add package.json |           git add package.json | ||||||
|           git commit -nm "Bump version $VERSION" |           git commit -m "Bump version $VERSION" | ||||||
|           git checkout -t origin/master |           git checkout -t origin/master | ||||||
|           git merge -m "Release $VERSION" --no-ff release/$VERSION |           git merge -m "Release $VERSION" --no-ff release/$VERSION | ||||||
|           git push --no-verify |           git push --no-verify | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -33,14 +33,6 @@ jobs: | |||||||
|         run: | |         run: | | ||||||
|           pnpm run ci --coverage |           pnpm run ci --coverage | ||||||
|  |  | ||||||
|       - name: Run ganttDb tests using California timezone |  | ||||||
|         env: |  | ||||||
|           # Makes sure that gantt db works even in a timezone that has daylight savings |  | ||||||
|           # since some days have 25 hours instead of 24. |  | ||||||
|           TZ: America/Los_Angeles |  | ||||||
|         run: | |  | ||||||
|           pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts |  | ||||||
|  |  | ||||||
|       - name: Upload Coverage to Coveralls |       - name: Upload Coverage to Coveralls | ||||||
|         # it feels a bit weird to use @master, but that's what the docs use |         # it feels a bit weird to use @master, but that's what the docs use | ||||||
|         # (coveralls also doesn't publish a @v1 we can use) |         # (coveralls also doesn't publish a @v1 we can use) | ||||||
|   | |||||||
| @@ -1,11 +1,5 @@ | |||||||
| export default { | export default { | ||||||
|   '!(docs/**/*)*.{ts,js,json,html,md,mts}': [ |   '!(docs/**/*)*.{ts,js,json,html,md,mts}': ['eslint --fix', 'prettier --write'], | ||||||
|     'eslint --cache --cache-strategy content --fix', |  | ||||||
|     // don't cache prettier yet, since we use `prettier-plugin-jsdoc`, |  | ||||||
|     // and prettier doesn't invalidate cache on plugin updates" |  | ||||||
|     // https://prettier.io/docs/en/cli.html#--cache |  | ||||||
|     'prettier --write', |  | ||||||
|   ], |  | ||||||
|   'cSpell.json': ['ts-node-esm scripts/fixCSpell.ts'], |   'cSpell.json': ['ts-node-esm scripts/fixCSpell.ts'], | ||||||
|   '**/*.jison': ['pnpm -w run lint:jison'], |   '**/*.jison': ['pnpm -w run lint:jison'], | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -9,11 +9,8 @@ https://mkdocs.org/ | |||||||
| https://osawards.com/javascript/#nominees | https://osawards.com/javascript/#nominees | ||||||
| https://osawards.com/javascript/2019 | https://osawards.com/javascript/2019 | ||||||
|  |  | ||||||
| # Timeout error, maybe Twitter has anti-bot defenses against GitHub's CI servers? | # Timeout error, maybe Twitter has anti-bot defences against GitHub's CI servers? | ||||||
| https://twitter.com/mermaidjs_ | https://twitter.com/mermaidjs_ | ||||||
|  |  | ||||||
| # Don't check files that are generated during the build via `pnpm docs:code` | # Don't check files that are generated during the build via `pnpm docs:code` | ||||||
| packages/mermaid/src/docs/config/setup/* | packages/mermaid/src/docs/config/setup/* | ||||||
|  |  | ||||||
| # Network error: 502, since few days |  | ||||||
| https://bundlephobia.com/ |  | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								.percy.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.percy.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | version: 2 | ||||||
|  | snapshot: | ||||||
|  |   widths: | ||||||
|  |     - 1280 | ||||||
|  | discovery: | ||||||
|  |   disable-cache: true | ||||||
							
								
								
									
										15
									
								
								.tern-project
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								.tern-project
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | { | ||||||
|  |   "ecmaVersion": 6, | ||||||
|  |   "libs": ["browser"], | ||||||
|  |   "loadEagerly": [], | ||||||
|  |   "dontLoad": ["node_modules/**"], | ||||||
|  |   "plugins": { | ||||||
|  |     "modules": {}, | ||||||
|  |     "es_modules": {}, | ||||||
|  |     "node": {}, | ||||||
|  |     "doc_comment": { | ||||||
|  |       "fullDocs": true, | ||||||
|  |       "strong": true | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
| @@ -20,14 +20,13 @@ const visualizerOptions = (packageName: string, core = false): PluginOption[] => | |||||||
|   if (packageName !== 'mermaid' || !visualize) { |   if (packageName !== 'mermaid' || !visualize) { | ||||||
|     return []; |     return []; | ||||||
|   } |   } | ||||||
|   return ['network', 'treemap', 'sunburst'].map( |   return ['network', 'treemap', 'sunburst'].map((chartType) => | ||||||
|     (chartType) => |     visualizer({ | ||||||
|       visualizer({ |       filename: `./stats/${chartType}${core ? '.core' : ''}.html`, | ||||||
|         filename: `./stats/${chartType}${core ? '.core' : ''}.html`, |       template: chartType as TemplateType, | ||||||
|         template: chartType as TemplateType, |       gzipSize: true, | ||||||
|         gzipSize: true, |       brotliSize: true, | ||||||
|         brotliSize: true, |     }) | ||||||
|       }) as PluginOption |  | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -37,11 +36,21 @@ const packageOptions = { | |||||||
|     packageName: 'mermaid', |     packageName: 'mermaid', | ||||||
|     file: 'mermaid.ts', |     file: 'mermaid.ts', | ||||||
|   }, |   }, | ||||||
|   'mermaid-example-diagram': { |   'mermaid-mindmap': { | ||||||
|     name: 'mermaid-example-diagram', |     name: 'mermaid-mindmap', | ||||||
|     packageName: 'mermaid-example-diagram', |     packageName: 'mermaid-mindmap', | ||||||
|     file: 'detector.ts', |     file: 'detector.ts', | ||||||
|   }, |   }, | ||||||
|  |   'mermaid-flowchart-v3': { | ||||||
|  |     name: 'mermaid-flowchart-v3', | ||||||
|  |     packageName: 'mermaid-flowchart-v3', | ||||||
|  |     file: 'detector.ts', | ||||||
|  |   }, | ||||||
|  |   // 'mermaid-example-diagram-detector': { | ||||||
|  |   //   name: 'mermaid-example-diagram-detector', | ||||||
|  |   //   packageName: 'mermaid-example-diagram', | ||||||
|  |   //   file: 'detector.ts', | ||||||
|  |   // }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| interface BuildOptions { | interface BuildOptions { | ||||||
| @@ -62,6 +71,12 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) | |||||||
|       sourcemap: true, |       sourcemap: true, | ||||||
|       entryFileNames: `${name}.esm${minify ? '.min' : ''}.mjs`, |       entryFileNames: `${name}.esm${minify ? '.min' : ''}.mjs`, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       name, | ||||||
|  |       format: 'umd', | ||||||
|  |       sourcemap: true, | ||||||
|  |       entryFileNames: `${name}${minify ? '.min' : ''}.js`, | ||||||
|  |     }, | ||||||
|   ]; |   ]; | ||||||
|  |  | ||||||
|   if (core) { |   if (core) { | ||||||
| @@ -109,7 +124,12 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) | |||||||
|  |  | ||||||
|   if (watch && config.build) { |   if (watch && config.build) { | ||||||
|     config.build.watch = { |     config.build.watch = { | ||||||
|       include: ['packages/mermaid-example-diagram/src/**', 'packages/mermaid/src/**'], |       include: [ | ||||||
|  |         'packages/mermaid-flowchart-v3/src/**', | ||||||
|  |         'packages/mermaid-mindmap/src/**', | ||||||
|  |         'packages/mermaid/src/**', | ||||||
|  |         // 'packages/mermaid-example-diagram/src/**', | ||||||
|  |       ], | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -117,9 +137,11 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) | |||||||
| }; | }; | ||||||
|  |  | ||||||
| const buildPackage = async (entryName: keyof typeof packageOptions) => { | const buildPackage = async (entryName: keyof typeof packageOptions) => { | ||||||
|   await build(getBuildConfig({ minify: false, entryName })); |   return Promise.allSettled([ | ||||||
|   await build(getBuildConfig({ minify: 'esbuild', entryName })); |     build(getBuildConfig({ minify: false, entryName })), | ||||||
|   await build(getBuildConfig({ minify: false, core: true, entryName })); |     build(getBuildConfig({ minify: 'esbuild', entryName })), | ||||||
|  |     build(getBuildConfig({ minify: false, core: true, entryName })), | ||||||
|  |   ]); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const main = async () => { | const main = async () => { | ||||||
| @@ -132,7 +154,9 @@ const main = async () => { | |||||||
| if (watch) { | if (watch) { | ||||||
|   build(getBuildConfig({ minify: false, watch, core: false, entryName: 'mermaid' })); |   build(getBuildConfig({ minify: false, watch, core: false, entryName: 'mermaid' })); | ||||||
|   if (!mermaidOnly) { |   if (!mermaidOnly) { | ||||||
|     build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' })); |     build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-flowchart-v3' })); | ||||||
|  |     build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' })); | ||||||
|  |     // build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' })); | ||||||
|   } |   } | ||||||
| } else if (visualize) { | } else if (visualize) { | ||||||
|   await build(getBuildConfig({ minify: false, core: true, entryName: 'mermaid' })); |   await build(getBuildConfig({ minify: false, core: true, entryName: 'mermaid' })); | ||||||
|   | |||||||
| @@ -1,6 +1,14 @@ | |||||||
| import express from 'express'; | import express, { NextFunction, Request, Response } from 'express'; | ||||||
| import cors from 'cors'; |  | ||||||
| import { createServer as createViteServer } from 'vite'; | import { createServer as createViteServer } from 'vite'; | ||||||
|  | // import { getBuildConfig } from './build'; | ||||||
|  |  | ||||||
|  | const cors = (req: Request, res: Response, next: NextFunction) => { | ||||||
|  |   res.header('Access-Control-Allow-Origin', '*'); | ||||||
|  |   res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); | ||||||
|  |   res.header('Access-Control-Allow-Headers', 'Content-Type'); | ||||||
|  |  | ||||||
|  |   next(); | ||||||
|  | }; | ||||||
|  |  | ||||||
| async function createServer() { | async function createServer() { | ||||||
|   const app = express(); |   const app = express(); | ||||||
| @@ -8,14 +16,14 @@ async function createServer() { | |||||||
|   // Create Vite server in middleware mode |   // Create Vite server in middleware mode | ||||||
|   const vite = await createViteServer({ |   const vite = await createViteServer({ | ||||||
|     configFile: './vite.config.ts', |     configFile: './vite.config.ts', | ||||||
|     mode: 'production', |  | ||||||
|     server: { middlewareMode: true }, |     server: { middlewareMode: true }, | ||||||
|     appType: 'custom', // don't include Vite's default HTML handling middlewares |     appType: 'custom', // don't include Vite's default HTML handling middlewares | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   app.use(cors()); |   app.use(cors); | ||||||
|   app.use(express.static('./packages/mermaid/dist')); |   app.use(express.static('./packages/mermaid/dist')); | ||||||
|   app.use(express.static('./packages/mermaid-example-diagram/dist')); |   app.use(express.static('./packages/mermaid-example-diagram/dist')); | ||||||
|  |   app.use(express.static('./packages/mermaid-mindmap/dist')); | ||||||
|   app.use(vite.middlewares); |   app.use(vite.middlewares); | ||||||
|   app.use(express.static('demos')); |   app.use(express.static('demos')); | ||||||
|   app.use(express.static('cypress/platform')); |   app.use(express.static('cypress/platform')); | ||||||
| @@ -25,4 +33,5 @@ async function createServer() { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // build(getBuildConfig({ minify: false, watch: true })); | ||||||
| createServer(); | createServer(); | ||||||
|   | |||||||
							
								
								
									
										103
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										103
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,105 +1,6 @@ | |||||||
| # Changelog | # Change Log | ||||||
|  |  | ||||||
| ## [10.0.0](https://github.com/mermaid-js/mermaid/releases/tag/v10.0.0) | // TODO: Populate changelog | ||||||
|  |  | ||||||
| ### Mermaid is ESM only! |  | ||||||
|  |  | ||||||
| We've dropped CJS support. So, you will have to update your import scripts as follows. |  | ||||||
|  |  | ||||||
| ```html |  | ||||||
| <script type="module"> |  | ||||||
|   import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs'; |  | ||||||
|   mermaid.initialize({ startOnLoad: true }); |  | ||||||
| </script> |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| You can keep using v9 by adding the `@9` in the CDN URL. |  | ||||||
|  |  | ||||||
| ```diff |  | ||||||
| - <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.js"></script> |  | ||||||
| + <script src="https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.js"></script> |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ### mermaid.render is async and doesn't accept callbacks |  | ||||||
|  |  | ||||||
| ```js |  | ||||||
| // < v10 |  | ||||||
| mermaid.render('id', 'graph TD;\nA-->B', (svg, bindFunctions) => { |  | ||||||
|   element.innerHTML = svg; |  | ||||||
|   if (bindFunctions) { |  | ||||||
|     bindFunctions(element); |  | ||||||
|   } |  | ||||||
| }); |  | ||||||
|  |  | ||||||
| // Shorter syntax |  | ||||||
| if (bindFunctions) { |  | ||||||
|   bindFunctions(element); |  | ||||||
| } |  | ||||||
| // can be replaced with the `?.` shorthand |  | ||||||
| bindFunctions?.(element); |  | ||||||
|  |  | ||||||
| // >= v10 with async/await |  | ||||||
| const { svg, bindFunctions } = await mermaid.render('id', 'graph TD;\nA-->B'); |  | ||||||
| element.innerHTML = svg; |  | ||||||
| bindFunctions?.(element); |  | ||||||
|  |  | ||||||
| // >= v10 with promise.then |  | ||||||
| mermaid.render('id', 'graph TD;A-->B').then(({ svg, bindFunctions }) => { |  | ||||||
|   element.innerHTML = svg; |  | ||||||
|   bindFunctions?.(element); |  | ||||||
| }); |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ### mermaid.parse is async and ParseError is removed |  | ||||||
|  |  | ||||||
| ```js |  | ||||||
| // < v10 |  | ||||||
| mermaid.parse(text, parseError); |  | ||||||
|  |  | ||||||
| //>= v10 |  | ||||||
| await mermaid.parse(text).catch(parseError); |  | ||||||
| // or |  | ||||||
| try { |  | ||||||
|   await mermaid.parse(text); |  | ||||||
| } catch (err) { |  | ||||||
|   parseError(err); |  | ||||||
| } |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ### Init deprecated and InitThrowsErrors removed |  | ||||||
|  |  | ||||||
| The config passed to `init` was not being used eariler. |  | ||||||
| It will now be used. |  | ||||||
| The `init` function is deprecated and will be removed in the next major release. |  | ||||||
| init currently works as a wrapper to `initialize` and `run`. |  | ||||||
|  |  | ||||||
| ```js |  | ||||||
| // < v10 |  | ||||||
| mermaid.init(config, selector, cb); |  | ||||||
|  |  | ||||||
| //>= v10 |  | ||||||
| mermaid.initialize(config); |  | ||||||
| mermaid.run({ |  | ||||||
|   querySelector: selector, |  | ||||||
|   postRenderCallback: cb, |  | ||||||
|   suppressErrors: true, |  | ||||||
| }); |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ```js |  | ||||||
| // < v10 |  | ||||||
| mermaid.initThrowsErrors(config, selector, cb); |  | ||||||
|  |  | ||||||
| //>= v10 |  | ||||||
| mermaid.initialize(config); |  | ||||||
| mermaid.run({ |  | ||||||
|   querySelector: selector, |  | ||||||
|   postRenderCallback: cb, |  | ||||||
|   suppressErrors: false, |  | ||||||
| }); |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| // TODO: Populate changelog pre v10 |  | ||||||
|  |  | ||||||
| - Config has a lot of changes | - Config has a lot of changes | ||||||
| - globalReset resets to `defaultConfig` instead of current config. Use `reset` instead. | - globalReset resets to `defaultConfig` instead of current config. Use `reset` instead. | ||||||
|   | |||||||
| @@ -63,28 +63,6 @@ flowchart LR | |||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| 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. |  | ||||||
|  |  | ||||||
| ```` |  | ||||||
| ```note |  | ||||||
| Note content |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ```tip |  | ||||||
| Tip content |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ```warning |  | ||||||
| Warning content |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ```danger |  | ||||||
| Danger content |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ```` |  | ||||||
|  |  | ||||||
| **_DO NOT CHANGE FILES IN `/docs`_** | **_DO NOT CHANGE FILES IN `/docs`_** | ||||||
|  |  | ||||||
| ### The official documentation site | ### The official documentation site | ||||||
|   | |||||||
							
								
								
									
										41
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,37 +1,8 @@ | |||||||
| <p align="center"> | # mermaid | ||||||
| <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/develop/docs/public/favicon.svg" height="150"> |  | ||||||
| </p> |  | ||||||
| <h1 align="center"> |  | ||||||
| Mermaid |  | ||||||
| </h1> |  | ||||||
| <p align="center"> |  | ||||||
| Generate diagrams from markdown-like text. |  | ||||||
| <p> |  | ||||||
| <p align="center"> |  | ||||||
|   <a href="https://www.npmjs.com/package/mermaid"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a> |  | ||||||
| <p> |  | ||||||
|  |  | ||||||
| <p align="center"> | [](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://bundlephobia.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [](https://twitter.com/mermaidjs_) | ||||||
| <a href="https://mermaid.live/"><b>Live Editor!</b></a> |  | ||||||
| </p> |  | ||||||
| <p align="center"> |  | ||||||
|  <a href="https://mermaid.js.org">📖 Documentation</a> | <a href="https://mermaid.js.org/intro/">🚀 Getting Started</a> | <a href="https://www.jsdelivr.com/package/npm/mermaid">🌐 CDN</a> | <a href="https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE" title="Slack invite">🙌 Join Us</a> |  | ||||||
| </p> |  | ||||||
| <p align="center"> |  | ||||||
| <a href="./README.zh-CN.md">简体中文</a> |  | ||||||
| </p> |  | ||||||
|  |  | ||||||
| <br> | English | [简体中文](./README.zh-CN.md) | ||||||
| <br> |  | ||||||
|  |  | ||||||
| [](https://www.npmjs.com/package/mermaid) |  | ||||||
| [](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) |  | ||||||
| [](https://bundlephobia.com/package/mermaid) |  | ||||||
| [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) |  | ||||||
| [](https://www.jsdelivr.com/package/npm/mermaid) |  | ||||||
| [](https://www.npmjs.com/package/mermaid) |  | ||||||
| [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) |  | ||||||
| [](https://twitter.com/mermaidjs_) |  | ||||||
|  |  | ||||||
| <img src="./img/header.png" alt="" /> | <img src="./img/header.png" alt="" /> | ||||||
|  |  | ||||||
| @@ -56,12 +27,14 @@ Mermaid addresses this problem by enabling users to create easily modifiable dia | |||||||
|  |  | ||||||
| Mermaid allows even non-programmers to easily create detailed diagrams through the [Mermaid Live Editor](https://mermaid.live/).<br/> | Mermaid allows even non-programmers to easily create detailed diagrams through the [Mermaid Live Editor](https://mermaid.live/).<br/> | ||||||
| [Tutorials](./docs/config/Tutorials.md) has video tutorials. | [Tutorials](./docs/config/Tutorials.md) has video tutorials. | ||||||
| Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](./docs/ecosystem/integrations.md). | Use Mermaid with your favorite applications, check out the list of [Integrations and Usages of Mermaid](./docs/misc/integrations.md). | ||||||
|  |  | ||||||
| You can also use Mermaid within [GitHub](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) as well many of your other favorite applications—check out the list of [Integrations and Usages of Mermaid](./docs/ecosystem/integrations.md). | You can also use Mermaid within [GitHub](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) as well many of your other favorite applications—check out the list of [Integrations and Usages of Mermaid](./docs/misc/integrations.md). | ||||||
|  |  | ||||||
| For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/community/n00b-overview.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). | For a more detailed introduction to Mermaid and some of its more basic uses, look to the [Beginner's Guide](./docs/community/n00b-overview.md), [Usage](./docs/config/usage.md) and [Tutorials](./docs/config/Tutorials.md). | ||||||
|  |  | ||||||
|  | 🌐 [CDN](https://unpkg.com/mermaid/) | 📖 [Documentation](https://mermaidjs.github.io) | 🙌 [Contribution](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) | 📜 [Changelog](./docs/CHANGELOG.md) | ||||||
|  |  | ||||||
| In our release process we rely heavily on visual regression tests using [applitools](https://applitools.com/). Applitools is a great service which has been easy to use and integrate with our tests. | In our release process we rely heavily on visual regression tests using [applitools](https://applitools.com/). Applitools is a great service which has been easy to use and integrate with our tests. | ||||||
|  |  | ||||||
| <a href="https://applitools.com/"> | <a href="https://applitools.com/"> | ||||||
|   | |||||||
| @@ -1,37 +1,8 @@ | |||||||
| <p align="center"> | # mermaid | ||||||
| <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/develop/docs/public/favicon.svg" height="150"> |  | ||||||
| </p> |  | ||||||
| <h1 align="center"> |  | ||||||
| Mermaid |  | ||||||
| </h1> |  | ||||||
| <p align="center"> |  | ||||||
| 通过解析类 Markdown 的文本语法来实现图表的创建和动态修改。 |  | ||||||
| <p> |  | ||||||
| <p align="center"> |  | ||||||
|   <a href="https://www.npmjs.com/package/mermaid"><img src="https://img.shields.io/npm/v/mermaid?color=ff3670&label="></a> |  | ||||||
| <p> |  | ||||||
|  |  | ||||||
| <p align="center"> | [](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://bundlephobia.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [](https://twitter.com/mermaidjs_) | ||||||
| <a href="https://mermaid.live/"><b>Live Editor!</b></a> |  | ||||||
| </p> |  | ||||||
| <p align="center"> |  | ||||||
|  <a href="https://mermaid.js.org">📖 文档</a> | <a href="https://mermaid.js.org/intro/">🚀 入门</a> | <a href="https://www.jsdelivr.com/package/npm/mermaid">🌐 CDN</a> | <a href="https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE" title="Slack invite">🙌 加入我们</a> |  | ||||||
| </p> |  | ||||||
| <p align="center"> |  | ||||||
| <a href="./README.md">English</a> |  | ||||||
| </p> |  | ||||||
|  |  | ||||||
| <br> | [English](./README.md) | 简体中文 | ||||||
| <br> |  | ||||||
|  |  | ||||||
| [](https://www.npmjs.com/package/mermaid) |  | ||||||
| [](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) |  | ||||||
| [](https://bundlephobia.com/package/mermaid) |  | ||||||
| [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) |  | ||||||
| [](https://www.jsdelivr.com/package/npm/mermaid) |  | ||||||
| [](https://www.npmjs.com/package/mermaid) |  | ||||||
| [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) |  | ||||||
| [](https://twitter.com/mermaidjs_) |  | ||||||
|  |  | ||||||
| <img src="./img/header.png" alt="" /> | <img src="./img/header.png" alt="" /> | ||||||
|  |  | ||||||
| @@ -53,10 +24,12 @@ Mermaid 是一个基于 Javascript 的图表绘制工具,通过解析类 Markd | |||||||
| Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它也可以作为生产脚本(或其他代码)的一部分。<br/> | Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它也可以作为生产脚本(或其他代码)的一部分。<br/> | ||||||
| <br/> | <br/> | ||||||
| Mermaid 甚至能让非程序员也能通过 [Mermaid Live Editor](https://mermaid.live/) 轻松创建详细的图表。<br/> | Mermaid 甚至能让非程序员也能通过 [Mermaid Live Editor](https://mermaid.live/) 轻松创建详细的图表。<br/> | ||||||
| 你可以访问 [教程](./docs/config/Tutorials.md) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](./docs/ecosystem/integrations.md) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 | 你可以访问 [教程](./docs/config/Tutorials.md) 来查看 Live Editor 的视频教程,也可以查看 [Mermaid 的集成和使用](./docs/misc/integrations.md) 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。 | ||||||
|  |  | ||||||
| 如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/community/n00b-overview.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). | 如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 [入门指引](./docs/community/n00b-overview.md), [用法](./docs/config/usage.md) 和 [教程](./docs/config/Tutorials.md). | ||||||
|  |  | ||||||
|  | 🌐 [CDN](https://unpkg.com/mermaid/) | 📖 [文档](https://mermaidjs.github.io) | 🙌 [贡献](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md) | 📜 [更新日志](./docs/CHANGELOG.md) | ||||||
|  |  | ||||||
| <!-- </Main description> --> | <!-- </Main description> --> | ||||||
|  |  | ||||||
| ## 示例 | ## 示例 | ||||||
| @@ -352,7 +325,7 @@ _很不幸的是,鱼与熊掌不可兼得,在这个场景下它意味着在 | |||||||
|  |  | ||||||
| 来自 Knut Sveidqvist: | 来自 Knut Sveidqvist: | ||||||
|  |  | ||||||
| > _特别感谢 [d3](https://d3js.org/) 和 [dagre-d3](https://github.com/cpettitt/dagre-d3) 这两个优秀的项目,它们提供了图形布局和绘图工具库!_ > _同样感谢 [js-sequence-diagram](https://bramp.github.io/js-sequence-diagrams) 提供了时序图语法的使用。 感谢 Jessica Peter 提供了甘特图渲染的灵感。_ > _感谢 [Tyler Long](https://github.com/tylerlong) 从 2017 年四月开始成为了项目的合作者。_ | > _特别感谢 [d3](https://d3js.org/) 和 [dagre-d3](https://github.com/cpettitt/dagre-d3) 这两个优秀的项目,它们提供了图形布局和绘图工具库! _ >_同样感谢 [js-sequence-diagram](https://bramp.github.io/js-sequence-diagrams) 提供了时序图语法的使用。 感谢 Jessica Peter 提供了甘特图渲染的灵感。_ >_感谢 [Tyler Long](https://github.com/tylerlong) 从 2017 年四月开始成为了项目的合作者。_ | ||||||
| > | > | ||||||
| > _感谢越来越多的 [贡献者们](https://github.com/knsv/mermaid/graphs/contributors),没有你们,就没有这个项目的今天!_ | > _感谢越来越多的 [贡献者们](https://github.com/knsv/mermaid/graphs/contributors),没有你们,就没有这个项目的今天!_ | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								V10-BreakingChanges.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								V10-BreakingChanges.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | # A collection of updates that change the behaviour | ||||||
|  |  | ||||||
|  | ## Lazy loading and asynchronisity | ||||||
|  |  | ||||||
|  | - Invalid dates are rendered as syntax error instead of returning best guess or the current date | ||||||
| @@ -6,7 +6,6 @@ | |||||||
|     "adamiecki", |     "adamiecki", | ||||||
|     "alois", |     "alois", | ||||||
|     "antiscript", |     "antiscript", | ||||||
|     "appli", |  | ||||||
|     "applitools", |     "applitools", | ||||||
|     "asciidoctor", |     "asciidoctor", | ||||||
|     "ashish", |     "ashish", | ||||||
| @@ -14,12 +13,10 @@ | |||||||
|     "bbox", |     "bbox", | ||||||
|     "bilkent", |     "bilkent", | ||||||
|     "bisheng", |     "bisheng", | ||||||
|     "blrs", |  | ||||||
|     "braintree", |     "braintree", | ||||||
|     "brkt", |     "brkt", | ||||||
|     "brolin", |     "brolin", | ||||||
|     "brotli", |     "brotli", | ||||||
|     "città", |  | ||||||
|     "classdef", |     "classdef", | ||||||
|     "codedoc", |     "codedoc", | ||||||
|     "colour", |     "colour", | ||||||
| @@ -28,7 +25,6 @@ | |||||||
|     "cuzon", |     "cuzon", | ||||||
|     "cytoscape", |     "cytoscape", | ||||||
|     "dagre", |     "dagre", | ||||||
|     "deepdwn", |  | ||||||
|     "descr", |     "descr", | ||||||
|     "docsify", |     "docsify", | ||||||
|     "docsy", |     "docsy", | ||||||
| @@ -58,10 +54,8 @@ | |||||||
|     "knut", |     "knut", | ||||||
|     "laganeckas", |     "laganeckas", | ||||||
|     "lintstagedrc", |     "lintstagedrc", | ||||||
|     "logmsg", |  | ||||||
|     "lucida", |     "lucida", | ||||||
|     "matthieu", |     "matthieu", | ||||||
|     "mdast", |  | ||||||
|     "mdbook", |     "mdbook", | ||||||
|     "mermerd", |     "mermerd", | ||||||
|     "mindaugas", |     "mindaugas", | ||||||
| @@ -87,7 +81,6 @@ | |||||||
|     "setupgraphviewbox", |     "setupgraphviewbox", | ||||||
|     "shiki", |     "shiki", | ||||||
|     "sidharth", |     "sidharth", | ||||||
|     "sidharthv", |  | ||||||
|     "sphinxcontrib", |     "sphinxcontrib", | ||||||
|     "statediagram", |     "statediagram", | ||||||
|     "stylis", |     "stylis", | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ const utf8ToB64 = (str) => { | |||||||
|   return window.btoa(unescape(encodeURIComponent(str))); |   return window.btoa(unescape(encodeURIComponent(str))); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const batchId = 'mermaid-batch' + new Date().getTime(); | const batchId = 'mermid-batch' + new Date().getTime(); | ||||||
|  |  | ||||||
| export const mermaidUrl = (graphStr, options, api) => { | export const mermaidUrl = (graphStr, options, api) => { | ||||||
|   const obj = { |   const obj = { | ||||||
| @@ -22,7 +22,7 @@ export const mermaidUrl = (graphStr, options, api) => { | |||||||
|   return url; |   return url; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| export const imgSnapshotTest = (graphStr, _options = {}, api = false, validation = undefined) => { | export const imgSnapshotTest = (graphStr, _options, api = false, validation) => { | ||||||
|   cy.log(_options); |   cy.log(_options); | ||||||
|   const options = Object.assign(_options); |   const options = Object.assign(_options); | ||||||
|   if (!options.fontFamily) { |   if (!options.fontFamily) { | ||||||
| @@ -46,22 +46,8 @@ export const imgSnapshotTest = (graphStr, _options = {}, api = false, validation | |||||||
|   if (!options.fontSize) { |   if (!options.fontSize) { | ||||||
|     options.fontSize = '16px'; |     options.fontSize = '16px'; | ||||||
|   } |   } | ||||||
|   const url = mermaidUrl(graphStr, options, api); |  | ||||||
|   openURLAndVerifyRendering(url, options, validation); |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| export const urlSnapshotTest = (url, _options, api = false, validation) => { |  | ||||||
|   const options = Object.assign(_options); |  | ||||||
|   openURLAndVerifyRendering(url, options, validation); |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| export const renderGraph = (graphStr, options, api) => { |  | ||||||
|   const url = mermaidUrl(graphStr, options, api); |  | ||||||
|   openURLAndVerifyRendering(url, options); |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| const openURLAndVerifyRendering = (url, options, validation = undefined) => { |  | ||||||
|   const useAppli = Cypress.env('useAppli'); |   const useAppli = Cypress.env('useAppli'); | ||||||
|  |   cy.log('Hello ' + useAppli ? 'Appli' : 'image-snapshot'); | ||||||
|   const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-'); |   const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-'); | ||||||
|  |  | ||||||
|   if (useAppli) { |   if (useAppli) { | ||||||
| @@ -74,20 +60,82 @@ const openURLAndVerifyRendering = (url, options, validation = undefined) => { | |||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   cy.visit(url); |   const url = mermaidUrl(graphStr, options, api); | ||||||
|   cy.window().should('have.property', 'rendered', true); |  | ||||||
|   cy.get('svg').should('be.visible'); |  | ||||||
|  |  | ||||||
|  |   cy.visit(url); | ||||||
|   if (validation) { |   if (validation) { | ||||||
|     cy.get('svg').should(validation); |     cy.get('svg').should(validation); | ||||||
|   } |   } | ||||||
|  |   cy.get('svg'); | ||||||
|  |   // Default name to test title | ||||||
|  |  | ||||||
|   if (useAppli) { |   if (useAppli) { | ||||||
|     cy.log('Check eyes' + Cypress.spec.name); |     cy.log('Check eyes' + Cypress.spec.name); | ||||||
|     cy.eyesCheckWindow('Click!'); |     cy.eyesCheckWindow('Click!'); | ||||||
|     cy.log('Closing eyes' + Cypress.spec.name); |     cy.log('Closing eyes: ' + Cypress.spec.name); | ||||||
|     cy.eyesClose(); |     cy.eyesClose(); | ||||||
|   } else { |   } else { | ||||||
|     cy.matchImageSnapshot(name); |     cy.matchImageSnapshot(name); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | export const urlSnapshotTest = (url, _options, api = false, validation) => { | ||||||
|  |   cy.log(_options); | ||||||
|  |   const options = Object.assign(_options); | ||||||
|  |   if (!options.fontFamily) { | ||||||
|  |     options.fontFamily = 'courier'; | ||||||
|  |   } | ||||||
|  |   if (!options.sequence) { | ||||||
|  |     options.sequence = {}; | ||||||
|  |   } | ||||||
|  |   if (!options.sequence || (options.sequence && !options.sequence.actorFontFamily)) { | ||||||
|  |     options.sequence.actorFontFamily = 'courier'; | ||||||
|  |   } | ||||||
|  |   if (options.sequence && !options.sequence.noteFontFamily) { | ||||||
|  |     options.sequence.noteFontFamily = 'courier'; | ||||||
|  |   } | ||||||
|  |   options.sequence.actorFontFamily = 'courier'; | ||||||
|  |   options.sequence.noteFontFamily = 'courier'; | ||||||
|  |   options.sequence.messageFontFamily = 'courier'; | ||||||
|  |   if (options.sequence && !options.sequence.actorFontFamily) { | ||||||
|  |     options.sequence.actorFontFamily = 'courier'; | ||||||
|  |   } | ||||||
|  |   if (!options.fontSize) { | ||||||
|  |     options.fontSize = '16px'; | ||||||
|  |   } | ||||||
|  |   const useAppli = Cypress.env('useAppli'); | ||||||
|  |   cy.log('Hello ' + useAppli ? 'Appli' : 'image-snapshot'); | ||||||
|  |   const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-'); | ||||||
|  |  | ||||||
|  |   if (useAppli) { | ||||||
|  |     cy.log('Opening eyes 2' + Cypress.spec.name); | ||||||
|  |     cy.eyesOpen({ | ||||||
|  |       appName: 'Mermaid', | ||||||
|  |       testName: name, | ||||||
|  |       batchName: Cypress.spec.name, | ||||||
|  |       batchId: batchId + Cypress.spec.name, | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   cy.visit(url); | ||||||
|  |   if (validation) { | ||||||
|  |     cy.get('svg').should(validation); | ||||||
|  |   } | ||||||
|  |   cy.get('body'); | ||||||
|  |   // Default name to test title | ||||||
|  |  | ||||||
|  |   if (useAppli) { | ||||||
|  |     cy.log('Check eyes 2' + Cypress.spec.name); | ||||||
|  |     cy.eyesCheckWindow('Click!'); | ||||||
|  |     cy.log('Closing eyes 2' + Cypress.spec.name); | ||||||
|  |     cy.eyesClose(); | ||||||
|  |   } else { | ||||||
|  |     cy.matchImageSnapshot(name); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | export const renderGraph = (graphStr, options, api) => { | ||||||
|  |   const url = mermaidUrl(graphStr, options, api); | ||||||
|  |  | ||||||
|  |   cy.visit(url); | ||||||
|  | }; | ||||||
|   | |||||||
| @@ -2,8 +2,8 @@ import { urlSnapshotTest } from '../../helpers/util'; | |||||||
|  |  | ||||||
| describe('mermaid', () => { | describe('mermaid', () => { | ||||||
|   describe('registerDiagram', () => { |   describe('registerDiagram', () => { | ||||||
|     it('should work on @mermaid-js/mermaid-example-diagram', () => { |     it('should work on @mermaid-js/mermaid-mindmap and mermaid-example-diagram', () => { | ||||||
|       const url = 'http://localhost:9000/external-diagrams-example-diagram.html'; |       const url = 'http://localhost:9000/external-diagrams-mindmap.html'; | ||||||
|       urlSnapshotTest(url, {}, false, false); |       urlSnapshotTest(url, {}, false, false); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ describe('Class diagram V2', () => { | |||||||
|         `, |         `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('1: should render a simple class diagram', () => { |   it('1: should render a simple class diagram', () => { | ||||||
| @@ -46,6 +47,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('2: should render a simple class diagrams with cardinality', () => { |   it('2: should render a simple class diagrams with cardinality', () => { | ||||||
| @@ -74,6 +76,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('should render a simple class diagram with different visibilities', () => { |   it('should render a simple class diagram with different visibilities', () => { | ||||||
| @@ -91,6 +94,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('should render multiple class diagrams', () => { |   it('should render multiple class diagrams', () => { | ||||||
| @@ -143,6 +147,7 @@ describe('Class diagram V2', () => { | |||||||
|       ], |       ], | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('4: should render a simple class diagram with comments', () => { |   it('4: should render a simple class diagram with comments', () => { | ||||||
| @@ -172,6 +177,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('5: should render a simple class diagram with abstract method', () => { |   it('5: should render a simple class diagram with abstract method', () => { | ||||||
| @@ -183,6 +189,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('6: should render a simple class diagram with static method', () => { |   it('6: should render a simple class diagram with static method', () => { | ||||||
| @@ -194,6 +201,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('7: should render a simple class diagram with Generic class', () => { |   it('7: should render a simple class diagram with Generic class', () => { | ||||||
| @@ -213,6 +221,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('8: should render a simple class diagram with Generic class and relations', () => { |   it('8: should render a simple class diagram with Generic class and relations', () => { | ||||||
| @@ -233,6 +242,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('9: should render a simple class diagram with clickable link', () => { |   it('9: should render a simple class diagram with clickable link', () => { | ||||||
| @@ -254,6 +264,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('10: should render a simple class diagram with clickable callback', () => { |   it('10: should render a simple class diagram with clickable callback', () => { | ||||||
| @@ -275,6 +286,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('11: should render a simple class diagram with return type on method', () => { |   it('11: should render a simple class diagram with return type on method', () => { | ||||||
| @@ -289,6 +301,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('12: should render a simple class diagram with generic types', () => { |   it('12: should render a simple class diagram with generic types', () => { | ||||||
| @@ -304,6 +317,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('13: should render a simple class diagram with css classes applied', () => { |   it('13: should render a simple class diagram with css classes applied', () => { | ||||||
| @@ -321,6 +335,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('14: should render a simple class diagram with css classes applied directly', () => { |   it('14: should render a simple class diagram with css classes applied directly', () => { | ||||||
| @@ -336,6 +351,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('15: should render a simple class diagram with css classes applied two multiple classes', () => { |   it('15: should render a simple class diagram with css classes applied two multiple classes', () => { | ||||||
| @@ -349,6 +365,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('16a: should render a simple class diagram with static field', () => { |   it('16a: should render a simple class diagram with static field', () => { | ||||||
| @@ -361,6 +378,7 @@ describe('Class diagram V2', () => { | |||||||
|             `, |             `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('16b: should handle the direction statement with TB', () => { |   it('16b: should handle the direction statement with TB', () => { | ||||||
| @@ -385,6 +403,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('18: should handle the direction statement with LR', () => { |   it('18: should handle the direction statement with LR', () => { | ||||||
| @@ -409,6 +428,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('17a: should handle the direction statement with BT', () => { |   it('17a: should handle the direction statement with BT', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -432,6 +452,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('17b: should handle the direction statement with RL', () => { |   it('17b: should handle the direction statement with RL', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -455,6 +476,7 @@ describe('Class diagram V2', () => { | |||||||
|       `, |       `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('18: should render a simple class diagram with notes', () => { |   it('18: should render a simple class diagram with notes', () => { | ||||||
| @@ -471,6 +493,7 @@ describe('Class diagram V2', () => { | |||||||
|         `, |         `, | ||||||
|       { logLevel: 1, flowchart: { htmlLabels: false } } |       { logLevel: 1, flowchart: { htmlLabels: false } } | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   it('1433: should render a simple class with a title', () => { |   it('1433: should render a simple class with a title', () => { | ||||||
| @@ -480,72 +503,8 @@ title: simple class diagram | |||||||
| --- | --- | ||||||
| classDiagram-v2 | classDiagram-v2 | ||||||
| class Class10 | class Class10 | ||||||
| ` | `, | ||||||
|     ); |       {} | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('should render a class with text label', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
|   class C1["Class 1 with text label"] |  | ||||||
|   C1 -->  C2` |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('should render two classes with text labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
|   class C1["Class 1 with text label"] |  | ||||||
|   class C2["Class 2 with chars @?"] |  | ||||||
|   C1 -->  C2` |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('should render a class with a text label, members and annotation', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
|   class C1["Class 1 with text label"] { |  | ||||||
|     <<interface>> |  | ||||||
|     +member1 |  | ||||||
|   } |  | ||||||
|   C1 -->  C2` |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('should render multiple classes with same text labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
| class C1["Class with text label"] |  | ||||||
| class C2["Class with text label"] |  | ||||||
| class C3["Class with text label"] |  | ||||||
| C1 --> C2 |  | ||||||
| C3 ..> C2 |  | ||||||
|   ` |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('should render classes with different text labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
| class C1["OneWord"] |  | ||||||
| class C2["With, Comma"] |  | ||||||
| class C3["With (Brackets)"] |  | ||||||
| class C4["With [Brackets]"] |  | ||||||
| class C5["With {Brackets}"] |  | ||||||
| class C7["With 1 number"] |  | ||||||
| class C8["With . period..."] |  | ||||||
| class C9["With - dash"] |  | ||||||
| class C10["With _ underscore"] |  | ||||||
| class C11["With ' single quote"] |  | ||||||
| class C12["With ~!@#$%^&*()_+=-/?"] |  | ||||||
| class C13["With Città foreign language"] |  | ||||||
|   ` |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('should render classLabel if class has already been defined earlier', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `classDiagram |  | ||||||
|   Animal <|-- Duck |  | ||||||
|   class Duck["Duck with text label"] |  | ||||||
| ` |  | ||||||
|     ); |     ); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -188,7 +188,7 @@ describe('Entity Relationship Diagram', () => { | |||||||
|     erDiagram |     erDiagram | ||||||
|         CLUSTER { |         CLUSTER { | ||||||
|           varchar(99) name |           varchar(99) name | ||||||
|           string(255) description |           string(255) description  | ||||||
|         } |         } | ||||||
|       `, |       `, | ||||||
|       { logLevel: 1 } |       { logLevel: 1 } | ||||||
|   | |||||||
| @@ -1,687 +0,0 @@ | |||||||
| import { imgSnapshotTest, renderGraph } from '../../helpers/util'; |  | ||||||
|  |  | ||||||
| describe.skip('Flowchart ELK', () => { |  | ||||||
|   it('1-elk: should render a simple flowchart', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|       A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|       B --> C{Let me think} |  | ||||||
|       C -->|One| D[Laptop] |  | ||||||
|       C -->|Two| E[iPhone] |  | ||||||
|       C -->|Three| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart TD |  | ||||||
|       A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|       B --> C{Let me think} |  | ||||||
|       C -->|One| D[Laptop] |  | ||||||
|       C -->|Two| E[iPhone] |  | ||||||
|       C -->|Three| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       { flowchart: { defaultRenderer: 'elk' } } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('2-elk: should render a simple flowchart with diagramPadding set to 0', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|       A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|       B --> C{Let me think} |  | ||||||
|       %% this is a comment |  | ||||||
|       C -->|One| D[Laptop] |  | ||||||
|       C -->|Two| E[iPhone] |  | ||||||
|       C -->|Three| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       { flowchart: { diagramPadding: 0 } } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('3-elk: a link with correct arrowhead to a subgraph', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|         P1 |  | ||||||
|         P1 -->P1.5 |  | ||||||
|         subgraph P1.5 |  | ||||||
|           P2 |  | ||||||
|           P2.5(( A )) |  | ||||||
|           P3 |  | ||||||
|         end |  | ||||||
|         P2 --> P4 |  | ||||||
|         P3 --> P6 |  | ||||||
|         P1.5 --> P5 |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('4-elk: Length of edges', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|       L1 --- L2 |  | ||||||
|       L2 --- C |  | ||||||
|       M1 ---> C |  | ||||||
|       R1 .-> R2 |  | ||||||
|       R2 <.-> C |  | ||||||
|       C -->|Label 1| E1 |  | ||||||
|       C <-- Label 2 ---> E2 |  | ||||||
|       C ----> E3 |  | ||||||
|       C <-...-> E4 |  | ||||||
|       C ======> E5 |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('5-elk: should render escaped without html labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|         a["<strong>Haiya</strong>"]---->b |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: false, flowchart: { htmlLabels: false } } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('6-elk: should render non-escaped with html labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|         a["<strong>Haiya</strong>"]===>b |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('7-elk: should render a flowchart when useMaxWidth is true (default)', () => { |  | ||||||
|     renderGraph( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|       A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|       B --> C{Let me think} |  | ||||||
|       C -->|One| D[Laptop] |  | ||||||
|       C -->|Two| E[iPhone] |  | ||||||
|       C -->|Three| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       { flowchart: { useMaxWidth: true } } |  | ||||||
|     ); |  | ||||||
|     cy.get('svg').should((svg) => { |  | ||||||
|       expect(svg).to.have.attr('width', '100%'); |  | ||||||
|       // expect(svg).to.have.attr('height'); |  | ||||||
|       // use within because the absolute value can be slightly different depending on the environment ±5% |  | ||||||
|       // const height = parseFloat(svg.attr('height')); |  | ||||||
|       // expect(height).to.be.within(446 * 0.95, 446 * 1.05); |  | ||||||
|       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(230 * 0.95, 230 * 1.05); |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
|   it('8-elk: should render a flowchart when useMaxWidth is false', () => { |  | ||||||
|     renderGraph( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|       A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|       B --> C{Let me think} |  | ||||||
|       C -->|One| D[Laptop] |  | ||||||
|       C -->|Two| E[iPhone] |  | ||||||
|       C -->|Three| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       { flowchart: { 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(446 * 0.95, 446 * 1.05); |  | ||||||
|       expect(width).to.be.within(230 * 0.95, 230 * 1.05); |  | ||||||
|       expect(svg).to.not.have.attr('style'); |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('V2 elk - 16: Render Stadium shape', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` flowchart-elk TD |  | ||||||
|       A([stadium shape test]) |  | ||||||
|       A -->|Get money| B([Go shopping]) |  | ||||||
|       B --> C([Let me think...<br />Do I want something for work,<br />something to spend every free second with,<br />or something to get around?]) |  | ||||||
|       C -->|One| D([Laptop]) |  | ||||||
|       C -->|Two| E([iPhone]) |  | ||||||
|       C -->|Three| F([Car<br/>wroom wroom]) |  | ||||||
|       click A "index.html#link-clicked" "link test" |  | ||||||
|       click B testClick "click test" |  | ||||||
|       classDef someclass fill:#f96; |  | ||||||
|       class A someclass; |  | ||||||
|       class C someclass; |  | ||||||
|       `, |  | ||||||
|       { flowchart: { htmlLabels: false }, fontFamily: 'courier' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('50-elk: handle nested subgraphs in reverse order', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk LR |  | ||||||
|         a -->b |  | ||||||
|         subgraph A |  | ||||||
|         B |  | ||||||
|         end |  | ||||||
|         subgraph B |  | ||||||
|         b |  | ||||||
|         end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('51-elk: handle nested subgraphs in reverse order', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk LR |  | ||||||
|         a -->b |  | ||||||
|         subgraph A |  | ||||||
|         B |  | ||||||
|         end |  | ||||||
|         subgraph B |  | ||||||
|         b |  | ||||||
|         end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('52-elk: handle nested subgraphs in several levels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TB |  | ||||||
|     b-->B |  | ||||||
|     a-->c |  | ||||||
|     subgraph O |  | ||||||
|       A |  | ||||||
|     end |  | ||||||
|     subgraph B |  | ||||||
|       c |  | ||||||
|     end |  | ||||||
|     subgraph A |  | ||||||
|         a |  | ||||||
|         b |  | ||||||
|         B |  | ||||||
|     end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('53-elk: handle nested subgraphs with edges in and out', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TB |  | ||||||
|   internet |  | ||||||
|   nat |  | ||||||
|   routeur |  | ||||||
|   lb1 |  | ||||||
|   lb2 |  | ||||||
|   compute1 |  | ||||||
|   compute2 |  | ||||||
|   subgraph project |  | ||||||
|   routeur |  | ||||||
|   nat |  | ||||||
|     subgraph subnet1 |  | ||||||
|       compute1 |  | ||||||
|       lb1 |  | ||||||
|     end |  | ||||||
|     subgraph subnet2 |  | ||||||
|       compute2 |  | ||||||
|       lb2 |  | ||||||
|     end |  | ||||||
|   end |  | ||||||
|   internet --> routeur |  | ||||||
|   routeur --> subnet1 & subnet2 |  | ||||||
|   subnet1 & subnet2 --> nat --> internet |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('54-elk: handle nested subgraphs with outgoing links', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|   subgraph  main |  | ||||||
|     subgraph subcontainer |  | ||||||
|       subcontainer-child |  | ||||||
|     end |  | ||||||
|      subcontainer-child--> subcontainer-sibling |  | ||||||
|   end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('55-elk: handle nested subgraphs with outgoing links 2', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TD |  | ||||||
|  |  | ||||||
| subgraph one[One] |  | ||||||
|     subgraph sub_one[Sub One] |  | ||||||
|         _sub_one |  | ||||||
|     end |  | ||||||
|     subgraph sub_two[Sub Two] |  | ||||||
|         _sub_two |  | ||||||
|     end |  | ||||||
|     _one |  | ||||||
| end |  | ||||||
|  |  | ||||||
| %% here, either the first or the second one |  | ||||||
| sub_one --> sub_two |  | ||||||
| _one --> b |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('56-elk: handle nested subgraphs with outgoing links 3', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TB |  | ||||||
|   subgraph container_Beta |  | ||||||
|     process_C-->Process_D |  | ||||||
|   end |  | ||||||
|   subgraph container_Alpha |  | ||||||
|     process_A-->process_B |  | ||||||
|     process_A-->|messages|process_C |  | ||||||
|     end |  | ||||||
|     process_B-->|via_AWSBatch|container_Beta |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('57-elk: handle nested subgraphs with outgoing links 4', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk LR |  | ||||||
| subgraph A |  | ||||||
| a -->b |  | ||||||
| end |  | ||||||
| subgraph B |  | ||||||
| b |  | ||||||
| end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('57-elk: handle nested subgraphs with outgoing links 2', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TB |  | ||||||
|     c1-->a2 |  | ||||||
|     subgraph one |  | ||||||
|     a1-->a2 |  | ||||||
|     end |  | ||||||
|     subgraph two |  | ||||||
|     b1-->b2 |  | ||||||
|     end |  | ||||||
|     subgraph three |  | ||||||
|     c1-->c2 |  | ||||||
|     end |  | ||||||
|     one --> two |  | ||||||
|     three --> two |  | ||||||
|     two --> c2 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('57.x: handle nested subgraphs with outgoing links 5', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%% this does not produce the desired result |  | ||||||
| flowchart-elk TB |  | ||||||
|   subgraph container_Beta |  | ||||||
|     process_C-->Process_D |  | ||||||
|   end |  | ||||||
|   subgraph container_Alpha |  | ||||||
|     process_A-->process_B |  | ||||||
|     process_B-->|via_AWSBatch|container_Beta |  | ||||||
|     process_A-->|messages|process_C |  | ||||||
|   end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('58-elk: handle styling with style expressions', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|     flowchart-elk LR |  | ||||||
|     id1(Start)-->id2(Stop) |  | ||||||
|     style id1 fill:#f9f,stroke:#333,stroke-width:4px |  | ||||||
|     style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('59-elk: handle styling of subgraphs and links', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk TD |  | ||||||
|   A[Christmas] ==> D |  | ||||||
|   A[Christmas] -->|Get money| B(Go shopping) |  | ||||||
|   A[Christmas] ==> C |  | ||||||
|   subgraph T ["Test"] |  | ||||||
|     A |  | ||||||
|     B |  | ||||||
|     C |  | ||||||
|   end |  | ||||||
|  |  | ||||||
|   classDef Test fill:#F84E68,stroke:#333,color:white; |  | ||||||
|   class A,T Test |  | ||||||
|   classDef TestSub fill:green; |  | ||||||
|   class T TestSub |  | ||||||
|   linkStyle 0,1 color:orange, stroke: orange; |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('60-elk: handle styling for all node shapes - v2', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk LR |  | ||||||
|       A[red text] -->|default style| B(blue text) |  | ||||||
|       C([red text]) -->|default style| D[[blue text]] |  | ||||||
|       E[(red text)] -->|default style| F((blue text)) |  | ||||||
|       G>red text] -->|default style| H{blue text} |  | ||||||
|       I{{red text}} -->|default style| J[/blue text/] |  | ||||||
|       K[\\ red text\\] -->|default style| L[/blue text\\] |  | ||||||
|       M[\\ red text/] -->|default style| N[blue text]; |  | ||||||
|       O(((red text))) -->|default style| P(((blue text))); |  | ||||||
|       linkStyle default color:Sienna; |  | ||||||
|       style A stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style B stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style C stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style D stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style E stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style F stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style G stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style H stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style I stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style J stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style K stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style L stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style M stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style N stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       style O stroke:#ff0000,fill:#ffcccc,color:#ff0000; |  | ||||||
|       style P stroke:#0000ff,fill:#ccccff,color:#0000ff; |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose', logLevel: 2 } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('61-elk: fontawesome icons in edge labels', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk TD |  | ||||||
|         C -->|fa:fa-car Car| F[fa:fa-car Car] |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('62-elk: should render styled subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk TB |  | ||||||
|       A |  | ||||||
|       B |  | ||||||
|       subgraph foo[Foo SubGraph] |  | ||||||
|         C |  | ||||||
|         D |  | ||||||
|       end |  | ||||||
|       subgraph bar[Bar SubGraph] |  | ||||||
|         E |  | ||||||
|         F |  | ||||||
|       end |  | ||||||
|       G |  | ||||||
|  |  | ||||||
|       A-->B |  | ||||||
|       B-->C |  | ||||||
|       C-->D |  | ||||||
|       B-->D |  | ||||||
|       D-->E |  | ||||||
|       E-->A |  | ||||||
|       E-->F |  | ||||||
|       F-->D |  | ||||||
|       F-->G |  | ||||||
|       B-->G |  | ||||||
|       G-->D |  | ||||||
|  |  | ||||||
|       style foo fill:#F99,stroke-width:2px,stroke:#F0F,color:darkred |  | ||||||
|       style bar fill:#999,stroke-width:10px,stroke:#0F0,color:blue |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('63-elk: title on subgraphs should be themable', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       %%{init:{"theme":"base", "themeVariables": {"primaryColor":"#411d4e", "titleColor":"white", "darkMode":true}}}%% |  | ||||||
|       flowchart-elk LR |  | ||||||
|       subgraph A |  | ||||||
|           a --> b |  | ||||||
|       end |  | ||||||
|       subgraph B |  | ||||||
|           i -->f |  | ||||||
|       end |  | ||||||
|       A --> B |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('65-elk: text-color from classes', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk LR |  | ||||||
|         classDef dark fill:#000,stroke:#000,stroke-width:4px,color:#fff |  | ||||||
|         Lorem --> Ipsum --> Dolor |  | ||||||
|         class Lorem,Dolor dark |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('66-elk: More nested subgraph cases (TB)', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk TB |  | ||||||
|     subgraph two |  | ||||||
|     b1 |  | ||||||
|     end |  | ||||||
|     subgraph three |  | ||||||
|     c2 |  | ||||||
|     end |  | ||||||
|  |  | ||||||
|     three --> two |  | ||||||
|     two --> c2 |  | ||||||
|  |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('67-elk: More nested subgraph cases (RL)', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk RL |  | ||||||
|     subgraph two |  | ||||||
|     b1 |  | ||||||
|     end |  | ||||||
|     subgraph three |  | ||||||
|     c2 |  | ||||||
|     end |  | ||||||
|  |  | ||||||
|     three --> two |  | ||||||
|     two --> c2 |  | ||||||
|  |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('68-elk: More nested subgraph cases (BT)', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk BT |  | ||||||
|     subgraph two |  | ||||||
|     b1 |  | ||||||
|     end |  | ||||||
|     subgraph three |  | ||||||
|     c2 |  | ||||||
|     end |  | ||||||
|  |  | ||||||
|     three --> two |  | ||||||
|     two --> c2 |  | ||||||
|  |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('69-elk: More nested subgraph cases (LR)', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk LR |  | ||||||
|     subgraph two |  | ||||||
|     b1 |  | ||||||
|     end |  | ||||||
|     subgraph three |  | ||||||
|     c2 |  | ||||||
|     end |  | ||||||
|  |  | ||||||
|     three --> two |  | ||||||
|     two --> c2 |  | ||||||
|  |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('70-elk: Handle nested subgraph cases (TB) link out and link between subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk TB |  | ||||||
|    subgraph S1 |  | ||||||
|     sub1 -->sub2 |  | ||||||
|    end |  | ||||||
|   subgraph S2 |  | ||||||
|     sub4 |  | ||||||
|    end |  | ||||||
|    S1 --> S2 |  | ||||||
|    sub1 --> sub4 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('71-elk: Handle nested subgraph cases (RL) link out and link between subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk RL |  | ||||||
|    subgraph S1 |  | ||||||
|     sub1 -->sub2 |  | ||||||
|    end |  | ||||||
|   subgraph S2 |  | ||||||
|     sub4 |  | ||||||
|    end |  | ||||||
|    S1 --> S2 |  | ||||||
|    sub1 --> sub4 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('72-elk: Handle nested subgraph cases (BT) link out and link between subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk BT |  | ||||||
|    subgraph S1 |  | ||||||
|     sub1 -->sub2 |  | ||||||
|    end |  | ||||||
|   subgraph S2 |  | ||||||
|     sub4 |  | ||||||
|    end |  | ||||||
|    S1 --> S2 |  | ||||||
|    sub1 --> sub4 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('74-elk: Handle nested subgraph cases (RL) link out and link between subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk RL |  | ||||||
|    subgraph S1 |  | ||||||
|     sub1 -->sub2 |  | ||||||
|    end |  | ||||||
|   subgraph S2 |  | ||||||
|     sub4 |  | ||||||
|    end |  | ||||||
|    S1 --> S2 |  | ||||||
|    sub1 --> sub4 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('74-elk: Handle labels for multiple edges from and to the same couple of nodes', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
| flowchart-elk RL |  | ||||||
|     subgraph one |  | ||||||
|       a1 -- l1 --> a2 |  | ||||||
|       a1 -- l2 --> a2 |  | ||||||
|     end |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('76-elk: handle unicode encoded character with HTML labels true', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `flowchart-elk TB |  | ||||||
|       a{{"Lorem 'ipsum' dolor 'sit' amet, 'consectetur' adipiscing 'elit'."}} |  | ||||||
|       --> b{{"Lorem #quot;ipsum#quot; dolor #quot;sit#quot; amet,#quot;consectetur#quot; adipiscing #quot;elit#quot;."}} |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('2050-elk: handling of different rendering direction in subgraphs', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|     flowchart-elk LR |  | ||||||
|  |  | ||||||
|       subgraph TOP |  | ||||||
|         direction TB |  | ||||||
|         subgraph B1 |  | ||||||
|             direction RL |  | ||||||
|             i1 -->f1 |  | ||||||
|         end |  | ||||||
|         subgraph B2 |  | ||||||
|             direction BT |  | ||||||
|             i2 -->f2 |  | ||||||
|         end |  | ||||||
|       end |  | ||||||
|       A --> TOP --> B |  | ||||||
|       B1 --> B2 |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('2388-elk: handling default in the node name', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk LR |  | ||||||
|       default-index.js --> dot.template.js |  | ||||||
|       index.js --> module-utl.js |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('2824-elk: Clipping of edges', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` |  | ||||||
|       flowchart-elk TD |  | ||||||
|           A --> B |  | ||||||
|           A --> C |  | ||||||
|           B --> C |  | ||||||
|       `, |  | ||||||
|       { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('1433-elk: should render a titled flowchart with titleTopMargin set to 0', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `--- |  | ||||||
| title: Simple flowchart |  | ||||||
| --- |  | ||||||
| flowchart-elk TD |  | ||||||
| A --> B |  | ||||||
| `, |  | ||||||
|       { titleTopMargin: 0 } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
| }); |  | ||||||
| @@ -670,17 +670,6 @@ title: Simple flowchart | |||||||
| --- | --- | ||||||
| flowchart TD | flowchart TD | ||||||
| A --> B | A --> B | ||||||
| `, |  | ||||||
|       { titleTopMargin: 0 } |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('3192: It should be possieble to render flowcharts with invisible edges', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `--- |  | ||||||
| title: Simple flowchart with invisible edges |  | ||||||
| --- |  | ||||||
| flowchart TD |  | ||||||
| A ~~~ B |  | ||||||
| `, | `, | ||||||
|       { titleTopMargin: 0 } |       { titleTopMargin: 0 } | ||||||
|     ); |     ); | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { imgSnapshotTest } from '../../helpers/util.js'; | import { imgSnapshotTest, renderGraph } from '../../helpers/util.js'; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Check whether the SVG Element has a Mindmap root |  * Check whether the SVG Element has a Mindmap root | ||||||
| @@ -158,6 +158,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('rounded rect shape', () => { |   it('rounded rect shape', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -171,6 +172,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('circle shape', () => { |   it('circle shape', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -184,6 +186,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('default shape', () => { |   it('default shape', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -195,6 +198,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('adding children', () => { |   it('adding children', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -208,6 +212,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   it('adding grand children', () => { |   it('adding grand children', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
| @@ -222,6 +227,7 @@ mindmap | |||||||
|       undefined, |       undefined, | ||||||
|       shouldHaveRoot |       shouldHaveRoot | ||||||
|     ); |     ); | ||||||
|  |     cy.get('svg'); | ||||||
|   }); |   }); | ||||||
|   /* The end */ |   /* The end */ | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -3,42 +3,6 @@ | |||||||
| import { imgSnapshotTest, renderGraph } from '../../helpers/util'; | import { imgSnapshotTest, renderGraph } from '../../helpers/util'; | ||||||
|  |  | ||||||
| context('Sequence diagram', () => { | context('Sequence diagram', () => { | ||||||
|   it('should render a sequence diagram with boxes', () => { |  | ||||||
|     renderGraph( |  | ||||||
|       ` |  | ||||||
|     sequenceDiagram |  | ||||||
|       box LightGrey Alice and Bob |  | ||||||
|       participant Alice |  | ||||||
|       participant Bob |  | ||||||
|       end |  | ||||||
|       participant John as John<br/>Second Line |  | ||||||
|       Alice ->> Bob: Hello Bob, how are you? |  | ||||||
|       Bob-->>John: How about you John? |  | ||||||
|       Bob--x Alice: I am good thanks! |  | ||||||
|       Bob-x John: I am good thanks! |  | ||||||
|       Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row. |  | ||||||
|       Bob-->Alice: Checking with John... |  | ||||||
|       alt either this |  | ||||||
|         Alice->>John: Yes |  | ||||||
|         else or this |  | ||||||
|         Alice->>John: No |  | ||||||
|         else or this will happen |  | ||||||
|         Alice->John: Maybe |  | ||||||
|       end |  | ||||||
|       par this happens in parallel |  | ||||||
|       Alice -->> Bob: Parallel message 1 |  | ||||||
|       and |  | ||||||
|       Alice -->> John: Parallel message 2 |  | ||||||
|       end |  | ||||||
|     `, |  | ||||||
|       { sequence: { useMaxWidth: false } } |  | ||||||
|     ); |  | ||||||
|     cy.get('svg').should((svg) => { |  | ||||||
|       const width = parseFloat(svg.attr('width')); |  | ||||||
|       expect(width).to.be.within(830 * 0.95, 830 * 1.05); |  | ||||||
|       expect(svg).to.not.have.attr('style'); |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
|   it('should render a simple sequence diagram', () => { |   it('should render a simple sequence diagram', () => { | ||||||
|     imgSnapshotTest( |     imgSnapshotTest( | ||||||
|       ` |       ` | ||||||
| @@ -116,11 +80,7 @@ context('Sequence diagram', () => { | |||||||
|         loop Loopy |         loop Loopy | ||||||
|             Bob->>Alice: Pasten |             Bob->>Alice: Pasten | ||||||
|         end      `, |         end      `, | ||||||
|       { |       { wrap: true } | ||||||
|         sequence: { |  | ||||||
|           wrap: true, |  | ||||||
|         }, |  | ||||||
|       } |  | ||||||
|     ); |     ); | ||||||
|   }); |   }); | ||||||
|   context('font settings', () => { |   context('font settings', () => { | ||||||
|   | |||||||
| @@ -1,164 +0,0 @@ | |||||||
| import { imgSnapshotTest } from '../../helpers/util.js'; |  | ||||||
|  |  | ||||||
| describe('Timeline diagram', () => { |  | ||||||
|   it('1: should render a simple timeline with no specific sections', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `timeline |  | ||||||
|     title History of Social Media Platform |  | ||||||
|     2002 : LinkedIn |  | ||||||
|     2004 : Facebook : Google |  | ||||||
|     2005 : Youtube |  | ||||||
|     2006 : Twitter |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('2: should render a timeline diagram with sections', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `timeline |  | ||||||
|     title Timeline of Industrial Revolution |  | ||||||
|     section 17th-20th century |  | ||||||
|         Industry 1.0 : Machinery, Water power, Steam <br>power |  | ||||||
|         Industry 2.0 : Electricity, Internal combustion engine, Mass production |  | ||||||
|         Industry 3.0 : Electronics, Computers, Automation |  | ||||||
|     section 21st century |  | ||||||
|         Industry 4.0 : Internet, Robotics, Internet of Things |  | ||||||
|         Industry 5.0 : Artificial intelligence, Big data,3D printing |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('3: should render a complex timeline with sections, and long events text with <br>', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `timeline |  | ||||||
|         title England's History Timeline |  | ||||||
|         section Stone Age |  | ||||||
|           7600 BC : Britain's oldest known house was built in Orkney, Scotland |  | ||||||
|           6000 BC : Sea levels rise and Britain becomes an island.<br> The people who live here are hunter-gatherers. |  | ||||||
|         section Broze Age |  | ||||||
|           2300 BC : People arrive from Europe and settle in Britain. <br>They bring farming and metalworking. |  | ||||||
|                   : New styles of pottery and ways of burying the dead appear. |  | ||||||
|           2200 BC : The last major building works are completed at Stonehenge.<br> People now bury their dead in stone circles. |  | ||||||
|                   : The first metal objects are made in Britain.Some other nice things happen. it is a good time to be alive. |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('4: should render a simple timeline with directives and disableMultiColor:true ', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'base', 'timeline': {'disableMulticolor': true}}}%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('5: should render a simple timeline with directive overriden colors', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       ` %%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': { |  | ||||||
|               'cScale0': '#ff0000', |  | ||||||
|               'cScale1': '#00ff00', |  | ||||||
|               'cScale2': '#0000ff' |  | ||||||
|        } } }%% |  | ||||||
|        timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|   it('6: should render a simple timeline in base theme', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'base' } }%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('7: should render a simple timeline in default theme', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'default' } }%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('8: should render a simple timeline in dark theme', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'dark' } }%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('9: should render a simple timeline in neutral theme', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'neutral' } }%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   it('10: should render a simple timeline in forest theme', () => { |  | ||||||
|     imgSnapshotTest( |  | ||||||
|       `%%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%% |  | ||||||
|     timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|       `, |  | ||||||
|       {} |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
| }); |  | ||||||
| @@ -1,231 +0,0 @@ | |||||||
| <html> |  | ||||||
|   <head> |  | ||||||
|     <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" /> |  | ||||||
|     <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" /> |  | ||||||
|     <link |  | ||||||
|       rel="stylesheet" |  | ||||||
|       href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" |  | ||||||
|     /> |  | ||||||
|     <link |  | ||||||
|       href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" |  | ||||||
|       rel="stylesheet" |  | ||||||
|     /> |  | ||||||
|     <link |  | ||||||
|       href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" |  | ||||||
|       rel="stylesheet" |  | ||||||
|     /> |  | ||||||
|     <style> |  | ||||||
|       body { |  | ||||||
|         /* background: rgb(221, 208, 208); */ |  | ||||||
|         /* background:#333; */ |  | ||||||
|         font-family: 'Arial'; |  | ||||||
|         /* font-size: 18px !important; */ |  | ||||||
|       } |  | ||||||
|       h1 { |  | ||||||
|         color: grey; |  | ||||||
|       } |  | ||||||
|       .mermaid2 { |  | ||||||
|         display: none; |  | ||||||
|       } |  | ||||||
|       .mermaid svg { |  | ||||||
|         /* font-size: 18px !important; */ |  | ||||||
|         background-color: #eee; |  | ||||||
|         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-repeat: repeat; |  | ||||||
|       } |  | ||||||
|       .malware { |  | ||||||
|         position: fixed; |  | ||||||
|         bottom: 0; |  | ||||||
|         left: 0; |  | ||||||
|         right: 0; |  | ||||||
|         height: 150px; |  | ||||||
|         background: red; |  | ||||||
|         color: black; |  | ||||||
|         display: flex; |  | ||||||
|         display: flex; |  | ||||||
|         justify-content: center; |  | ||||||
|         align-items: center; |  | ||||||
|         font-family: monospace; |  | ||||||
|         font-size: 72px; |  | ||||||
|       } |  | ||||||
|     </style> |  | ||||||
|   </head> |  | ||||||
|   <body> |  | ||||||
|     <div>Security check</div> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|  timeline |  | ||||||
|         title My day |  | ||||||
|         section section with no tasks |  | ||||||
|         section Go to work at the dog office |  | ||||||
|           1930 : first step : second step is a long step |  | ||||||
|                : third step |  | ||||||
|           1940 : fourth step : fifth step |  | ||||||
|         section Go home |  | ||||||
|           1950 : India got independent and already won war against Pakistan |  | ||||||
|           1960 : India fights poverty, looses war to China and gets nuclear weapons from USA and USSR |  | ||||||
|           1970 : Green Revolution comes to india |  | ||||||
|         section Another section with no tasks |  | ||||||
|           I am a big big big tasks |  | ||||||
|           I am not so big tasks |  | ||||||
|     </pre> |  | ||||||
|     <pre id="diagram" class="mermaid"> |  | ||||||
|  timeline |  | ||||||
|         title MermaidChart 2023 Timeline |  | ||||||
|         section 2023 Q1 <br> Release Personal Tier |  | ||||||
|           Buttet 1 : sub-point 1a : sub-point 1b |  | ||||||
|                : sub-point 1c |  | ||||||
|           Bullet 2 : sub-point 2a : sub-point 2b |  | ||||||
|         section 2023 Q2 <br> Release XYZ Tier |  | ||||||
|           Buttet 3 : sub-point <br> 3a : sub-point 3b |  | ||||||
|                : sub-point 3c |  | ||||||
|           Bullet 4 : sub-point 4a : sub-point 4b |  | ||||||
|  |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <pre id="diagram" class="mermaid"> |  | ||||||
|  timeline |  | ||||||
|         title England's History Timeline |  | ||||||
|         section Stone Age |  | ||||||
|           7600 BC : Britain's oldest known house was built in Orkney, Scotland |  | ||||||
|           6000 BC : Sea levels rise and Britain becomes an island. The people who live here are hunter-gatherers. |  | ||||||
|         section Broze Age |  | ||||||
|           2300 BC : People arrive from Europe and settle in Britain. They bring farming and metalworking. |  | ||||||
|                : New styles of pottery and ways of burying the dead appear. |  | ||||||
|           2200 BC : The last major building works are completed at Stonehenge. People now bury their dead in stone circles. |  | ||||||
|                   : The first metal objects are made in Britain.Some other nice things happen. it is a good time to be alive. |  | ||||||
|  |  | ||||||
|     </pre> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|       %%{'init': { 'logLevel': 'debug', 'theme': 'default', 'timeline': {'disableMulticolor':false} } }%% |  | ||||||
|  timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google : Pixar |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008s : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|     </pre> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|       %%{init: { 'logLevel': 'debug', 'theme': 'base', 'themeVariables': { |  | ||||||
|               'cScale0': '#ff0000', |  | ||||||
|               'cScale1': '#00ff00', |  | ||||||
|               'cScale2': '#ff0000' |  | ||||||
|               } } }%% |  | ||||||
|  timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google : Pixar |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008s : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|           %%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': { |  | ||||||
|               'cScale0': '#ff0000', |  | ||||||
|               'cScale1': '#00ff00', |  | ||||||
|               'cScale2': '#0000ff' |  | ||||||
|        } } }%% |  | ||||||
|        timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008 : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|  |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|  timeline |  | ||||||
|         title History of Social Media Platform |  | ||||||
|           2002 : LinkedIn |  | ||||||
|           2004 : Facebook : Google |  | ||||||
|           2005 : Youtube |  | ||||||
|           2006 : Twitter |  | ||||||
|           2007 : Tumblr |  | ||||||
|           2008s : Instagram |  | ||||||
|           2010 : Pinterest |  | ||||||
|     </pre> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
| mindmap |  | ||||||
|   root |  | ||||||
|     child1((Circle)) |  | ||||||
|         grandchild 1 |  | ||||||
|         grandchild 2 |  | ||||||
|     child2(Round rectangle) |  | ||||||
|         grandchild 3 |  | ||||||
|         grandchild 4 |  | ||||||
|     child3[Square] |  | ||||||
|         grandchild 5 |  | ||||||
|         ::icon(mdi mdi-fire) |  | ||||||
|         gc6((grand<br/>child 6)) |  | ||||||
|         ::icon(mdi mdi-fire) |  | ||||||
|           gc7((grand<br/>grand<br/>child 8)) |  | ||||||
|         </pre> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|       flowchart-elk TB |  | ||||||
|       a --> b |  | ||||||
|       a --> c |  | ||||||
|       b --> d |  | ||||||
|       c --> d |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <!-- <div id="cy"></div> --> |  | ||||||
|     <!-- <script src="http://localhost:9000/packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> --> |  | ||||||
|     <!-- <script src="./mermaid-example-diagram-detector.js"></script>    --> |  | ||||||
|     <!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> --> |  | ||||||
|     <script type="module"> |  | ||||||
|       //import mindmap from '../../packages/mermaid-mindmap/src/detector'; |  | ||||||
|       // import example from '../../packages/mermaid-example-diagram/src/detector'; |  | ||||||
|       // import timeline from '../../packages/mermaid-timeline/src/detector'; |  | ||||||
|       import mermaid from '../../packages/mermaid/src/mermaid'; |  | ||||||
|       // await mermaid.registerExternalDiagrams([]); |  | ||||||
|       mermaid.parseError = function (err, hash) { |  | ||||||
|         // console.error('Mermaid error: ', err); |  | ||||||
|       }; |  | ||||||
|       mermaid.initialize({ |  | ||||||
|         theme: 'base', |  | ||||||
|         startOnLoad: true, |  | ||||||
|         logLevel: 0, |  | ||||||
|         flowchart: { |  | ||||||
|           useMaxWidth: false, |  | ||||||
|           htmlLabels: true, |  | ||||||
|         }, |  | ||||||
|         gantt: { |  | ||||||
|           useMaxWidth: false, |  | ||||||
|         }, |  | ||||||
|         timeline: { |  | ||||||
|           disableMulticolor: false, |  | ||||||
|           htmlLabels: false, |  | ||||||
|         }, |  | ||||||
|         useMaxWidth: true, |  | ||||||
|         lazyLoadedDiagrams: [ |  | ||||||
|           // './mermaid-mindmap-detector.esm.mjs', |  | ||||||
|           // './mermaid-example-diagram-detector.esm.mjs', |  | ||||||
|           //'./mermaid-timeline-detector.esm.mjs', |  | ||||||
|         ], |  | ||||||
|       }); |  | ||||||
|       function callback() { |  | ||||||
|         alert('It worked'); |  | ||||||
|       } |  | ||||||
|       mermaid.parseError = function (err, hash) { |  | ||||||
|         console.error('In parse error:'); |  | ||||||
|         console.error(err); |  | ||||||
|       }; |  | ||||||
|       // mermaid.test1('first_slow', 1200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('second_fast', 200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('third_fast', 200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('forth_slow', 1200).then((r) => console.info(r)); |  | ||||||
|     </script> |  | ||||||
|   </body> |  | ||||||
| </html> |  | ||||||
| @@ -49,9 +49,13 @@ mermaid.initialize({ | |||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
| void (async () => { | mermaid.render( | ||||||
|   const { svg } = await mermaid.render('the-id-of-the-svg', code); |   'the-id-of-the-svg', | ||||||
|   console.log(svg); |   code, | ||||||
|   const elem = document.querySelector('#graph-to-be'); |   (svg) => { | ||||||
|   elem.innerHTML = svg; |     console.log(svg); | ||||||
| })(); |     const elem = document.querySelector('#graph-to-be'); | ||||||
|  |     elem.innerHTML = svg; | ||||||
|  |   } | ||||||
|  |   // ,document.querySelector('#tmp') | ||||||
|  | ); | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ | |||||||
|     <style> |     <style> | ||||||
|       body { |       body { | ||||||
|         background: rgb(221, 208, 208); |         background: rgb(221, 208, 208); | ||||||
|  |         /*background:#333;*/ | ||||||
|         font-family: 'Arial'; |         font-family: 'Arial'; | ||||||
|       } |       } | ||||||
|       h1 { |       h1 { | ||||||
| @@ -45,9 +46,13 @@ | |||||||
|     <pre class="mermaid" style="width: 100%; height: 20%"> |     <pre class="mermaid" style="width: 100%; height: 20%"> | ||||||
|       %%{init: {'theme': 'base',  'fontFamily': 'courier', 'themeVariables': {  'primaryColor': '#fff000'}}}%% |       %%{init: {'theme': 'base',  'fontFamily': 'courier', 'themeVariables': {  'primaryColor': '#fff000'}}}%% | ||||||
|       classDiagram-v2 |       classDiagram-v2 | ||||||
| classA <|-- classB : implements |        class BankAccount{ | ||||||
| classC *-- classD : composition |         +String owner | ||||||
| classE o-- classF : aggregation |         +BigDecimal balance | ||||||
|  |         +deposit(amount) bool | ||||||
|  |         +withdrawl(amount) int | ||||||
|  |        } | ||||||
|  |        cssClass "BankAccount" customCss | ||||||
|     </pre> |     </pre> | ||||||
|     <pre class="mermaid2" style="width: 100%; height: 20%"> |     <pre class="mermaid2" style="width: 100%; height: 20%"> | ||||||
|         %%{init: {'theme': 'base',  'fontFamily': 'courier', 'themeVariables': {  'primaryColor': '#fff000'}}}%% |         %%{init: {'theme': 'base',  'fontFamily': 'courier', 'themeVariables': {  'primaryColor': '#fff000'}}}%% | ||||||
| @@ -112,16 +117,24 @@ classE o-- classF : aggregation | |||||||
|         callback Shape "callbackFunction" "This is a tooltip for a callback" |         callback Shape "callbackFunction" "This is a tooltip for a callback" | ||||||
|  |  | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'default', |         theme: 'default', | ||||||
|  |         // arrowMarkerAbsolute: true, | ||||||
|  |         // themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}', | ||||||
|         logLevel: 0, |         logLevel: 0, | ||||||
|         flowchart: { curve: 'linear', htmlLabels: true }, |         flowchart: { curve: 'linear', htmlLabels: true }, | ||||||
|  |         // gantt: { axisFormat: '%m/%d/%Y' }, | ||||||
|         sequence: { actorMargin: 50, showSequenceNumbers: true }, |         sequence: { actorMargin: 50, showSequenceNumbers: true }, | ||||||
|  |         // sequenceDiagram: { actorMargin: 300 } // deprecated | ||||||
|  |         // fontFamily: '"arial", sans-serif', | ||||||
|  |         // themeVariables: { | ||||||
|  |         //   fontFamily: '"arial", sans-serif', | ||||||
|  |         // }, | ||||||
|         curve: 'linear', |         curve: 'linear', | ||||||
|         securityLevel: 'loose', |         securityLevel: 'loose', | ||||||
|       }); |       }); | ||||||
|   | |||||||
| @@ -125,6 +125,7 @@ | |||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|  |     <script src="./mermaid.js"></script> | ||||||
|     <script> |     <script> | ||||||
|       function clickByFlow(elemName) { |       function clickByFlow(elemName) { | ||||||
|         const div = document.createElement('div'); |         const div = document.createElement('div'); | ||||||
| @@ -161,9 +162,6 @@ | |||||||
|  |  | ||||||
|         document.getElementsByTagName('body')[0].appendChild(div); |         document.getElementsByTagName('body')[0].appendChild(div); | ||||||
|       } |       } | ||||||
|     </script> |  | ||||||
|     <script type="module"> |  | ||||||
|       import mermaid from './mermaid.esm.mjs'; |  | ||||||
|       mermaid.initialize({ startOnLoad: true, securityLevel: 'loose', logLevel: 1 }); |       mermaid.initialize({ startOnLoad: true, securityLevel: 'loose', logLevel: 1 }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
|   | |||||||
| @@ -59,8 +59,8 @@ | |||||||
|     Add another diagram to demo page    : 48h |     Add another diagram to demo page    : 48h | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function clickByFlow(elemName) { |       function clickByFlow(elemName) { | ||||||
|         const div = document.createElement('div'); |         const div = document.createElement('div'); | ||||||
|         div.className = 'created-by-click'; |         div.className = 'created-by-click'; | ||||||
|   | |||||||
| @@ -125,8 +125,8 @@ | |||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function clickByFlow(elemName) { |       function clickByFlow(elemName) { | ||||||
|         const div = document.createElement('div'); |         const div = document.createElement('div'); | ||||||
|         div.className = 'created-by-click'; |         div.className = 'created-by-click'; | ||||||
|   | |||||||
| @@ -61,8 +61,8 @@ | |||||||
|     Add another diagram to demo page    : 48h |     Add another diagram to demo page    : 48h | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function clickByFlow(elemName) { |       function clickByFlow(elemName) { | ||||||
|         const div = document.createElement('div'); |         const div = document.createElement('div'); | ||||||
|         div.className = 'created-by-click'; |         div.className = 'created-by-click'; | ||||||
|   | |||||||
| @@ -28,8 +28,8 @@ | |||||||
|     end |     end | ||||||
|     A --> B |     A --> B | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function showFullFirstSquad(elemName) { |       function showFullFirstSquad(elemName) { | ||||||
|         console.log('show ' + elemName); |         console.log('show ' + elemName); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -107,8 +107,8 @@ Note over Alice,Bob: Looks | |||||||
| Note over Bob,Alice: Looks back | Note over Bob,Alice: Looks back | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -1,12 +1,32 @@ | |||||||
| <html> | <html> | ||||||
|   <head> |   <head> | ||||||
|     <meta charset="utf-8" /> |     <meta charset="utf-8" /> | ||||||
|  |     <!-- <meta charset="iso-8859-15"/> --> | ||||||
|     <script src="./viewer.js" type="module"></script> |     <script src="./viewer.js" type="module"></script> | ||||||
|  |     <!-- <link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" /> --> | ||||||
|     <link |     <link | ||||||
|       href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" |       href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" | ||||||
|       rel="stylesheet" |       rel="stylesheet" | ||||||
|     /> |     /> | ||||||
|     <style> |     <style> | ||||||
|  |       body { | ||||||
|  |         /* font-family: 'Mansalva', cursive;*/ | ||||||
|  |         /* font-family: 'Mansalva', cursive; */ | ||||||
|  |         /* font-family: 'arial'; */ | ||||||
|  |         /* font-family: "trebuchet ms", verdana, arial; */ | ||||||
|  |       } | ||||||
|  |       /* div { | ||||||
|  |         font-family: 'arial'; | ||||||
|  |       } */ | ||||||
|  |       /* .mermaid-main-font { | ||||||
|  |         font-family: "trebuchet ms", verdana, arial; | ||||||
|  |         font-family: var(--mermaid-font-family); | ||||||
|  |       } */ | ||||||
|  |       /* :root { | ||||||
|  |         --mermaid-font-family: '"trebuchet ms", verdana, arial'; | ||||||
|  |         --mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive; | ||||||
|  |         --mermaid-font-family: '"Lucida Console", Monaco, monospace'; | ||||||
|  |       } */ | ||||||
|       svg { |       svg { | ||||||
|         border: 2px solid darkred; |         border: 2px solid darkred; | ||||||
|       } |       } | ||||||
| @@ -16,5 +36,21 @@ | |||||||
|       } |       } | ||||||
|     </style> |     </style> | ||||||
|   </head> |   </head> | ||||||
|   <body></body> |   <body> | ||||||
|  |     <!-- <script src="./mermaid.js"></script> --> | ||||||
|  |     <script> | ||||||
|  |       // Notice startOnLoad=false | ||||||
|  |       // This prevents default handling in mermaid from render before the e2e logic is applied | ||||||
|  |       // mermaid.initialize({ | ||||||
|  |       //   startOnLoad: false, | ||||||
|  |       //   useMaxWidth: true, | ||||||
|  |       //   // "themeCSS": ":root { --mermaid-font-family: \"trebuchet ms\", verdana, arial;}", | ||||||
|  |       //   // fontFamily: '\"trebuchet ms\", verdana, arial;' | ||||||
|  |       //   // fontFamily: '"Comic Sans MS", "Comic Sans", cursive' | ||||||
|  |       //   // fontFamily: '"Mansalva", cursive', | ||||||
|  |       //   // fontFamily: '"Noto Sans SC", sans-serif' | ||||||
|  |       //   fontFamily: '"Noto Sans SC", sans-serif' | ||||||
|  |       // }); | ||||||
|  |     </script> | ||||||
|  |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -2,8 +2,34 @@ | |||||||
|   <body> |   <body> | ||||||
|     <h1>Should correctly load a third-party diagram using registerDiagram</h1> |     <h1>Should correctly load a third-party diagram using registerDiagram</h1> | ||||||
|     <pre id="diagram" class="mermaid"> |     <pre id="diagram" class="mermaid"> | ||||||
| example-diagram | mindmap | ||||||
|  |   root | ||||||
|  |     A | ||||||
|  |     B | ||||||
|  |     C | ||||||
|  |     D | ||||||
|  |     E | ||||||
|  |     A2 | ||||||
|  |     B2 | ||||||
|  |     C2 | ||||||
|  |     D2 | ||||||
|  |     E2 | ||||||
|  |     child1((Circle)) | ||||||
|  |         grandchild 1 | ||||||
|  |         grandchild 2 | ||||||
|  |     child2(Round rectangle) | ||||||
|  |         grandchild 3 | ||||||
|  |         grandchild 4 | ||||||
|  |     child3[Square] | ||||||
|  |         grandchild 5 | ||||||
|  |         ::icon(mdi mdi-fire) | ||||||
|  |         gc6((grand<br/>child 6)) | ||||||
|  |         ::icon(mdi mdi-fire) | ||||||
|  |           gc7((grand<br/>grand<br/>child 8)) | ||||||
|     </pre> |     </pre> | ||||||
|  |     <!-- <pre id="diagram" class="mermaid2"> | ||||||
|  |       example-diagram | ||||||
|  |     </pre> --> | ||||||
| 
 | 
 | ||||||
|     <!-- <div id="cy"></div> --> |     <!-- <div id="cy"></div> --> | ||||||
|     <!-- <script src="http://localhost:9000/packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> --> |     <!-- <script src="http://localhost:9000/packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> --> | ||||||
| @@ -11,16 +37,13 @@ example-diagram | |||||||
|     <!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> --> |     <!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> --> | ||||||
|     <!-- <script type="module" src="./external-diagrams-mindmap.mjs" /> --> |     <!-- <script type="module" src="./external-diagrams-mindmap.mjs" /> --> | ||||||
|     <script type="module"> |     <script type="module"> | ||||||
|       import exampleDiagram from '../../packages/mermaid-example-diagram/src/detector'; |       import mindmap from '../../packages/mermaid-mindmap/src/detector'; | ||||||
|       // import example from '../../packages/mermaid-example-diagram/src/detector'; |       // import example from '../../packages/mermaid-example-diagram/src/detector'; | ||||||
|       import mermaid from '../../packages/mermaid/src/mermaid'; |       import mermaid from '../../packages/mermaid/src/mermaid'; | ||||||
| 
 | 
 | ||||||
|       await mermaid.registerExternalDiagrams([exampleDiagram]); |       await mermaid.registerExternalDiagrams([mindmap]); | ||||||
|       await mermaid.initialize({ logLevel: 0 }); |       await mermaid.initialize({ logLevel: 0 }); | ||||||
|       await mermaid.run(); |       await mermaid.initThrowsErrorsAsync(); | ||||||
|       if (window.Cypress) { |  | ||||||
|         window.rendered = true; |  | ||||||
|       } |  | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
| @@ -29,8 +29,8 @@ | |||||||
|         click a_a "http://www.aftonbladet.se" "apa" |         click a_a "http://www.aftonbladet.se" "apa" | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         theme: 'forest', | ||||||
|         // themeCSS: '.node rect { fill: red; }', |         // themeCSS: '.node rect { fill: red; }', | ||||||
|   | |||||||
| @@ -1,46 +0,0 @@ | |||||||
| <html> |  | ||||||
|   <head> |  | ||||||
|     <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" /> |  | ||||||
|     <style> |  | ||||||
|       body { |  | ||||||
|         font-family: 'trebuchet ms', verdana, arial; |  | ||||||
|       } |  | ||||||
|     </style> |  | ||||||
|   </head> |  | ||||||
|   <body> |  | ||||||
|     <pre class="mermaid"> |  | ||||||
|       graph TB |  | ||||||
|       subgraph One |  | ||||||
|         a1-->a2-->a3 |  | ||||||
|       end |  | ||||||
|     </pre> |  | ||||||
|     <pre class="mermaid"> |  | ||||||
|       graph TB |  | ||||||
|         a_a --> b_b:::apa --> c_c:::apa |  | ||||||
|         classDef apa fill:#f9f,stroke:#333,stroke-width:4px; |  | ||||||
|         class a_a apa; |  | ||||||
|     </pre> |  | ||||||
|     <pre class="mermaid"> |  | ||||||
|       graph TB |  | ||||||
|         a_a(Aftonbladet) --> b_b[gorilla]:::apa --> c_c{chimp}:::apa -->a_a |  | ||||||
|         a_a --> c --> d_d --> c_c |  | ||||||
|         classDef apa fill:#f9f,stroke:#333,stroke-width:4px; |  | ||||||
|         class a_a apa; |  | ||||||
|         click a_a "http://www.aftonbladet.se" "apa" |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <script type="module"> |  | ||||||
|       import mermaid from '../../packages/mermaid/src/mermaid'; |  | ||||||
|  |  | ||||||
|       mermaid.initialize({ |  | ||||||
|         theme: 'forest', |  | ||||||
|         // themeCSS: '.node rect { fill: red; }', |  | ||||||
|         logLevel: 3, |  | ||||||
|         flowchart: { curve: 'linear' }, |  | ||||||
|         gantt: { axisFormat: '%m/%d/%Y' }, |  | ||||||
|         sequence: { actorMargin: 50 }, |  | ||||||
|         // sequenceDiagram: { actorMargin: 300 } // deprecated |  | ||||||
|       }); |  | ||||||
|     </script> |  | ||||||
|   </body> |  | ||||||
| </html> |  | ||||||
| @@ -8,22 +8,19 @@ | |||||||
|     </div> |     </div> | ||||||
|     <svg id="diagram"></svg> |     <svg id="diagram"></svg> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ startOnLoad: false, logLevel: 0 }); |       mermaid.initialize({ startOnLoad: false, logLevel: 0 }); | ||||||
|  |  | ||||||
|       const graph = ` |       const graph = ` | ||||||
|       %%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%% |      %%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%% | ||||||
|              graph TD |             graph TD | ||||||
|                  A[Goose] |                 A[Goose] | ||||||
|              `; |             `; | ||||||
|  |  | ||||||
|       const diagram = document.getElementById('diagram'); |       const diagram = document.getElementById('diagram'); | ||||||
|       const { svg } = await mermaid.render('diagram-svg', graph); |       const svg = mermaid.render('diagram-svg', graph); | ||||||
|       diagram.innerHTML = svg; |       diagram.innerHTML = svg; | ||||||
|       if (window.Cypress) { |  | ||||||
|         window.rendered = true; |  | ||||||
|       } |  | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ | |||||||
|     </div> |     </div> | ||||||
|     <svg id="diagram"></svg> |     <svg id="diagram"></svg> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ startOnLoad: false, logLevel: 0 }); |       mermaid.initialize({ startOnLoad: false, logLevel: 0 }); | ||||||
|  |  | ||||||
|       const graph = ` |       const graph = ` | ||||||
| @@ -19,11 +19,8 @@ | |||||||
|             `; |             `; | ||||||
|  |  | ||||||
|       const diagram = document.getElementById('diagram'); |       const diagram = document.getElementById('diagram'); | ||||||
|       const { svg } = await mermaid.render('diagram-svg', graph); |       const svg = mermaid.render('diagram-svg', graph); | ||||||
|       diagram.innerHTML = svg; |       diagram.innerHTML = svg; | ||||||
|       if (window.Cypress) { |  | ||||||
|         window.rendered = true; |  | ||||||
|       } |  | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -91,11 +91,10 @@ | |||||||
|       diagram += 'le> * { background : red}</style>test</p>"]'; |       diagram += 'le> * { background : red}</style>test</p>"]'; | ||||||
|  |  | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       document.querySelector('#res').innerHTML = svg; |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       if (window.Cypress) { |         document.querySelector('#res').innerHTML = res; | ||||||
|         window.rendered = true; |       }); | ||||||
|       } |  | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -43,8 +43,8 @@ | |||||||
|        cssClass "BankAccount" customCss |        cssClass "BankAccount" customCss | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -130,8 +130,8 @@ | |||||||
|       commit |       commit | ||||||
|       merge main |       merge main | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -98,8 +98,8 @@ | |||||||
|       commit |       commit | ||||||
|       merge main |       merge main | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -7,8 +7,8 @@ | |||||||
|     <pre class="mermaid"> |     <pre class="mermaid"> | ||||||
| info | info | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         theme: 'forest', | ||||||
|         // themeCSS: '.node rect { fill: red; }', |         // themeCSS: '.node rect { fill: red; }', | ||||||
|   | |||||||
| @@ -87,8 +87,8 @@ | |||||||
|     Add another diagram to demo page    : 48h |     Add another diagram to demo page    : 48h | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function clickByFlow(elemName) { |       function clickByFlow(elemName) { | ||||||
|         const div = document.createElement('div'); |         const div = document.createElement('div'); | ||||||
|         div.className = 'created-by-click'; |         div.className = 'created-by-click'; | ||||||
|   | |||||||
| @@ -56,24 +56,13 @@ | |||||||
|   <body> |   <body> | ||||||
|     <pre id="diagram" class="mermaid"> |     <pre id="diagram" class="mermaid"> | ||||||
| %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% | %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% | ||||||
| graph BT | graph TB | ||||||
| a{The cat in the hat} -- 1o --> b |  | ||||||
| a -- 2o --> c |  | ||||||
| a -- 3o --> d |  | ||||||
| g --2i--> a |  | ||||||
| d --1i--> a |  | ||||||
| h --3i -->a |  | ||||||
| b --> d(The dog in the hog) |  | ||||||
| c --> d |  | ||||||
|     </pre> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
| flowchart-elk TB |  | ||||||
|       a --> b |       a --> b | ||||||
|       a --> c |       a --> c | ||||||
|       b --> d |       b --> d | ||||||
|       c --> d |       c --> d | ||||||
|     </pre> |     </pre> | ||||||
|     <pre id="diagram" class="mermaid2"> |     <pre id="diagram" class="mermaid"> | ||||||
| %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% | %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% | ||||||
| flowchart TB | flowchart TB | ||||||
|   %% I could not figure out how to use double quotes in labels in Mermaid |   %% I could not figure out how to use double quotes in labels in Mermaid | ||||||
| @@ -129,7 +118,7 @@ flowchart TB | |||||||
| </pre | </pre | ||||||
|     > |     > | ||||||
|     <br /> |     <br /> | ||||||
|     <pre id="diagram" class="mermaid2"> |     <pre id="diagram" class="mermaid"> | ||||||
| flowchart TB | flowchart TB | ||||||
|   %% I could not figure out how to use double quotes in labels in Mermaid |   %% I could not figure out how to use double quotes in labels in Mermaid | ||||||
|   subgraph ibm[IBM Espresso CPU] |   subgraph ibm[IBM Espresso CPU] | ||||||
| @@ -232,27 +221,13 @@ sequenceDiagram | |||||||
|         </pre |         </pre | ||||||
|     > |     > | ||||||
|     <pre id="diagram" class="mermaid2"> |     <pre id="diagram" class="mermaid2"> | ||||||
| mindmap |       gantt | ||||||
|   root((mindmap)) |         title Style today marker (vertical line should be 5px wide and half-transparent blue) | ||||||
|     Origins |         dateFormat YYYY-MM-DD | ||||||
|       Long history |         axisFormat %d | ||||||
|       ::icon(fa fa-book) |         todayMarker stroke-width:5px,stroke:#00f,opacity:0.5 | ||||||
|       Popularisation |         section Section1 | ||||||
|         British popular psychology author Tony Buzan |         Today: 1, -1h | ||||||
|     Research |  | ||||||
|       On effectiveness<br/>and features |  | ||||||
|       On Automatic creation |  | ||||||
|         Uses |  | ||||||
|             Creative techniques |  | ||||||
|             Strategic planning |  | ||||||
|             Argument mapping |  | ||||||
|     Tools |  | ||||||
|       Pen and paper |  | ||||||
|       Mermaid |  | ||||||
|     </pre> |  | ||||||
|     <br /> |  | ||||||
|     <pre id="diagram" class="mermaid2"> |  | ||||||
|   example-diagram |  | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <!-- <div id="cy"></div> --> |     <!-- <div id="cy"></div> --> | ||||||
| @@ -262,17 +237,18 @@ mindmap | |||||||
|     <!-- <script src="./mermaid.js"></script> --> |     <!-- <script src="./mermaid.js"></script> --> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script type="module"> | ||||||
|       // import mindmap from '../../packages/mermaid-mindmap/src/detector'; |       import mindmap from '../../packages/mermaid-mindmap/src/detector'; | ||||||
|       import example from '../../packages/mermaid-example-diagram/src/detector'; |       import flowV3 from '../../packages/mermaid-flowchart-v3/src/detector'; | ||||||
|  |       // import example from '../../packages/mermaid-example-diagram/src/detector'; | ||||||
|       import mermaid from '../../packages/mermaid/src/mermaid'; |       import mermaid from '../../packages/mermaid/src/mermaid'; | ||||||
|       await mermaid.registerExternalDiagrams([example]); |       await mermaid.registerExternalDiagrams([mindmap, flowV3]); | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         // theme: 'forest', | ||||||
|         startOnLoad: true, |         startOnLoad: true, | ||||||
|         logLevel: 5, |         logLevel: 0, | ||||||
|         flowchart: { |         flowchart: { | ||||||
|           // defaultRenderer: 'elk', |           // defaultRenderer: 'elk', | ||||||
|           useMaxWidth: false, |           useMaxWidth: false, | ||||||
|   | |||||||
| @@ -1,93 +1,81 @@ | |||||||
| <!DOCTYPE html> | <html> | ||||||
| <html lang="en"> |  | ||||||
|   <head> |   <head> | ||||||
|     <meta charset="utf-8" /> |     <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" /> | ||||||
|     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |     <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" /> | ||||||
|     <title>Mindmap Mermaid Quick Test Page</title> |     <link | ||||||
|     <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" /> |       rel="stylesheet" | ||||||
|  |       href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" | ||||||
|  |     /> | ||||||
|  |     <link | ||||||
|  |       href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" | ||||||
|  |       rel="stylesheet" | ||||||
|  |     /> | ||||||
|  |     <link | ||||||
|  |       href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap" | ||||||
|  |       rel="stylesheet" | ||||||
|  |     /> | ||||||
|     <style> |     <style> | ||||||
|       div.mermaid { |       body { | ||||||
|         /* font-family: 'trebuchet ms', verdana, arial; */ |         /* background: rgb(221, 208, 208); */ | ||||||
|         font-family: 'Courier New', Courier, monospace !important; |         /* background:#333; */ | ||||||
|  |         font-family: 'Arial'; | ||||||
|  |         /* font-size: 18px !important; */ | ||||||
|  |       } | ||||||
|  |       h1 { | ||||||
|  |         color: grey; | ||||||
|  |       } | ||||||
|  |       .mermaid2 { | ||||||
|  |         display: none; | ||||||
|  |       } | ||||||
|  |       .mermaid svg { | ||||||
|  |         /* font-size: 18px !important; */ | ||||||
|  |         background-color: #eee; | ||||||
|  |         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-repeat: repeat; | ||||||
|  |       } | ||||||
|  |       .malware { | ||||||
|  |         position: fixed; | ||||||
|  |         bottom: 0; | ||||||
|  |         left: 0; | ||||||
|  |         right: 0; | ||||||
|  |         height: 150px; | ||||||
|  |         background: red; | ||||||
|  |         color: black; | ||||||
|  |         display: flex; | ||||||
|  |         display: flex; | ||||||
|  |         justify-content: center; | ||||||
|  |         align-items: center; | ||||||
|  |         font-family: monospace; | ||||||
|  |         font-size: 72px; | ||||||
|       } |       } | ||||||
|     </style> |     </style> | ||||||
|   </head> |   </head> | ||||||
|  |  | ||||||
|   <body> |   <body> | ||||||
|     <h1>Mindmap diagram demo</h1> |     <div>Security check</div> | ||||||
|     <pre class="mermaid"> |     <pre id="diagram" class="mermaid"> | ||||||
|         mindmap |       graph TD | ||||||
|         root |         A["test"] --"<p><style> * { display : none}</style>test</p>"--> B | ||||||
|             child1((Circle)) |  | ||||||
|                 grandchild 1 |  | ||||||
|                 grandchild 2 |  | ||||||
|             child2(Round rectangle) |  | ||||||
|                 grandchild 3 |  | ||||||
|                 grandchild 4 |  | ||||||
|             child3[Square] |  | ||||||
|                 grandchild 5 |  | ||||||
|                 ::icon(mdi mdi-fire) |  | ||||||
|                 gc6((grand<br/>child 6)) |  | ||||||
|                 ::icon(mdi mdi-fire) |  | ||||||
|                 gc7((grand<br/>grand<br/>child 8)) |  | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <h2>Mindmap with root wrapping text and a shape</h2> |     <!-- <div id="cy"></div> --> | ||||||
|     <pre class="mermaid"> |     <!-- <script src="http://localhost:9000/packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> --> | ||||||
|         mindmap |     <!-- <script src="./mermaid-example-diagram-detector.js"></script>    --> | ||||||
|             root[A root with a long text that wraps to keep the node size in check] |     <!-- <script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script> --> | ||||||
|     </pre> |     <!-- <script src="./mermaid.js"></script> --> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script type="module"> | ||||||
|       // import mermaid from './mermaid.esm.mjs'; |       import mindmap from '../../packages/mermaid-mindmap/src/detector'; | ||||||
|  |       // import example from '../../packages/mermaid-example-diagram/src/detector'; | ||||||
|       import mermaid from '../../packages/mermaid/src/mermaid'; |       import mermaid from '../../packages/mermaid/src/mermaid'; | ||||||
|       // import mermaidMindmap from './mermaid-mindmap.esm.mjs'; |       await mermaid.registerExternalDiagrams([mindmap]); | ||||||
|  |  | ||||||
|       // import mermaidMindmap from 'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.3.0/+esm'; |  | ||||||
|       // await mermaid.registerExternalDiagrams([mermaidMindmap]); |  | ||||||
|  |  | ||||||
|       const ALLOWED_TAGS = [ |  | ||||||
|         'a', |  | ||||||
|         'b', |  | ||||||
|         'blockquote', |  | ||||||
|         'br', |  | ||||||
|         'dd', |  | ||||||
|         'div', |  | ||||||
|         'dl', |  | ||||||
|         'dt', |  | ||||||
|         'em', |  | ||||||
|         'foreignObject', |  | ||||||
|         'h1', |  | ||||||
|         'h2', |  | ||||||
|         'h3', |  | ||||||
|         'h4', |  | ||||||
|         'h5', |  | ||||||
|         'h6', |  | ||||||
|         'h7', |  | ||||||
|         'h8', |  | ||||||
|         'hr', |  | ||||||
|         'i', |  | ||||||
|         'li', |  | ||||||
|         'ul', |  | ||||||
|         'ol', |  | ||||||
|         'p', |  | ||||||
|         'pre', |  | ||||||
|         'span', |  | ||||||
|         'strike', |  | ||||||
|         'strong', |  | ||||||
|         'table', |  | ||||||
|         'tbody', |  | ||||||
|         'td', |  | ||||||
|         'tfoot', |  | ||||||
|         'th', |  | ||||||
|         'thead', |  | ||||||
|         'tr', |  | ||||||
|       ]; |  | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'base', |         theme: 'default', | ||||||
|         startOnLoad: true, |         startOnLoad: true, | ||||||
|         logLevel: 0, |         logLevel: 0, | ||||||
|         flowchart: { |         flowchart: { | ||||||
| @@ -106,6 +94,10 @@ | |||||||
|         console.error('In parse error:'); |         console.error('In parse error:'); | ||||||
|         console.error(err); |         console.error(err); | ||||||
|       }; |       }; | ||||||
|  |       // mermaid.test1('first_slow', 1200).then((r) => console.info(r)); | ||||||
|  |       // mermaid.test1('second_fast', 200).then((r) => console.info(r)); | ||||||
|  |       // mermaid.test1('third_fast', 200).then((r) => console.info(r)); | ||||||
|  |       // mermaid.test1('forth_slow', 1200).then((r) => console.info(r)); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -59,7 +59,7 @@ A-->B | |||||||
|     > |     > | ||||||
|     <script src="./packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> |     <script src="./packages/mermaid-mindmap/dist/mermaid-mindmap-detector.js"></script> | ||||||
|     <script src="./packages/mermaid-mindmap/dist/mermaid-example-diagram-detector.js"></script> |     <script src="./packages/mermaid-mindmap/dist/mermaid-example-diagram-detector.js"></script> | ||||||
|     <script src="./packages/mermaid/dist/mermaid.esm.mjs"></script> |     <script src="./packages/mermaid/dist/mermaid.js"></script> | ||||||
|     <script> |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|   | |||||||
| @@ -1,4 +1,14 @@ | |||||||
| <html> | <html> | ||||||
|  |   <head> | ||||||
|  |     <script src="http://localhost:9000/mermaid.js"></script> | ||||||
|  |     <script> | ||||||
|  |       mermaid.initialize({ | ||||||
|  |         theme: 'base', | ||||||
|  |         themeVariables: {}, | ||||||
|  |         startOnLoad: true, | ||||||
|  |       }); | ||||||
|  |     </script> | ||||||
|  |   </head> | ||||||
|   <body> |   <body> | ||||||
|     <h1>Example</h1> |     <h1>Example</h1> | ||||||
|     <pre class="mermaid"> |     <pre class="mermaid"> | ||||||
| @@ -16,12 +26,4 @@ sequenceDiagram | |||||||
|     Note left of Ernie: Cookies are good |     Note left of Ernie: Cookies are good | ||||||
|     </pre> |     </pre> | ||||||
|   </body> |   </body> | ||||||
|   <script type="module"> |  | ||||||
|     import mermaid from '/mermaid.esm.mjs'; |  | ||||||
|     mermaid.initialize({ |  | ||||||
|       theme: 'base', |  | ||||||
|       themeVariables: {}, |  | ||||||
|       startOnLoad: true, |  | ||||||
|     }); |  | ||||||
|   </script> |  | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -9,19 +9,19 @@ | |||||||
|   <body> |   <body> | ||||||
|     <div id="graph"></div> |     <div id="graph"></div> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       await mermaid.initialize({ startOnLoad: false }); |       mermaid.init({ startOnLoad: false }); | ||||||
|       await mermaid.run(); |  | ||||||
|  |  | ||||||
|       await mermaid.mermaidAPI.initialize({ securityLevel: 'strict' }); |       mermaid.mermaidAPI.initialize({ securityLevel: 'strict' }); | ||||||
|       try { |       try { | ||||||
|         console.log('rendering'); |         console.log('rendering'); | ||||||
|         await mermaid.mermaidAPI.render('graphDiv', `>`); |         mermaid.mermaidAPI.render('graphDiv', `>`); | ||||||
|       } catch (e) {} |       } catch (e) {} | ||||||
|  |  | ||||||
|       const { svg } = await mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`); |       mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`, (html) => { | ||||||
|       document.getElementById('graph').innerHTML = svg; |         document.getElementById('graph').innerHTML = html; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -9,20 +9,20 @@ | |||||||
|   <body> |   <body> | ||||||
|     <div id="graph"></div> |     <div id="graph"></div> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ startOnLoad: false }); |       mermaid.init({ startOnLoad: false }); | ||||||
|       mermaid.mermaidAPI.initialize(); |       mermaid.mermaidAPI.initialize(); | ||||||
|  |  | ||||||
|       async function rerender(text) { |       rerender('XMas'); | ||||||
|  |  | ||||||
|  |       function rerender(text) { | ||||||
|         const graphText = `graph TD |         const graphText = `graph TD | ||||||
|         A[${text}] -->|Get money| B(Go shopping)`; |         A[${text}] -->|Get money| B(Go shopping)`; | ||||||
|         const { svg } = await mermaid.mermaidAPI.render('id', graphText); |         const graph = mermaid.mermaidAPI.render('id', graphText); | ||||||
|         console.log('\x1b[35m%s\x1b[0m', '>> graph', svg); |         console.log('\x1b[35m%s\x1b[0m', '>> graph', graph); | ||||||
|         document.getElementById('graph').innerHTML = svg; |         document.getElementById('graph').innerHTML = graph; | ||||||
|       } |       } | ||||||
|       window.rerender = rerender; |  | ||||||
|       await rerender('XMas'); |  | ||||||
|     </script> |     </script> | ||||||
|     <button id="rerender" onclick="rerender('Saturday')">Rerender</button> |     <button id="rerender" onclick="rerender('Saturday')">Rerender</button> | ||||||
|   </body> |   </body> | ||||||
|   | |||||||
| @@ -313,8 +313,8 @@ requirementDiagram | |||||||
|       merge release |       merge release | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -308,8 +308,8 @@ gitGraph | |||||||
|     |     | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -308,8 +308,8 @@ gitGraph | |||||||
|       merge release |       merge release | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -301,8 +301,8 @@ requirementDiagram | |||||||
|       merge release |       merge release | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -305,8 +305,8 @@ requirementDiagram | |||||||
|       merge release |       merge release | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -305,8 +305,8 @@ requirementDiagram | |||||||
|       merge release |       merge release | ||||||
|       </pre> |       </pre> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -1,50 +1,14 @@ | |||||||
| <html> | <html> | ||||||
|   <body> |   <body> | ||||||
|     <pre id="diagram" class="mermaid"> |     <pre class="mermaid"> | ||||||
| graph TB |     none | ||||||
|       a --> b |     hello world | ||||||
|       a --> c |  | ||||||
|       b --> d |  | ||||||
|       c --> d |  | ||||||
|     </pre> |     </pre> | ||||||
|  |     <script src="./mermaid.js"></script> | ||||||
|     <div id="d2"></div> |     <script> | ||||||
|  |  | ||||||
|     <script type="module"> |  | ||||||
|       import mermaid from '/mermaid.esm.mjs'; |  | ||||||
|       mermaid.parseError = function (err, hash) { |  | ||||||
|         // console.error('Mermaid error: ', err); |  | ||||||
|       }; |  | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         // theme: 'forest', |         logLevel: 1, | ||||||
|         startOnLoad: true, |  | ||||||
|         logLevel: 0, |  | ||||||
|         flowchart: { |  | ||||||
|           // defaultRenderer: 'elk', |  | ||||||
|           useMaxWidth: false, |  | ||||||
|           htmlLabels: true, |  | ||||||
|         }, |  | ||||||
|         gantt: { |  | ||||||
|           useMaxWidth: false, |  | ||||||
|         }, |  | ||||||
|         useMaxWidth: false, |  | ||||||
|       }); |       }); | ||||||
|       function callback() { |  | ||||||
|         alert('It worked'); |  | ||||||
|       } |  | ||||||
|       mermaid.parseError = function (err, hash) { |  | ||||||
|         console.error('In parse error:'); |  | ||||||
|         console.error(err); |  | ||||||
|       }; |  | ||||||
|       const value = `graph TD\nHello --> World`; |  | ||||||
|       const el = document.getElementById('d2'); |  | ||||||
|       const { svg } = await mermaid.render('d22', value); |  | ||||||
|       console.log(svg); |  | ||||||
|       el.innerHTML = svg; |  | ||||||
|       // mermaid.test1('first_slow', 1200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('second_fast', 200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('third_fast', 200).then((r) => console.info(r)); |  | ||||||
|       // mermaid.test1('forth_slow', 1200).then((r) => console.info(r)); |  | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -34,8 +34,8 @@ | |||||||
|       9e122290-->82072290_1ec3_e711_8c5a_005056ad0002 |       9e122290-->82072290_1ec3_e711_8c5a_005056ad0002 | ||||||
|       style 9e122290 fill:#F99,stroke-width:2px,stroke:#F0F |       style 9e122290 fill:#F99,stroke-width:2px,stroke:#F0F | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function showFullFirstSquad(elemName) { |       function showFullFirstSquad(elemName) { | ||||||
|         console.log('show ' + elemName); |         console.log('show ' + elemName); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -120,8 +120,8 @@ | |||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
|   | |||||||
| @@ -25,8 +25,8 @@ | |||||||
|           Get into car:4: Dad, Mum, Child 1, Child 2 |           Get into car:4: Dad, Mum, Child 1, Child 2 | ||||||
|           Drive home:3: Dad |           Drive home:3: Dad | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         theme: 'forest', | ||||||
|         logLevel: 3, |         logLevel: 3, | ||||||
|   | |||||||
| @@ -26,8 +26,8 @@ | |||||||
|       A --> B --> C |       A --> B --> C | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       function showFullFirstSquad(elemName) { |       function showFullFirstSquad(elemName) { | ||||||
|         console.log('show ' + elemName); |         console.log('show ' + elemName); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -1,17 +1,10 @@ | |||||||
| import mermaid2 from '../../packages/mermaid/src/mermaid'; | import mermaid2 from '../../packages/mermaid/src/mermaid'; | ||||||
| import externalExample from '../../packages/mermaid-example-diagram/src/detector'; | import mindmap from '../../packages/mermaid-mindmap/src/detector'; | ||||||
|  |  | ||||||
| function b64ToUtf8(str) { | function b64ToUtf8(str) { | ||||||
|   return decodeURIComponent(escape(window.atob(str))); |   return decodeURIComponent(escape(window.atob(str))); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Adds a rendered flag to window when rendering is done, so cypress can wait for it. |  | ||||||
| function markRendered() { |  | ||||||
|   if (window.Cypress) { |  | ||||||
|     window.rendered = true; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * ##contentLoaded Callback function that is called when page is loaded. This functions fetches |  * ##contentLoaded Callback function that is called when page is loaded. This functions fetches | ||||||
|  * configuration for mermaid rendering and calls init for rendering the mermaid diagrams on the |  * configuration for mermaid rendering and calls init for rendering the mermaid diagrams on the | ||||||
| @@ -44,10 +37,9 @@ const contentLoaded = async function () { | |||||||
|       document.getElementsByTagName('body')[0].appendChild(div); |       document.getElementsByTagName('body')[0].appendChild(div); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     await mermaid2.registerExternalDiagrams([externalExample]); |     await mermaid2.registerExternalDiagrams([mindmap]); | ||||||
|     mermaid2.initialize(graphObj.mermaid); |     mermaid2.initialize(graphObj.mermaid); | ||||||
|     await mermaid2.run(); |     mermaid2.init(); | ||||||
|     markRendered(); |  | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -75,7 +67,7 @@ function merge(current, update) { | |||||||
|   return current; |   return current; | ||||||
| } | } | ||||||
|  |  | ||||||
| const contentLoadedApi = async function () { | const contentLoadedApi = function () { | ||||||
|   let pos = document.location.href.indexOf('?graph='); |   let pos = document.location.href.indexOf('?graph='); | ||||||
|   if (pos > 0) { |   if (pos > 0) { | ||||||
|     pos = pos + 7; |     pos = pos + 7; | ||||||
| @@ -102,28 +94,40 @@ const contentLoadedApi = async function () { | |||||||
|       mermaid2.initialize(cnf); |       mermaid2.initialize(cnf); | ||||||
|  |  | ||||||
|       for (let i = 0; i < numCodes; i++) { |       for (let i = 0; i < numCodes; i++) { | ||||||
|         const { svg, bindFunctions } = await mermaid2.render( |         mermaid2.render( | ||||||
|           'newid' + i, |           'newid' + i, | ||||||
|           graphObj.code[i], |           graphObj.code[i], | ||||||
|  |           (svgCode, bindFunctions) => { | ||||||
|  |             div.innerHTML = svgCode; | ||||||
|  |  | ||||||
|  |             bindFunctions(div); | ||||||
|  |           }, | ||||||
|           divs[i] |           divs[i] | ||||||
|         ); |         ); | ||||||
|         div.innerHTML = svg; |  | ||||||
|         bindFunctions(div); |  | ||||||
|       } |       } | ||||||
|     } else { |     } else { | ||||||
|       const div = document.createElement('div'); |       const div = document.createElement('div'); | ||||||
|       div.id = 'block'; |       div.id = 'block'; | ||||||
|       div.className = 'mermaid'; |       div.className = 'mermaid'; | ||||||
|  |       // div.innerHTML = graphObj.code | ||||||
|       console.warn('graphObj.mermaid', graphObj.mermaid); |       console.warn('graphObj.mermaid', graphObj.mermaid); | ||||||
|       document.getElementsByTagName('body')[0].appendChild(div); |       document.getElementsByTagName('body')[0].appendChild(div); | ||||||
|       mermaid2.initialize(graphObj.mermaid); |       mermaid2.initialize(graphObj.mermaid); | ||||||
|  |  | ||||||
|       const { svg, bindFunctions } = await mermaid2.render('newid', graphObj.code, div); |       mermaid2.render( | ||||||
|       div.innerHTML = svg; |         'newid', | ||||||
|       bindFunctions(div); |         graphObj.code, | ||||||
|  |         (svgCode, bindFunctions) => { | ||||||
|  |           div.innerHTML = svgCode; | ||||||
|  |  | ||||||
|  |           if (bindFunctions) { | ||||||
|  |             bindFunctions(div); | ||||||
|  |           } | ||||||
|  |         }, | ||||||
|  |         div | ||||||
|  |       ); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   markRendered(); |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| if (typeof document !== 'undefined') { | if (typeof document !== 'undefined') { | ||||||
| @@ -135,10 +139,10 @@ if (typeof document !== 'undefined') { | |||||||
|     function () { |     function () { | ||||||
|       if (this.location.href.match('xss.html')) { |       if (this.location.href.match('xss.html')) { | ||||||
|         this.console.log('Using api'); |         this.console.log('Using api'); | ||||||
|         void contentLoadedApi(); |         contentLoadedApi(); | ||||||
|       } else { |       } else { | ||||||
|         this.console.log('Not using api'); |         this.console.log('Not using api'); | ||||||
|         void contentLoaded(); |         contentLoaded(); | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     false |     false | ||||||
|   | |||||||
| @@ -33,8 +33,8 @@ | |||||||
|     </script> |     </script> | ||||||
|   </head> |   </head> | ||||||
|   <body> |   <body> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         startOnLoad: false, |         startOnLoad: false, | ||||||
|         useMaxWidth: true, |         useMaxWidth: true, | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -104,9 +104,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -102,9 +102,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -102,9 +102,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -102,9 +102,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -104,9 +104,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -103,9 +103,10 @@ | |||||||
|       //  diagram += "=xssAttack()> --> B"; |       //  diagram += "=xssAttack()> --> B"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -102,9 +102,10 @@ | |||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // console.log(diagram); |       // console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -102,9 +102,10 @@ | |||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // console.log(diagram); |       // console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -101,9 +101,10 @@ | |||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // console.log(diagram); |       // console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -103,9 +103,10 @@ class Shape{ | |||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // console.log(diagram); |       // console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -48,8 +48,8 @@ | |||||||
|       Alice->>Bob: Hi Bob |       Alice->>Bob: Hi Bob | ||||||
|       Bob->>Alice: Hi Alice |       Bob->>Alice: Hi Alice | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         startOnLoad: true, |         startOnLoad: true, | ||||||
|         useMaxWidth: true, |         useMaxWidth: true, | ||||||
| @@ -59,7 +59,7 @@ | |||||||
|       const handler = setInterval(() => { |       const handler = setInterval(() => { | ||||||
|         cnt++; |         cnt++; | ||||||
|         a = {}; |         a = {}; | ||||||
|         if (a.polluted !== undefined) { |         if (typeof a.polluted !== 'undefined') { | ||||||
|           clearInterval(handler); |           clearInterval(handler); | ||||||
|           xssAttack(); |           xssAttack(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -101,8 +101,10 @@ A --> B["<a href='javasc`; | |||||||
|       diagram += `ript#colon;xssAttack()'>AAA</a>"]`; |       diagram += `ript#colon;xssAttack()'>AAA</a>"]`; | ||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       document.querySelector('#res').innerHTML = svg; |         // console.log(res); | ||||||
|  |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -97,12 +97,14 @@ | |||||||
|       // A --> B["<a href='javascript`; |       // A --> B["<a href='javascript`; | ||||||
|       // diagram += `ript#colon;xssAttack()'>AAA</a>"]`; |       // diagram += `ript#colon;xssAttack()'>AAA</a>"]`; | ||||||
|       let diagram = `  graph TD |       let diagram = `  graph TD | ||||||
|       A --> B["<a href='javasc`; | A --> B["<a href='javasc`; | ||||||
|       diagram += `ript#9;t#colon;xssAttack()'>AAA</a>"]`; |       diagram += `ript#9;t#colon;xssAttack()'>AAA</a>"]`; | ||||||
|       // diagram += '//via.placeholder.com/64\' width=64 />"]'; |       // diagram += '//via.placeholder.com/64\' width=64 />"]'; | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       document.querySelector('#res').innerHTML = svg; |         console.log(res); | ||||||
|  |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ | |||||||
|   graph TD |   graph TD | ||||||
| A --> B["<a href='javascript#9;t#colon;alert(document.location)'>AAA</a>"] | A --> B["<a href='javascript#9;t#colon;alert(document.location)'>AAA</a>"] | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ startOnLoad: true }); |       mermaid.initialize({ startOnLoad: true }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
|   | |||||||
| @@ -36,8 +36,8 @@ | |||||||
|       graph LR |       graph LR | ||||||
|           A --> B |           A --> B | ||||||
|     </pre> |     </pre> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         startOnLoad: true, |         startOnLoad: true, | ||||||
|         useMaxWidth: true, |         useMaxWidth: true, | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -95,8 +95,9 @@ | |||||||
|  |  | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -99,9 +99,10 @@ | |||||||
|  |  | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -97,9 +97,10 @@ | |||||||
|       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; |       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -99,9 +99,10 @@ | |||||||
|       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; |       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -98,9 +98,10 @@ | |||||||
|       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; |       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ | |||||||
|       <div id="diagram" class="mermaid"></div> |       <div id="diagram" class="mermaid"></div> | ||||||
|       <div id="res" class=""></div> |       <div id="res" class=""></div> | ||||||
|     </div> |     </div> | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.parseError = function (err, hash) { |       mermaid.parseError = function (err, hash) { | ||||||
|         // console.error('Mermaid error: ', err); |         // console.error('Mermaid error: ', err); | ||||||
|       }; |       }; | ||||||
| @@ -98,9 +98,10 @@ | |||||||
|       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; |       // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; | ||||||
|       console.log(diagram); |       console.log(diagram); | ||||||
|       // document.querySelector('#diagram').innerHTML = diagram; |       // document.querySelector('#diagram').innerHTML = diagram; | ||||||
|       const { svg } = await mermaid.render('diagram', diagram); |       mermaid.render('diagram', diagram, (res) => { | ||||||
|       console.log(res); |         console.log(res); | ||||||
|       document.querySelector('#res').innerHTML = svg; |         document.querySelector('#res').innerHTML = res; | ||||||
|  |       }); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -217,8 +217,8 @@ | |||||||
|      </pre> |      </pre> | ||||||
|     <hr /> |     <hr /> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       const ALLOWED_TAGS = [ |       const ALLOWED_TAGS = [ | ||||||
|         'a', |         'a', | ||||||
|         'b', |         'b', | ||||||
| @@ -273,7 +273,8 @@ | |||||||
|         }, |         }, | ||||||
|         // sequenceDiagram: { actorMargin: 300 } // deprecated |         // sequenceDiagram: { actorMargin: 300 } // deprecated | ||||||
|       }); |       }); | ||||||
|  |     </script> | ||||||
|  |     <script> | ||||||
|       function testClick(nodeId) { |       function testClick(nodeId) { | ||||||
|         console.log('clicked', nodeId); |         console.log('clicked', nodeId); | ||||||
|         let originalBgColor = document.querySelector('body').style.backgroundColor; |         let originalBgColor = document.querySelector('body').style.backgroundColor; | ||||||
| @@ -282,18 +283,21 @@ | |||||||
|           document.querySelector('body').style.backgroundColor = originalBgColor; |           document.querySelector('body').style.backgroundColor = originalBgColor; | ||||||
|         }, 100); |         }, 100); | ||||||
|       } |       } | ||||||
|  |     </script> | ||||||
|       const testLineEndings = async (test, input) => { |     <script> | ||||||
|  |       const testLineEndings = (test, input) => { | ||||||
|         try { |         try { | ||||||
|           await mermaid.render(test, input); |           mermaid.render(test, input, () => { | ||||||
|  |             //no-op | ||||||
|  |           }); | ||||||
|         } catch (err) { |         } catch (err) { | ||||||
|           console.error('Error in %s:\n\n%s', test, err); |           console.error('Error in %s:\n\n%s', test, err); | ||||||
|         } |         } | ||||||
|       }; |       }; | ||||||
|  |  | ||||||
|       await testLineEndings('CR', 'graph LR\rsubgraph CR\rA --> B\rend'); |       testLineEndings('CR', 'graph LR\rsubgraph CR\rA --> B\rend'); | ||||||
|       await testLineEndings('LF', 'graph LR\nsubgraph LF\nA --> B\nend'); |       testLineEndings('LF', 'graph LR\nsubgraph LF\nA --> B\nend'); | ||||||
|       await testLineEndings('CRLF', 'graph LR\r\nsubgraph CRLF\r\nA --> B\r\nend'); |       testLineEndings('CRLF', 'graph LR\r\nsubgraph CRLF\r\nA --> B\r\nend'); | ||||||
|     </script> |     </script> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
| @@ -154,8 +154,8 @@ | |||||||
|     </pre> |     </pre> | ||||||
|     <hr /> |     <hr /> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'default', |         theme: 'default', | ||||||
|         // themeCSS: '.node rect { fill: red; }', |         // themeCSS: '.node rect { fill: red; }', | ||||||
|   | |||||||
| @@ -34,8 +34,8 @@ | |||||||
|       noSide[|borders:no| stroke no side ]; |       noSide[|borders:no| stroke no side ]; | ||||||
|     </pre> |     </pre> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         theme: 'forest', | ||||||
|         logLevel: 3, |         logLevel: 3, | ||||||
|   | |||||||
| @@ -71,46 +71,8 @@ | |||||||
|     </pre> |     </pre> | ||||||
|     <hr /> |     <hr /> | ||||||
|  |  | ||||||
|     <pre class="mermaid"> |     <script src="./mermaid.js"></script> | ||||||
|       erDiagram |  | ||||||
|         "HOSPITAL" { |  | ||||||
|           int id PK |  | ||||||
|           int doctor_id PK, FK |  | ||||||
|           string address UK |  | ||||||
|           string name |  | ||||||
|           string phone_number |  | ||||||
|           string fax_number |  | ||||||
|         } |  | ||||||
|       </pre |  | ||||||
|     > |  | ||||||
|     <hr /> |  | ||||||
|  |  | ||||||
|     <pre class="mermaid"> |  | ||||||
|       erDiagram |  | ||||||
|         CAR ||--o{ NAMED-DRIVER : allows |  | ||||||
|         CAR { |  | ||||||
|           string registrationNumber PK |  | ||||||
|           string make |  | ||||||
|           string model |  | ||||||
|           string[] parts |  | ||||||
|         } |  | ||||||
|         PERSON ||--o{ NAMED-DRIVER : is |  | ||||||
|         PERSON { |  | ||||||
|           string driversLicense PK "The license #" |  | ||||||
|           string(99) firstName "Only 99 characters are allowed" |  | ||||||
|           string lastName |  | ||||||
|           string phone UK |  | ||||||
|           int age |  | ||||||
|         } |  | ||||||
|         NAMED-DRIVER { |  | ||||||
|           string carRegistrationNumber PK, FK |  | ||||||
|           string driverLicence PK,FK |  | ||||||
|         } |  | ||||||
|         MANUFACTURER only one to zero or more CAR : makes |  | ||||||
|     </pre> |  | ||||||
|  |  | ||||||
|     <script type="module"> |     <script type="module"> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |  | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'default', |         theme: 'default', | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1507,8 +1507,8 @@ | |||||||
|  |  | ||||||
|     <h1 id="link-clicked">Anchor for "link-clicked" test</h1> |     <h1 id="link-clicked">Anchor for "link-clicked" test</h1> | ||||||
|  |  | ||||||
|     <script type="module"> |     <script src="./mermaid.js"></script> | ||||||
|       import mermaid from './mermaid.esm.mjs'; |     <script> | ||||||
|       mermaid.initialize({ |       mermaid.initialize({ | ||||||
|         theme: 'forest', |         theme: 'forest', | ||||||
|         logLevel: 3, |         logLevel: 3, | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user