fix(mermaid): fix Mermaid integration for v9.2 release (#8282)

This commit is contained in:
Sébastien Lorber 2022-11-10 16:07:18 +01:00 committed by GitHub
parent 04eb04cb49
commit 1d5afbaaa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 31 deletions

View file

@ -40,7 +40,6 @@
"@docusaurus/types": "^3.0.0-alpha.0", "@docusaurus/types": "^3.0.0-alpha.0",
"@types/escape-html": "^1.0.2", "@types/escape-html": "^1.0.2",
"@types/mdast": "^3.0.10", "@types/mdast": "^3.0.10",
"@types/mermaid": "^8.2.9",
"@types/stringify-object": "^3.3.1", "@types/stringify-object": "^3.3.1",
"@types/unist": "^2.0.6", "@types/unist": "^2.0.6",
"rehype-stringify": "^8.0.0", "rehype-stringify": "^8.0.0",

View file

@ -39,12 +39,11 @@
"@docusaurus/types": "^3.0.0-alpha.0", "@docusaurus/types": "^3.0.0-alpha.0",
"@docusaurus/utils-validation": "^3.0.0-alpha.0", "@docusaurus/utils-validation": "^3.0.0-alpha.0",
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",
"mermaid": "^9.1.1", "mermaid": "^9.2.2",
"tslib": "^2.4.0" "tslib": "^2.4.0"
}, },
"devDependencies": { "devDependencies": {
"@types/mdx-js__react": "^1.5.5", "@types/mdx-js__react": "^1.5.5",
"@types/mermaid": "^8.2.9",
"react-test-renderer": "^17.0.2" "react-test-renderer": "^17.0.2"
}, },
"peerDependencies": { "peerDependencies": {

View file

@ -7,8 +7,7 @@
import {useMemo} from 'react'; import {useMemo} from 'react';
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common'; import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
import mermaid from 'mermaid'; import mermaid, {type MermaidConfig} from 'mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import type {ThemeConfig} from '@docusaurus/theme-mermaid'; import type {ThemeConfig} from '@docusaurus/theme-mermaid';
// Stable className to allow users to easily target with CSS // Stable className to allow users to easily target with CSS
@ -18,7 +17,7 @@ export function useMermaidThemeConfig(): ThemeConfig['mermaid'] {
return (useThemeConfig() as unknown as ThemeConfig).mermaid; return (useThemeConfig() as unknown as ThemeConfig).mermaid;
} }
export function useMermaidConfig(): mermaidAPI.Config { export function useMermaidConfig(): MermaidConfig {
const {colorMode} = useColorMode(); const {colorMode} = useColorMode();
const mermaidThemeConfig = useMermaidThemeConfig(); const mermaidThemeConfig = useMermaidThemeConfig();
@ -33,7 +32,7 @@ export function useMermaidConfig(): mermaidAPI.Config {
export function useMermaidSvg( export function useMermaidSvg(
txt: string, txt: string,
mermaidConfigParam?: mermaidAPI.Config, mermaidConfigParam?: MermaidConfig,
): string { ): string {
/* /*
For flexibility, we allow the hook to receive a custom Mermaid config For flexibility, we allow the hook to receive a custom Mermaid config

View file

@ -7,14 +7,13 @@
import {Joi} from '@docusaurus/utils-validation'; import {Joi} from '@docusaurus/utils-validation';
import type {ThemeConfig} from '@docusaurus/theme-mermaid'; import type {ThemeConfig} from '@docusaurus/theme-mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import type {ThemeConfigValidationContext} from '@docusaurus/types'; import type {ThemeConfigValidationContext} from '@docusaurus/types';
export const DEFAULT_THEME_CONFIG: ThemeConfig = { export const DEFAULT_THEME_CONFIG: ThemeConfig = {
mermaid: { mermaid: {
theme: { theme: {
dark: 'dark' as mermaidAPI.Theme, dark: 'dark',
light: 'default' as mermaidAPI.Theme, light: 'default',
}, },
options: {}, options: {},
}, },

View file

@ -10,6 +10,6 @@
"module": "esnext", "module": "esnext",
"target": "esnext" "target": "esnext"
}, },
"include": ["src/theme", "src/*.d.ts"], "include": ["src/client", "src/theme", "src/*.d.ts"],
"exclude": ["**/__tests__/**"] "exclude": ["**/__tests__/**"]
} }

View file

@ -10,5 +10,5 @@
"outDir": "lib" "outDir": "lib"
}, },
"include": ["src"], "include": ["src"],
"exclude": ["src/theme", "**/__tests__/**"] "exclude": ["src/client", "src/theme", "**/__tests__/**"]
} }

View file

@ -3659,11 +3659,6 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/mermaid@^8.2.9":
version "8.2.9"
resolved "https://registry.yarnpkg.com/@types/mermaid/-/mermaid-8.2.9.tgz#1844505dcffcd47703e94628a6200583d35c2c76"
integrity sha512-f1i8fNoVFVJXedk+R7GcEk4KoOWzWAU3CzFqlVw1qWKktfsataBERezCz1pOdKy8Ec02ZdPQXGM7NU2lPHABYQ==
"@types/micromatch@^4.0.2": "@types/micromatch@^4.0.2":
version "4.0.2" version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.2.tgz#ce29c8b166a73bf980a5727b1e4a4d099965151d" resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.2.tgz#ce29c8b166a73bf980a5727b1e4a4d099965151d"
@ -7918,6 +7913,11 @@ extglob@^2.0.4:
snapdragon "^0.8.1" snapdragon "^0.8.1"
to-regex "^3.0.1" to-regex "^3.0.1"
fast-clone@^1.5.13:
version "1.5.13"
resolved "https://registry.yarnpkg.com/fast-clone/-/fast-clone-1.5.13.tgz#7fe17542ae1c872e71bf80d177d00c11f51c2ea7"
integrity sha512-0ez7coyFBQFjZtId+RJqJ+EQs61w9xARfqjqK0AD9vIUkSxWD4HvPt80+5evebZ1tTnv1GYKrPTipx7kOW5ipA==
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3" version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@ -11112,20 +11112,24 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
mermaid@^9.1.1: mermaid@^9.2.2:
version "9.1.7" version "9.2.2"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.1.7.tgz#e24de9b2d36c8cb25a09d72ffce966941b24bd6e" resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.2.2.tgz#73cca1f0b74e7e674c0de3519d7e7e8ea83bea4a"
integrity sha512-MRVHXy5FLjnUQUG7YS3UN9jEN6FXCJbFCXVGJQjVIbiR6Vhw0j/6pLIjqsiah9xoHmQU6DEaKOvB3S1g/1nBPA== integrity sha512-6s7eKMqFJGS+0MYjmx8f6ZigqKBJVoSx5ql2gw6a4Aa+WJ49QiEJg7gPwywaBg3DZMs79UP7trESp4+jmaQccw==
dependencies: dependencies:
"@braintree/sanitize-url" "^6.0.0" "@braintree/sanitize-url" "^6.0.0"
d3 "^7.0.0" d3 "^7.0.0"
dagre "^0.8.5" dagre "^0.8.5"
dagre-d3 "^0.6.4" dagre-d3 "^0.6.4"
dompurify "2.4.0" dompurify "2.4.0"
fast-clone "^1.5.13"
graphlib "^2.1.8" graphlib "^2.1.8"
khroma "^2.0.0" khroma "^2.0.0"
moment-mini "2.24.0" lodash "^4.17.21"
stylis "^4.0.10" moment-mini "^2.24.0"
non-layered-tidy-tree-layout "^2.0.2"
stylis "^4.1.2"
uuid "^9.0.0"
methods@~1.1.2: methods@~1.1.2:
version "1.1.2" version "1.1.2"
@ -11402,10 +11406,10 @@ modify-values@^1.0.0:
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==
moment-mini@2.24.0: moment-mini@^2.24.0:
version "2.24.0" version "2.29.4"
resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.24.0.tgz#fa68d98f7fe93ae65bf1262f6abb5fb6983d8d18" resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.29.4.tgz#cbbcdc58ce1b267506f28ea6668dbe060a32758f"
integrity sha512-9ARkWHBs+6YJIvrIp0Ik5tyTTtP9PoV0Ssu2Ocq5y9v8+NOOpWiRshAp8c4rZVWTOe+157on/5G+zj5pwIQFEQ== integrity sha512-uhXpYwHFeiTbY9KSgPPRoo1nt8OxNVdMVoTBYHfSEKeRkIkwGpO+gERmhuhBtzfaeOyTkykSrm2+noJBgqt3Hg==
mrmime@^1.0.0: mrmime@^1.0.0:
version "1.0.1" version "1.0.1"
@ -11604,6 +11608,11 @@ node-releases@^2.0.6:
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"
integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==
non-layered-tidy-tree-layout@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/non-layered-tidy-tree-layout/-/non-layered-tidy-tree-layout-2.0.2.tgz#57d35d13c356643fc296a55fb11ac15e74da7804"
integrity sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==
nopt@^5.0.0: nopt@^5.0.0:
version "5.0.0" version "5.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88" resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
@ -14916,10 +14925,10 @@ stylelint@^14.11.0:
v8-compile-cache "^2.3.0" v8-compile-cache "^2.3.0"
write-file-atomic "^4.0.2" write-file-atomic "^4.0.2"
stylis@^4.0.10: stylis@^4.1.2:
version "4.1.2" version "4.1.3"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.2.tgz#870b3c1c2275f51b702bb3da9e94eedad87bba41" resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7"
integrity sha512-Nn2CCrG2ZaFziDxaZPN43CXqn+j7tcdjPFCkRBkFue8QYXC2HdEwnw5TCBo4yQZ2WxKYeSi0fdoOrtEqgDrXbA== integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==
supports-color@^5.3.0: supports-color@^5.3.0:
version "5.5.0" version "5.5.0"
@ -15886,6 +15895,11 @@ uuid@^8.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
v8-compile-cache@2.3.0, v8-compile-cache@^2.3.0: v8-compile-cache@2.3.0, v8-compile-cache@^2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"