diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 8710d49aa..44b16532c 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,4 @@ -blank_issues_enabled: false +blank_issues_enabled: true contact_links: - name: GitHub Discussions url: https://github.com/mermaid-js/mermaid/discussions diff --git a/.percy.yml b/.percy.yml deleted file mode 100644 index f56df3d5e..000000000 --- a/.percy.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -snapshot: - widths: - - 1280 -discovery: - disable-cache: true diff --git a/.tern-project b/.tern-project deleted file mode 100644 index 1209b33da..000000000 --- a/.tern-project +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ecmaVersion": 6, - "libs": ["browser"], - "loadEagerly": [], - "dontLoad": ["node_modules/**"], - "plugins": { - "modules": {}, - "es_modules": {}, - "node": {}, - "doc_comment": { - "fullDocs": true, - "strong": true - } - } -} diff --git a/.vite/build.ts b/.vite/build.ts index e3c947173..268db3270 100644 --- a/.vite/build.ts +++ b/.vite/build.ts @@ -62,12 +62,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) sourcemap: true, entryFileNames: `${name}.esm${minify ? '.min' : ''}.mjs`, }, - { - name, - format: 'umd', - sourcemap: true, - entryFileNames: `${name}${minify ? '.min' : ''}.js`, - }, ]; if (core) { diff --git a/.vite/server.ts b/.vite/server.ts index 0f1fef91d..82b75232d 100644 --- a/.vite/server.ts +++ b/.vite/server.ts @@ -1,27 +1,20 @@ -import express, { NextFunction, Request, Response } from 'express'; +import express from 'express'; +import cors from 'cors'; import { createServer as createViteServer } from 'vite'; -const cors = (req: Request, res: Response, next: NextFunction) => { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); - res.header('Access-Control-Allow-Headers', 'Content-Type'); - - next(); -}; - async function createServer() { const app = express(); // Create Vite server in middleware mode const vite = await createViteServer({ configFile: './vite.config.ts', + mode: 'production', server: { middlewareMode: true }, 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-example-diagram/dist')); app.use(express.static('./packages/mermaid-example-diagram/dist')); app.use(vite.middlewares); app.use(express.static('demos')); diff --git a/CHANGELOG.md b/CHANGELOG.md index c5903cd91..7552efa3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,105 @@ -# Change Log +# Changelog -// TODO: Populate changelog +## [10.0.0](https://github.com/mermaid-js/mermaid/releases/tag/v10.0.0) + +### Mermaid is ESM only! + +We've dropped CJS support. So, you will have to update your import scripts as follows. + +```html + +``` + +You can keep using v9 by adding the `@9` in the CDN URL. + +```diff +- ++ +``` + +### 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 - globalReset resets to `defaultConfig` instead of current config. Use `reset` instead. diff --git a/README.md b/README.md index f4cf8e105..d42e2f7e1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Mermaid Generate diagrams from markdown-like text.
diff --git a/README.zh-CN.md b/README.zh-CN.md index 65cf38645..2653ac72b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -8,7 +8,7 @@ Mermaid 通过解析类 Markdown 的文本语法来实现图表的创建和动态修改。
diff --git a/V10-BreakingChanges.md b/V10-BreakingChanges.md deleted file mode 100644 index bd9110d1a..000000000 --- a/V10-BreakingChanges.md +++ /dev/null @@ -1,5 +0,0 @@ -# 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 diff --git a/cSpell.json b/cSpell.json index 340954ba0..d860c5e33 100644 --- a/cSpell.json +++ b/cSpell.json @@ -28,6 +28,7 @@ "cuzon", "cytoscape", "dagre", + "deepdwn", "descr", "docsify", "docsy", diff --git a/cypress/integration/rendering/erDiagram.spec.js b/cypress/integration/rendering/erDiagram.spec.js index c72df49b6..df1fac0cd 100644 --- a/cypress/integration/rendering/erDiagram.spec.js +++ b/cypress/integration/rendering/erDiagram.spec.js @@ -188,7 +188,7 @@ describe('Entity Relationship Diagram', () => { erDiagram CLUSTER { varchar(99) name - string(255) description + string(255) description } `, { logLevel: 1 } diff --git a/cypress/integration/rendering/flowchart-elk.spec.js b/cypress/integration/rendering/flowchart-elk.spec.js index 0d4ec4211..414037651 100644 --- a/cypress/integration/rendering/flowchart-elk.spec.js +++ b/cypress/integration/rendering/flowchart-elk.spec.js @@ -1,6 +1,6 @@ import { imgSnapshotTest, renderGraph } from '../../helpers/util'; -describe('Flowchart ELK', () => { +describe.skip('Flowchart ELK', () => { it('1-elk: should render a simple flowchart', () => { imgSnapshotTest( `flowchart-elk TD diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index 30ae4f0d2..abdb22265 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -670,6 +670,17 @@ title: Simple flowchart --- flowchart TD 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 } ); diff --git a/cypress/integration/rendering/sequencediagram.spec.js b/cypress/integration/rendering/sequencediagram.spec.js index 1f063c13e..f8948240a 100644 --- a/cypress/integration/rendering/sequencediagram.spec.js +++ b/cypress/integration/rendering/sequencediagram.spec.js @@ -116,7 +116,11 @@ context('Sequence diagram', () => { loop Loopy Bob->>Alice: Pasten end `, - { wrap: true } + { + sequence: { + wrap: true, + }, + } ); }); context('font settings', () => { diff --git a/cypress/platform/bundle-test.js b/cypress/platform/bundle-test.js index a991918c4..edd3dfbc4 100644 --- a/cypress/platform/bundle-test.js +++ b/cypress/platform/bundle-test.js @@ -49,13 +49,9 @@ mermaid.initialize({ ], }, }); -mermaid.render( - 'the-id-of-the-svg', - code, - (svg) => { - console.log(svg); - const elem = document.querySelector('#graph-to-be'); - elem.innerHTML = svg; - } - // ,document.querySelector('#tmp') -); +void (async () => { + const { svg } = await mermaid.render('the-id-of-the-svg', code); + console.log(svg); + const elem = document.querySelector('#graph-to-be'); + elem.innerHTML = svg; +})(); diff --git a/cypress/platform/class.html b/cypress/platform/class.html index ea0914c6d..2f853bbc1 100644 --- a/cypress/platform/class.html +++ b/cypress/platform/class.html @@ -112,8 +112,8 @@ classE o-- classF : aggregation callback Shape "callbackFunction" "This is a tooltip for a callback" - - +
- - -