@myst-theme/diagrams 0.9.2 → 0.9.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAY1D,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,2CA0B3E;AAED,eAAO,MAAM,mBAAmB,EAAE,YAEjC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAY1D,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,2CA6B3E;AAED,eAAO,MAAM,mBAAmB,EAAE,YAEjC,CAAC"}
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { useEffect, useState } from 'react';
11
+ import { useEffect, useId, useState } from 'react';
12
12
  function parse(id, text) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const { default: mermaid } = yield import('mermaid');
@@ -20,10 +20,11 @@ function parse(id, text) {
20
20
  });
21
21
  }
22
22
  export function MermaidRenderer({ id, value }) {
23
+ const key = useId();
23
24
  const [graph, setGraph] = useState();
24
25
  const [error, setError] = useState();
25
26
  useEffect(() => {
26
- parse(id, value)
27
+ parse(`mermaid-${key.replace(/:/g, '')}`, value)
27
28
  .then((svg) => {
28
29
  setGraph(svg);
29
30
  setError(undefined);
@@ -33,8 +34,8 @@ export function MermaidRenderer({ id, value }) {
33
34
  setError(err);
34
35
  });
35
36
  }, []);
36
- return (_jsxs("figure", { className: "", children: [graph && _jsx("div", { dangerouslySetInnerHTML: { __html: graph } }), error && (_jsxs("pre", { children: ["Error parsing mermaid graph.", '\n\n', value] }))] }));
37
+ return (_jsxs("figure", { id: id, children: [graph && _jsx("div", { dangerouslySetInnerHTML: { __html: graph } }), error && (_jsxs("pre", { children: ["Error parsing mermaid graph.", '\n\n', error.message, '\n\n', value] }))] }));
37
38
  }
38
39
  export const MermaidNodeRenderer = ({ node }) => {
39
- return _jsx(MermaidRenderer, { id: node.key, value: node.value });
40
+ return _jsx(MermaidRenderer, { id: node.html_id || node.identifier, value: node.value });
40
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/diagrams",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "build": "npm-run-all -l clean -p build:esm"
21
21
  },
22
22
  "dependencies": {
23
- "@myst-theme/providers": "^0.9.2",
23
+ "@myst-theme/providers": "^0.9.3",
24
24
  "mermaid": "^9.3.0"
25
25
  },
26
26
  "peerDependencies": {