remons-render-markdown 1.0.0-beta.1 → 1.0.0-beta.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.
@@ -1,38 +1,38 @@
1
- import { a as e, i as t, o as n, r, t as i } from "./RenderMarkdown-TzdhCUFl.js";
1
+ import { a as e, i as t, o as n, s as r, t as i } from "./RenderMarkdown-Br1PK06M.js";
2
2
  import a, { createContext as o, forwardRef as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
3
3
  import { CodeOutlined as m, DownOutlined as h, DownloadOutlined as g, ExportOutlined as _, FullscreenExitOutlined as v, FullscreenOutlined as y, ImportOutlined as ee, LoadingOutlined as te, MinusOutlined as b, PlusOutlined as x, ReloadOutlined as S, UpOutlined as C } from "@ant-design/icons";
4
4
  import { createPortal as w } from "react-dom";
5
5
  import { jsx as T, jsxs as E } from "react/jsx-runtime";
6
6
  //#region src/utils/download.ts
7
- function D(e, n) {
7
+ function D(t, n) {
8
8
  let r;
9
- if (e instanceof Blob) r = URL.createObjectURL(e);
10
- else if (typeof e == "string") r = e;
9
+ if (t instanceof Blob) r = URL.createObjectURL(t);
10
+ else if (typeof t == "string") r = t;
11
11
  else {
12
- t.error("不支持的下载格式");
12
+ e.error("不支持的下载格式");
13
13
  return;
14
14
  }
15
15
  let i = document.createElement("a");
16
- i.href = r, i.download = n, i.click(), URL.revokeObjectURL(r), t.success(`${n} 已下载`);
16
+ i.href = r, i.download = n, i.click(), URL.revokeObjectURL(r), e.success(`${n} 已下载`);
17
17
  }
18
18
  function ne(e, t = "image") {
19
19
  D(new Blob([e], { type: "image/svg+xml;charset=utf-8" }), `${t}.svg`);
20
20
  }
21
- function O(e, n = "image", r = 2) {
22
- let { w: i, h: a } = k(e), o = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e)))}`, s = new Image();
21
+ function O(t, n = "image", r = 2) {
22
+ let { w: i, h: a } = k(t), o = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`, s = new Image();
23
23
  s.crossOrigin = "anonymous", s.src = o, s.onload = () => {
24
- let e = document.createElement("canvas");
25
- e.width = Math.max(1, Math.round(i * r)), e.height = Math.max(1, Math.round(a * r));
26
- let o = e.getContext("2d");
27
- o.fillStyle = "#ffffff", o.fillRect(0, 0, e.width, e.height), o.scale(r, r), o.drawImage(s, 0, 0, i, a), e.toBlob((e) => {
28
- if (!e) {
29
- t.error("PNG 生成失败");
24
+ let t = document.createElement("canvas");
25
+ t.width = Math.max(1, Math.round(i * r)), t.height = Math.max(1, Math.round(a * r));
26
+ let o = t.getContext("2d");
27
+ o.fillStyle = "#ffffff", o.fillRect(0, 0, t.width, t.height), o.scale(r, r), o.drawImage(s, 0, 0, i, a), t.toBlob((t) => {
28
+ if (!t) {
29
+ e.error("PNG 生成失败");
30
30
  return;
31
31
  }
32
- D(e, `${n}.png`);
32
+ D(t, `${n}.png`);
33
33
  }, "image/png");
34
34
  }, s.onerror = () => {
35
- t.error("PNG 生成失败:图片加载失败");
35
+ e.error("PNG 生成失败:图片加载失败");
36
36
  };
37
37
  }
38
38
  function k(e) {
@@ -129,7 +129,7 @@ function ae() {
129
129
  }
130
130
  //#endregion
131
131
  //#region src/components/CustomTooltip/index.tsx
132
- var R = e.bind({
132
+ var R = n.bind({
133
133
  tooltip: "_tooltip_1kuma_4",
134
134
  "tooltip-trigger": "_tooltip-trigger_1kuma_7",
135
135
  "tooltip-inner": "_tooltip-inner_1kuma_11",
@@ -189,7 +189,7 @@ var R = e.bind({
189
189
  children: t
190
190
  }), y]
191
191
  });
192
- }, z = e.bind({
192
+ }, z = n.bind({
193
193
  dropdown: "_dropdown_x4h0x_4",
194
194
  "dropdown-trigger": "_dropdown-trigger_x4h0x_8",
195
195
  "dropdown-menu": "_dropdown-menu_x4h0x_12",
@@ -226,7 +226,7 @@ var R = e.bind({
226
226
  }, e.key))
227
227
  })]
228
228
  });
229
- }, B = e.bind({
229
+ }, B = n.bind({
230
230
  "modal-mask": "_modal-mask_uwsht_4",
231
231
  "modal-mask-visible": "_modal-mask-visible_uwsht_18",
232
232
  modal: "_modal_uwsht_4",
@@ -824,7 +824,7 @@ var Z = {
824
824
  previewContent: "_previewContent_d2mv6_22",
825
825
  errorTip: "_errorTip_d2mv6_38",
826
826
  emptyTip: "_emptyTip_d2mv6_50"
827
- }, Fe = r(), Ie = [
827
+ }, Fe = t(), Ie = [
828
828
  "pointerdown",
829
829
  "mousedown",
830
830
  "pointerup",
@@ -1591,9 +1591,9 @@ function Ut(e) {
1591
1591
  }
1592
1592
  //#endregion
1593
1593
  //#region src/components/MermaidRenderer/index.tsx
1594
- var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-menu-driver", qt = s(function({ source: n, debounceMs: r = 300, enablePanzoom: a = !0, showDownload: o = !0, showSourceView: s = !1, showCollapse: l = !1, defaultCollapsed: d = !0, className: w = "", minHeight: D = 200 }) {
1595
- let k = n.match(/---\s*\n\s*title:\s*(.+)\s*\n\s*---/), A = k ? k[1].trim() : "mermaid 图表", { isDark: j } = ae(), { svg: M, error: N, loading: re } = ue({
1596
- source: n,
1594
+ var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-menu-driver", qt = s(function({ source: t, debounceMs: r = 300, enablePanzoom: a = !0, showDownload: o = !0, showSourceView: s = !1, showCollapse: l = !1, defaultCollapsed: d = !0, className: w = "", minHeight: D = 200 }) {
1595
+ let k = t.match(/---\s*\n\s*title:\s*(.+)\s*\n\s*---/), A = k ? k[1].trim() : "mermaid 图表", { isDark: j } = ae(), { svg: M, error: N, loading: re } = ue({
1596
+ source: t,
1597
1597
  debounceMs: r,
1598
1598
  isDark: j
1599
1599
  }), [P, F] = p(!1), [I, L] = p(d), [ie, R] = p(!1), [z, B] = p(s), V = f(null), H = f(null), U = a && (P || !I || !l), W = Pe({
@@ -1709,13 +1709,13 @@ var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-
1709
1709
  }, [l]);
1710
1710
  let le = c(() => {
1711
1711
  if (!M) {
1712
- t.warning("暂无图表");
1712
+ e.warning("暂无图表");
1713
1713
  return;
1714
1714
  }
1715
1715
  ne(M, A);
1716
1716
  }, [M]), de = c(() => {
1717
1717
  if (!M) {
1718
- t.warning("暂无图表");
1718
+ e.warning("暂无图表");
1719
1719
  return;
1720
1720
  }
1721
1721
  O(M, A, 2);
@@ -1731,7 +1731,7 @@ var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-
1731
1731
  }, G = !!M;
1732
1732
  return /* @__PURE__ */ E("div", {
1733
1733
  ref: V,
1734
- className: e.bind(Z)(l ? "mermaid-wrapper" : "", I && l && !z ? " mermaid-collapsed" : "", w, z && I && !P ? "mermaid-mini" : ""),
1734
+ className: n.bind(Z)(l ? "mermaid-wrapper" : "", I && l && !z ? " mermaid-collapsed" : "", w, z && I && !P ? "mermaid-mini" : ""),
1735
1735
  style: {
1736
1736
  minHeight: z ? 0 : D,
1737
1737
  position: "relative",
@@ -1845,7 +1845,7 @@ var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-
1845
1845
  dangerouslySetInnerHTML: { __html: M || "" }
1846
1846
  }), (!G && !N || re) && /* @__PURE__ */ T("div", {
1847
1847
  className: Z.emptyTip,
1848
- children: n?.trim() ? "渲染中..." : "← 输入 Mermaid 源码"
1848
+ children: t?.trim() ? "渲染中..." : "← 输入 Mermaid 源码"
1849
1849
  })]
1850
1850
  }),
1851
1851
  s && /* @__PURE__ */ T(ce, {
@@ -1860,7 +1860,7 @@ var Wt = "docList-mermaid-driver", Gt = "docList-menu-driver", Kt = "docList-pc-
1860
1860
  isShowCollapsed: !1,
1861
1861
  isSlotMermaid: !1,
1862
1862
  codeType: "mermaid",
1863
- content: n
1863
+ content: t
1864
1864
  })
1865
1865
  })
1866
1866
  ]
@@ -1871,9 +1871,9 @@ async function Jt() {
1871
1871
  for (let t of e) {
1872
1872
  let e = t.parentElement;
1873
1873
  if (!e) return;
1874
- let r = t.textContent.trim(), i = document.createElement("div");
1875
- i.className = "mermaid-react-root", e.replaceWith(i), n(i).render(/* @__PURE__ */ T(a.StrictMode, { children: /* @__PURE__ */ T(ie, { children: /* @__PURE__ */ T(qt, {
1876
- source: r,
1874
+ let n = t.textContent.trim(), i = document.createElement("div");
1875
+ i.className = "mermaid-react-root", e.replaceWith(i), r(i).render(/* @__PURE__ */ T(a.StrictMode, { children: /* @__PURE__ */ T(ie, { children: /* @__PURE__ */ T(qt, {
1876
+ source: n,
1877
1877
  enablePanzoom: !0,
1878
1878
  showDownload: !0,
1879
1879
  showSourceView: !0,
@@ -1886,4 +1886,4 @@ async function Jt() {
1886
1886
  //#endregion
1887
1887
  export { Jt as renderMermaidWithControls };
1888
1888
 
1889
- //# sourceMappingURL=MermaidRenderer-DupOXIdE.js.map
1889
+ //# sourceMappingURL=MermaidRenderer-D1jOKZ4Z.js.map