Skip to content

Commit

Permalink
fix Mermaid TS integration after v9.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Nov 10, 2022
1 parent 2182961 commit ba777d8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@docusaurus/types": "^3.0.0-alpha.0",
"@types/escape-html": "^1.0.2",
"@types/mdast": "^3.0.10",
"@types/mermaid": "^8.2.9",
"@types/stringify-object": "^3.3.1",
"@types/unist": "^2.0.6",
"rehype-stringify": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-mermaid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@docusaurus/types": "^3.0.0-alpha.0",
"@docusaurus/utils-validation": "^3.0.0-alpha.0",
"@mdx-js/react": "^1.6.22",
"mermaid": "^9.2.0",
"mermaid": "^9.2.2",
"tslib": "^2.4.0"
},
"devDependencies": {
Expand Down
7 changes: 3 additions & 4 deletions packages/docusaurus-theme-mermaid/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import {useMemo} from 'react';
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
import mermaid from 'mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import mermaid, {type MermaidConfig} from 'mermaid';
import type {ThemeConfig} from '@docusaurus/theme-mermaid';

// Stable className to allow users to easily target with CSS
Expand All @@ -18,7 +17,7 @@ export function useMermaidThemeConfig(): ThemeConfig['mermaid'] {
return (useThemeConfig() as unknown as ThemeConfig).mermaid;
}

export function useMermaidConfig(): mermaidAPI.Config {
export function useMermaidConfig(): MermaidConfig {
const {colorMode} = useColorMode();
const mermaidThemeConfig = useMermaidThemeConfig();

Expand All @@ -33,7 +32,7 @@ export function useMermaidConfig(): mermaidAPI.Config {

export function useMermaidSvg(
txt: string,
mermaidConfigParam?: mermaidAPI.Config,
mermaidConfigParam?: MermaidConfig,
): string {
/*
For flexibility, we allow the hook to receive a custom Mermaid config
Expand Down
5 changes: 2 additions & 3 deletions packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

import {Joi} from '@docusaurus/utils-validation';
import type {ThemeConfig} from '@docusaurus/theme-mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import type {ThemeConfigValidationContext} from '@docusaurus/types';

export const DEFAULT_THEME_CONFIG: ThemeConfig = {
mermaid: {
theme: {
dark: 'dark' as mermaidAPI.Theme,
light: 'default' as mermaidAPI.Theme,
dark: 'dark',
light: 'default',
},
options: {},
},
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3659,11 +3659,6 @@
dependencies:
"@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":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.2.tgz#ce29c8b166a73bf980a5727b1e4a4d099965151d"
Expand Down Expand Up @@ -11117,10 +11112,10 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

mermaid@9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.2.0.tgz#e73bfe252a8cb12427fcb9cb38867d8f2d1a77f0"
integrity sha512-iWKTBjHoPUSs+mJMpZ5+K9xg97KflKjbv91Bu42yK2jjz4wX4Nt1eshi+bmmFWAhn7f2R0X55hlxxbSxdp0QYA==
mermaid@^9.2.2:
version "9.2.2"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.2.2.tgz#73cca1f0b74e7e674c0de3519d7e7e8ea83bea4a"
integrity sha512-6s7eKMqFJGS+0MYjmx8f6ZigqKBJVoSx5ql2gw6a4Aa+WJ49QiEJg7gPwywaBg3DZMs79UP7trESp4+jmaQccw==
dependencies:
"@braintree/sanitize-url" "^6.0.0"
d3 "^7.0.0"
Expand Down

0 comments on commit ba777d8

Please sign in to comment.