@docusaurus/theme-mermaid 3.10.1-canary-6655 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { useState, useEffect, useMemo, useId } from 'react';
7
+ import { useState, useEffect, useMemo } from 'react';
8
8
  import { useColorMode, useThemeConfig } from '@docusaurus/theme-common';
9
9
  import { loadMermaid } from './loadMermaid';
10
10
  // Stable className to allow users to easily target with CSS
@@ -19,9 +19,15 @@ export function useMermaidConfig() {
19
19
  const { options } = mermaidThemeConfig;
20
20
  return useMemo(() => ({ startOnLoad: false, ...options, theme }), [theme, options]);
21
21
  }
22
- // Random client-only id, we don't care much but mermaid want an id so...
23
22
  function useMermaidId() {
24
- return useId();
23
+ /*
24
+ Random client-only id, we don't care much but mermaid want an id so...
25
+ Note: Mermaid doesn't like values provided by Rect.useId() and throws
26
+ */
27
+ // TODO Docusaurus v4: check if useId() now works
28
+ // It could work thanks to https://github.com/facebook/react/pull/32001
29
+ // return useId(); // tried that, doesn't work ('#d:re:' is not a valid selector.)
30
+ return useState(`mermaid-svg-${Math.round(Math.random() * 10000000)}`)[0];
25
31
  }
26
32
  async function renderMermaid({ id, text, config, }) {
27
33
  const mermaid = await loadMermaid();
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ async function isElkLayoutPackageAvailable() {
18
18
  await import('@mermaid-js/layout-elk');
19
19
  return true;
20
20
  }
21
- catch {
21
+ catch (e) {
22
22
  return false;
23
23
  }
24
24
  }
@@ -22,6 +22,7 @@ function MermaidRenderResult({renderResult}) {
22
22
  <div
23
23
  ref={ref}
24
24
  className={`${MermaidContainerClassName} ${styles.container}`}
25
+ // eslint-disable-next-line react/no-danger
25
26
  dangerouslySetInnerHTML={{__html: renderResult.svg}}
26
27
  />
27
28
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-mermaid",
3
- "version": "3.10.1-canary-6655",
3
+ "version": "3.10.2",
4
4
  "description": "Mermaid components for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-mermaid.d.ts",
@@ -27,24 +27,24 @@
27
27
  },
28
28
  "license": "MIT",
29
29
  "scripts": {
30
- "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"",
30
+ "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
31
31
  "watch": "run-p -c copy:watch build:watch",
32
32
  "build:watch": "tsc --build --watch",
33
33
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/core": "3.10.1-canary-6655",
37
- "@docusaurus/module-type-aliases": "3.10.1-canary-6655",
38
- "@docusaurus/theme-common": "3.10.1-canary-6655",
39
- "@docusaurus/types": "3.10.1-canary-6655",
40
- "@docusaurus/utils-validation": "3.10.1-canary-6655",
41
- "mermaid": ">=11.14.0",
36
+ "@docusaurus/core": "3.10.2",
37
+ "@docusaurus/module-type-aliases": "3.10.2",
38
+ "@docusaurus/theme-common": "3.10.2",
39
+ "@docusaurus/types": "3.10.2",
40
+ "@docusaurus/utils-validation": "3.10.2",
41
+ "mermaid": ">=11.6.0",
42
42
  "tslib": "^2.6.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@mermaid-js/layout-elk": "^0.1.9",
46
- "react": "^19.2.5",
47
- "react-dom": "^19.2.5"
46
+ "react": "^18.0.0 || ^19.0.0",
47
+ "react-dom": "^18.0.0 || ^19.0.0"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@mermaid-js/layout-elk": {
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "engines": {
55
- "node": ">=24.14"
55
+ "node": ">=20.0"
56
56
  },
57
- "gitHead": "6e93a3055178dd0af922ba627f787229dcdf948b"
57
+ "gitHead": "f37f9035584917a97a260b91fc2842cba4f8b94f"
58
58
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {useState, useEffect, useMemo, useId} from 'react';
8
+ import {useState, useEffect, useMemo} from 'react';
9
9
  import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
10
10
  import {loadMermaid} from './loadMermaid';
11
11
 
@@ -32,9 +32,17 @@ export function useMermaidConfig(): MermaidConfig {
32
32
  );
33
33
  }
34
34
 
35
- // Random client-only id, we don't care much but mermaid want an id so...
36
35
  function useMermaidId(): string {
37
- return useId();
36
+ /*
37
+ Random client-only id, we don't care much but mermaid want an id so...
38
+ Note: Mermaid doesn't like values provided by Rect.useId() and throws
39
+ */
40
+
41
+ // TODO Docusaurus v4: check if useId() now works
42
+ // It could work thanks to https://github.com/facebook/react/pull/32001
43
+ // return useId(); // tried that, doesn't work ('#d:re:' is not a valid selector.)
44
+
45
+ return useState(`mermaid-svg-${Math.round(Math.random() * 10000000)}`)[0];
38
46
  }
39
47
 
40
48
  async function renderMermaid({
@@ -9,6 +9,7 @@ import type {Mermaid} from 'mermaid';
9
9
 
10
10
  declare global {
11
11
  // Global variable provided by bundler DefinePlugin
12
+ /* eslint-disable-next-line no-underscore-dangle */
12
13
  const __DOCUSAURUS_MERMAID_LAYOUT_ELK_ENABLED__: boolean;
13
14
  }
14
15
 
package/src/index.ts CHANGED
@@ -16,7 +16,7 @@ async function isElkLayoutPackageAvailable() {
16
16
  try {
17
17
  await import('@mermaid-js/layout-elk');
18
18
  return true;
19
- } catch {
19
+ } catch (e) {
20
20
  return false;
21
21
  }
22
22
  }
@@ -33,6 +33,7 @@ function MermaidRenderResult({
33
33
  <div
34
34
  ref={ref}
35
35
  className={`${MermaidContainerClassName} ${styles.container}`}
36
+ // eslint-disable-next-line react/no-danger
36
37
  dangerouslySetInnerHTML={{__html: renderResult.svg}}
37
38
  />
38
39
  );