nested-markdown 0.0.10 → 0.0.12

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.
package/dist/index.js CHANGED
@@ -28237,7 +28237,7 @@ function expandNestedMarkdownSync(markdown, options2) {
28237
28237
  // src/Mermaid.tsx
28238
28238
  import { useEffect as useEffect2, useState as useState2, useId } from "react";
28239
28239
  import { jsx as jsx2 } from "react/jsx-runtime";
28240
- var Mermaid = ({ chart, theme }) => {
28240
+ var MermaidClient = ({ chart, theme }) => {
28241
28241
  const id = useId().replace(/:/g, "");
28242
28242
  const [svg5, setSvg] = useState2("");
28243
28243
  const [hydrated, setHydrated] = useState2(false);
@@ -28253,7 +28253,7 @@ var Mermaid = ({ chart, theme }) => {
28253
28253
  } else if (theme === "light") {
28254
28254
  mermaidTheme = "default";
28255
28255
  } else {
28256
- if (typeof window !== "undefined") {
28256
+ if (typeof window !== "undefined" || typeof document === "undefined") {
28257
28257
  mermaidTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "default";
28258
28258
  }
28259
28259
  }
@@ -28288,6 +28288,12 @@ var Mermaid = ({ chart, theme }) => {
28288
28288
  }
28289
28289
  return /* @__PURE__ */ jsx2("div", { className: "mermaid", dangerouslySetInnerHTML: { __html: svg5 } });
28290
28290
  };
28291
+ var Mermaid = ({ chart, theme }) => {
28292
+ if (typeof window === "undefined" || typeof document === "undefined") {
28293
+ return /* @__PURE__ */ jsx2("pre", { className: "mermaid", children: chart });
28294
+ }
28295
+ return /* @__PURE__ */ jsx2(MermaidClient, { chart, theme });
28296
+ };
28291
28297
 
28292
28298
  // src/NestedMarkdown.tsx
28293
28299
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
@@ -28440,13 +28446,18 @@ var NestedMarkdown = ({
28440
28446
  const match = /language-(\w+)/.exec(className2 || "");
28441
28447
  const isMermaid = match && match[1] === "mermaid";
28442
28448
  if (!inline2 && isMermaid) {
28443
- return /* @__PURE__ */ jsx3(
28444
- Mermaid,
28445
- {
28446
- chart: String(children3).replace(/\n$/, ""),
28447
- theme: theme === "auto" ? void 0 : theme
28448
- }
28449
- );
28449
+ const chart = String(children3).replace(/\n$/, "");
28450
+ if (typeof window === "undefined" || typeof document === "undefined") {
28451
+ return /* @__PURE__ */ jsx3("pre", { className: "nmd-pre", children: /* @__PURE__ */ jsx3(
28452
+ "code",
28453
+ {
28454
+ ...props,
28455
+ className: [className2, "nmd-code"].filter(Boolean).join(" "),
28456
+ children: chart
28457
+ }
28458
+ ) });
28459
+ }
28460
+ return /* @__PURE__ */ jsx3(Mermaid, { chart, theme: theme === "auto" ? void 0 : theme });
28450
28461
  }
28451
28462
  return /* @__PURE__ */ jsx3(
28452
28463
  "code",