@superlc/md-react 0.1.1 → 0.2.0
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/Markdown.d.ts +10 -0
- package/dist/Markdown.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/mermaid/MermaidBlock.d.ts +5 -0
- package/dist/components/mermaid/MermaidBlock.d.ts.map +1 -0
- package/dist/components/mermaid/MermaidFullscreenViewer.d.ts +5 -0
- package/dist/components/mermaid/MermaidFullscreenViewer.d.ts.map +1 -0
- package/dist/components/mermaid/icons.d.ts +25 -0
- package/dist/components/mermaid/icons.d.ts.map +1 -0
- package/dist/components/mermaid/index.d.ts +8 -0
- package/dist/components/mermaid/index.d.ts.map +1 -0
- package/dist/components/mermaid/types.d.ts +42 -0
- package/dist/components/mermaid/types.d.ts.map +1 -0
- package/dist/components/mermaid/useZoom.d.ts +28 -0
- package/dist/components/mermaid/useZoom.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +824 -296
- package/dist/types.d.ts +19 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -3
package/dist/index.js
CHANGED
|
@@ -1,425 +1,953 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { parseToHast as
|
|
4
|
-
import { toJsxRuntime as
|
|
5
|
-
async function
|
|
1
|
+
import { jsxs as C, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import U, { useState as E, useCallback as p, useRef as k, useEffect as z, useMemo as O, memo as P, useLayoutEffect as me } from "react";
|
|
3
|
+
import { detectColorScheme as fe, observeColorScheme as he, downloadAsPng as pe, MermaidRenderer as be, parseToHast as J, createStreamingParser as Q, OutputRateController as ee } from "@superlc/md-core";
|
|
4
|
+
import { toJsxRuntime as W } from "hast-util-to-jsx-runtime";
|
|
5
|
+
async function ve(t) {
|
|
6
6
|
try {
|
|
7
|
-
return await navigator.clipboard.writeText(
|
|
7
|
+
return await navigator.clipboard.writeText(t), !0;
|
|
8
8
|
} catch {
|
|
9
|
-
return
|
|
9
|
+
return ge(t);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
function ge(t) {
|
|
13
|
+
const n = document.createElement("textarea");
|
|
14
|
+
n.value = t, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
|
|
15
15
|
try {
|
|
16
16
|
return document.execCommand("copy"), !0;
|
|
17
17
|
} catch {
|
|
18
18
|
return !1;
|
|
19
19
|
} finally {
|
|
20
|
-
document.body.removeChild(
|
|
20
|
+
document.body.removeChild(n);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
children:
|
|
25
|
-
showCopyButton:
|
|
26
|
-
onCopy:
|
|
27
|
-
className:
|
|
23
|
+
const ye = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }) }), we = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }), K = ({
|
|
24
|
+
children: t,
|
|
25
|
+
showCopyButton: n = !0,
|
|
26
|
+
onCopy: c,
|
|
27
|
+
className: l
|
|
28
28
|
}) => {
|
|
29
|
-
const [
|
|
30
|
-
const
|
|
31
|
-
await
|
|
32
|
-
}, [
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
29
|
+
const [a, i] = E(!1), o = p(async () => {
|
|
30
|
+
const r = j(t);
|
|
31
|
+
await ve(r) && (i(!0), c == null || c(r), setTimeout(() => i(!1), 2e3));
|
|
32
|
+
}, [t, c]);
|
|
33
|
+
return /* @__PURE__ */ C("div", { className: `md-code-block-wrapper${l ? ` ${l}` : ""}`, children: [
|
|
34
|
+
/* @__PURE__ */ e("pre", { children: t }),
|
|
35
|
+
n && /* @__PURE__ */ e(
|
|
36
36
|
"button",
|
|
37
37
|
{
|
|
38
38
|
type: "button",
|
|
39
|
-
className: `md-copy-button${
|
|
40
|
-
onClick:
|
|
41
|
-
title:
|
|
42
|
-
"aria-label":
|
|
43
|
-
children:
|
|
39
|
+
className: `md-copy-button${a ? " md-copy-button--copied" : ""}`,
|
|
40
|
+
onClick: o,
|
|
41
|
+
title: a ? "已复制" : "复制代码",
|
|
42
|
+
"aria-label": a ? "已复制" : "复制代码",
|
|
43
|
+
children: a ? /* @__PURE__ */ e(we, {}) : /* @__PURE__ */ e(ye, {})
|
|
44
44
|
}
|
|
45
45
|
)
|
|
46
46
|
] });
|
|
47
47
|
};
|
|
48
|
-
function
|
|
49
|
-
return typeof
|
|
48
|
+
function j(t) {
|
|
49
|
+
return typeof t == "string" ? t : typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(j).join("") : U.isValidElement(t) ? j(t.props.children) : "";
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
K.displayName = "CodeBlock";
|
|
52
|
+
const ke = {
|
|
53
|
+
min: 0.25,
|
|
54
|
+
max: 4,
|
|
55
|
+
step: 0.25,
|
|
56
|
+
default: 1
|
|
57
|
+
};
|
|
58
|
+
function te(t = {}) {
|
|
59
|
+
const {
|
|
60
|
+
config: n,
|
|
61
|
+
enableDrag: c = !1,
|
|
62
|
+
enableWheelZoom: l = !1
|
|
63
|
+
} = t, a = { ...ke, ...n }, i = k(null), o = k(!1), r = k({ x: 0, y: 0 }), b = k({ x: 0, y: 0 }), [u, f] = E({
|
|
64
|
+
scale: a.default,
|
|
65
|
+
translateX: 0,
|
|
66
|
+
translateY: 0
|
|
67
|
+
}), d = p(
|
|
68
|
+
(s) => Math.max(a.min, Math.min(a.max, s)),
|
|
69
|
+
[a.min, a.max]
|
|
70
|
+
), v = p(() => {
|
|
71
|
+
f((s) => ({
|
|
72
|
+
...s,
|
|
73
|
+
scale: d(s.scale + a.step)
|
|
74
|
+
}));
|
|
75
|
+
}, [d, a.step]), h = p(() => {
|
|
76
|
+
f((s) => ({
|
|
77
|
+
...s,
|
|
78
|
+
scale: d(s.scale - a.step)
|
|
79
|
+
}));
|
|
80
|
+
}, [d, a.step]), g = p(() => {
|
|
81
|
+
f({
|
|
82
|
+
scale: a.default,
|
|
83
|
+
translateX: 0,
|
|
84
|
+
translateY: 0
|
|
85
|
+
});
|
|
86
|
+
}, [a.default]), x = p(
|
|
87
|
+
(s) => {
|
|
88
|
+
f((w) => ({
|
|
89
|
+
...w,
|
|
90
|
+
scale: d(s)
|
|
91
|
+
}));
|
|
92
|
+
},
|
|
93
|
+
[d]
|
|
94
|
+
), V = p(
|
|
95
|
+
(s, w) => {
|
|
96
|
+
const L = s.width / w.width, D = s.height / w.height, F = Math.min(L, D) * 0.95;
|
|
97
|
+
f({
|
|
98
|
+
scale: d(F),
|
|
99
|
+
translateX: 0,
|
|
100
|
+
translateY: 0
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
[d]
|
|
104
|
+
), y = p(
|
|
105
|
+
(s) => {
|
|
106
|
+
c && (s.preventDefault(), o.current = !0, r.current = { x: s.clientX, y: s.clientY }, b.current = { x: u.translateX, y: u.translateY });
|
|
107
|
+
},
|
|
108
|
+
[c, u.translateX, u.translateY]
|
|
109
|
+
);
|
|
110
|
+
z(() => {
|
|
111
|
+
if (!c) return;
|
|
112
|
+
const s = (L) => {
|
|
113
|
+
if (!o.current) return;
|
|
114
|
+
const D = L.clientX - r.current.x, F = L.clientY - r.current.y;
|
|
115
|
+
f((m) => ({
|
|
116
|
+
...m,
|
|
117
|
+
translateX: b.current.x + D,
|
|
118
|
+
translateY: b.current.y + F
|
|
119
|
+
}));
|
|
120
|
+
}, w = () => {
|
|
121
|
+
o.current = !1;
|
|
122
|
+
};
|
|
123
|
+
return document.addEventListener("mousemove", s), document.addEventListener("mouseup", w), () => {
|
|
124
|
+
document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", w);
|
|
125
|
+
};
|
|
126
|
+
}, [c]);
|
|
127
|
+
const I = p(
|
|
128
|
+
(s) => {
|
|
129
|
+
if (!l) return;
|
|
130
|
+
s.preventDefault();
|
|
131
|
+
const w = s.deltaY > 0 ? -a.step : a.step;
|
|
132
|
+
f((L) => ({
|
|
133
|
+
...L,
|
|
134
|
+
scale: d(L.scale + w)
|
|
135
|
+
}));
|
|
136
|
+
},
|
|
137
|
+
[l, a.step, d]
|
|
138
|
+
), B = p(() => {
|
|
139
|
+
g();
|
|
140
|
+
}, [g]), T = {
|
|
141
|
+
transform: `translate(${u.translateX}px, ${u.translateY}px) scale(${u.scale})`,
|
|
142
|
+
transformOrigin: "center center",
|
|
143
|
+
transition: o.current ? "none" : "transform 0.2s ease-out",
|
|
144
|
+
cursor: c ? o.current ? "grabbing" : "grab" : "default"
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
state: u,
|
|
148
|
+
zoomIn: v,
|
|
149
|
+
zoomOut: h,
|
|
150
|
+
reset: g,
|
|
151
|
+
fitToContainer: V,
|
|
152
|
+
setScale: x,
|
|
153
|
+
canZoomIn: u.scale < a.max,
|
|
154
|
+
canZoomOut: u.scale > a.min,
|
|
155
|
+
containerRef: i,
|
|
156
|
+
contentStyle: T,
|
|
157
|
+
handlers: {
|
|
158
|
+
onMouseDown: y,
|
|
159
|
+
onWheel: I,
|
|
160
|
+
onDoubleClick: B
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const Ce = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z" }) }), xe = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z" }) }), ne = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2V7z" }) }), re = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7V9z" }) }), ae = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" }) }), Ne = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }) }), Me = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }) }), ce = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" }) }), Se = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }), ze = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }) }), Le = () => /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }), se = ({
|
|
165
|
+
svg: t,
|
|
166
|
+
open: n,
|
|
167
|
+
onClose: c,
|
|
168
|
+
onDownload: l
|
|
59
169
|
}) => {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
170
|
+
const a = k(null), i = k(null), o = k(null), [r, b] = E(!1), {
|
|
171
|
+
state: u,
|
|
172
|
+
zoomIn: f,
|
|
173
|
+
zoomOut: d,
|
|
174
|
+
reset: v,
|
|
175
|
+
fitToContainer: h,
|
|
176
|
+
canZoomIn: g,
|
|
177
|
+
canZoomOut: x,
|
|
178
|
+
contentStyle: V,
|
|
179
|
+
handlers: y
|
|
180
|
+
} = te({
|
|
181
|
+
enableDrag: !0,
|
|
182
|
+
enableWheelZoom: !0
|
|
183
|
+
}), I = p(async () => {
|
|
184
|
+
if (a.current)
|
|
185
|
+
try {
|
|
186
|
+
await a.current.requestFullscreen(), b(!0);
|
|
187
|
+
} catch {
|
|
188
|
+
b(!0);
|
|
189
|
+
}
|
|
190
|
+
}, []), B = p(() => {
|
|
191
|
+
document.fullscreenElement && document.exitFullscreen().catch(() => {
|
|
192
|
+
}), b(!1), c();
|
|
193
|
+
}, [c]);
|
|
194
|
+
z(() => {
|
|
195
|
+
n ? I() : r && B();
|
|
196
|
+
}, [n, I, B, r]), z(() => {
|
|
197
|
+
const s = () => {
|
|
198
|
+
!document.fullscreenElement && r && (b(!1), c());
|
|
65
199
|
};
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
200
|
+
return document.addEventListener("fullscreenchange", s), () => document.removeEventListener("fullscreenchange", s);
|
|
201
|
+
}, [r, c]), z(() => {
|
|
202
|
+
if (!r) return;
|
|
203
|
+
const s = (w) => {
|
|
204
|
+
switch (w.key) {
|
|
205
|
+
case "+":
|
|
206
|
+
case "=":
|
|
207
|
+
f();
|
|
208
|
+
break;
|
|
209
|
+
case "-":
|
|
210
|
+
d();
|
|
211
|
+
break;
|
|
212
|
+
case "0":
|
|
213
|
+
v();
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
|
|
218
|
+
}, [r, f, d, v]);
|
|
219
|
+
const T = p(() => {
|
|
220
|
+
if (!i.current || !o.current) return;
|
|
221
|
+
const s = i.current.getBoundingClientRect(), w = o.current.querySelector("svg");
|
|
222
|
+
if (w) {
|
|
223
|
+
const L = w.getBoundingClientRect();
|
|
224
|
+
h(s, L);
|
|
225
|
+
}
|
|
226
|
+
}, [h]);
|
|
227
|
+
return /* @__PURE__ */ e(
|
|
228
|
+
"div",
|
|
229
|
+
{
|
|
230
|
+
ref: a,
|
|
231
|
+
className: `md-mermaid-fullscreen-wrapper${r ? " md-mermaid-fullscreen-wrapper--active" : ""}`,
|
|
232
|
+
role: "dialog",
|
|
233
|
+
"aria-modal": "true",
|
|
234
|
+
"aria-label": "Mermaid 图表全屏预览",
|
|
235
|
+
"aria-hidden": !r,
|
|
236
|
+
children: r && /* @__PURE__ */ C(H, { children: [
|
|
237
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-fullscreen-toolbar", children: [
|
|
238
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-toolbar-group", children: [
|
|
239
|
+
/* @__PURE__ */ e(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
type: "button",
|
|
243
|
+
className: "md-mermaid-toolbar-btn",
|
|
244
|
+
onClick: d,
|
|
245
|
+
disabled: !x,
|
|
246
|
+
title: "缩小 (-)",
|
|
247
|
+
"aria-label": "缩小",
|
|
248
|
+
children: /* @__PURE__ */ e(re, {})
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ C("span", { className: "md-mermaid-zoom-label", children: [
|
|
252
|
+
Math.round(u.scale * 100),
|
|
253
|
+
"%"
|
|
254
|
+
] }),
|
|
255
|
+
/* @__PURE__ */ e(
|
|
256
|
+
"button",
|
|
257
|
+
{
|
|
258
|
+
type: "button",
|
|
259
|
+
className: "md-mermaid-toolbar-btn",
|
|
260
|
+
onClick: f,
|
|
261
|
+
disabled: !g,
|
|
262
|
+
title: "放大 (+)",
|
|
263
|
+
"aria-label": "放大",
|
|
264
|
+
children: /* @__PURE__ */ e(ne, {})
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ e("span", { className: "md-mermaid-toolbar-divider" }),
|
|
268
|
+
/* @__PURE__ */ e(
|
|
269
|
+
"button",
|
|
270
|
+
{
|
|
271
|
+
type: "button",
|
|
272
|
+
className: "md-mermaid-toolbar-btn",
|
|
273
|
+
onClick: v,
|
|
274
|
+
title: "重置 (0)",
|
|
275
|
+
"aria-label": "重置",
|
|
276
|
+
children: /* @__PURE__ */ e(ae, {})
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ e(
|
|
280
|
+
"button",
|
|
281
|
+
{
|
|
282
|
+
type: "button",
|
|
283
|
+
className: "md-mermaid-toolbar-btn",
|
|
284
|
+
onClick: T,
|
|
285
|
+
title: "适应窗口",
|
|
286
|
+
"aria-label": "适应窗口",
|
|
287
|
+
children: /* @__PURE__ */ e(Me, {})
|
|
288
|
+
}
|
|
289
|
+
)
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-toolbar-group", children: [
|
|
292
|
+
l && /* @__PURE__ */ e(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
type: "button",
|
|
296
|
+
className: "md-mermaid-toolbar-btn",
|
|
297
|
+
onClick: l,
|
|
298
|
+
title: "下载 PNG",
|
|
299
|
+
"aria-label": "下载",
|
|
300
|
+
children: /* @__PURE__ */ e(ce, {})
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
/* @__PURE__ */ e(
|
|
304
|
+
"button",
|
|
305
|
+
{
|
|
306
|
+
type: "button",
|
|
307
|
+
className: "md-mermaid-toolbar-btn",
|
|
308
|
+
onClick: B,
|
|
309
|
+
title: "退出全屏 (Esc)",
|
|
310
|
+
"aria-label": "退出全屏",
|
|
311
|
+
children: /* @__PURE__ */ e(Se, {})
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
] })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ e(
|
|
317
|
+
"div",
|
|
318
|
+
{
|
|
319
|
+
ref: i,
|
|
320
|
+
className: "md-mermaid-fullscreen-content",
|
|
321
|
+
onWheel: y.onWheel,
|
|
322
|
+
children: /* @__PURE__ */ e(
|
|
323
|
+
"div",
|
|
324
|
+
{
|
|
325
|
+
ref: o,
|
|
326
|
+
className: "md-mermaid-fullscreen-svg",
|
|
327
|
+
style: V,
|
|
328
|
+
onMouseDown: y.onMouseDown,
|
|
329
|
+
onDoubleClick: y.onDoubleClick,
|
|
330
|
+
dangerouslySetInnerHTML: { __html: t }
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
)
|
|
335
|
+
] })
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
se.displayName = "MermaidFullscreenViewer";
|
|
340
|
+
let Z = null;
|
|
341
|
+
function Ie(t = "auto") {
|
|
342
|
+
return Z ? Z.setTheme(t ?? "auto") : Z = new be({ theme: t }), Z;
|
|
343
|
+
}
|
|
344
|
+
async function Ee(t) {
|
|
345
|
+
try {
|
|
346
|
+
return await navigator.clipboard.writeText(t), !0;
|
|
347
|
+
} catch {
|
|
348
|
+
const n = document.createElement("textarea");
|
|
349
|
+
n.value = t, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
|
|
350
|
+
try {
|
|
351
|
+
return document.execCommand("copy"), !0;
|
|
352
|
+
} catch {
|
|
353
|
+
return !1;
|
|
354
|
+
} finally {
|
|
355
|
+
document.body.removeChild(n);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const oe = ({
|
|
360
|
+
code: t,
|
|
361
|
+
theme: n = "auto",
|
|
362
|
+
showToolbar: c = !0,
|
|
363
|
+
onCopy: l,
|
|
364
|
+
className: a
|
|
365
|
+
}) => {
|
|
366
|
+
const [i, o] = E("preview"), [r, b] = E(null), [u, f] = E(!0), [d, v] = E(!1), [h, g] = E(!1), x = k(null), [V, y] = E(() => fe()), {
|
|
367
|
+
state: I,
|
|
368
|
+
zoomIn: B,
|
|
369
|
+
zoomOut: T,
|
|
370
|
+
reset: s,
|
|
371
|
+
canZoomIn: w,
|
|
372
|
+
canZoomOut: L,
|
|
373
|
+
contentStyle: D
|
|
374
|
+
} = te();
|
|
375
|
+
z(() => {
|
|
376
|
+
if (n === "auto")
|
|
377
|
+
return he((S) => {
|
|
378
|
+
y(S);
|
|
379
|
+
});
|
|
380
|
+
}, [n]), z(() => {
|
|
381
|
+
let S = !1;
|
|
382
|
+
return (async () => {
|
|
383
|
+
f(!0);
|
|
384
|
+
const $ = await Ie(n).render(t);
|
|
385
|
+
S || (b($), f(!1), $.success || o("code"));
|
|
386
|
+
})(), () => {
|
|
387
|
+
S = !0;
|
|
388
|
+
};
|
|
389
|
+
}, [t, n, V]);
|
|
390
|
+
const F = p(async () => {
|
|
391
|
+
await Ee(t) && (g(!0), l == null || l(t), setTimeout(() => g(!1), 2e3));
|
|
392
|
+
}, [t, l]), m = p(async () => {
|
|
393
|
+
var S;
|
|
394
|
+
if (r != null && r.svg)
|
|
395
|
+
try {
|
|
396
|
+
const A = ((S = window.matchMedia) == null ? void 0 : S.call(window, "(prefers-color-scheme: dark)").matches) ?? !1;
|
|
397
|
+
await pe(r.svg, {
|
|
398
|
+
backgroundColor: A ? "#1a1a2e" : "#ffffff",
|
|
399
|
+
padding: 20,
|
|
400
|
+
scale: 2
|
|
401
|
+
});
|
|
402
|
+
} catch (A) {
|
|
403
|
+
console.error("Download failed:", A);
|
|
404
|
+
}
|
|
405
|
+
}, [r]), N = p(() => {
|
|
406
|
+
v((S) => !S);
|
|
407
|
+
}, []), M = (r == null ? void 0 : r.success) && r.svg;
|
|
408
|
+
return /* @__PURE__ */ C("div", { className: `md-mermaid-block${a ? ` ${a}` : ""}`, children: [
|
|
409
|
+
c && /* @__PURE__ */ C("div", { className: "md-mermaid-toolbar", children: [
|
|
410
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-toolbar-group md-mermaid-mode-switch", children: [
|
|
411
|
+
/* @__PURE__ */ e(
|
|
412
|
+
"button",
|
|
413
|
+
{
|
|
414
|
+
type: "button",
|
|
415
|
+
className: `md-mermaid-toolbar-btn${i === "preview" ? " md-mermaid-toolbar-btn--active" : ""}`,
|
|
416
|
+
onClick: () => o("preview"),
|
|
417
|
+
disabled: !M,
|
|
418
|
+
title: "图片模式",
|
|
419
|
+
"aria-label": "图片模式",
|
|
420
|
+
children: /* @__PURE__ */ e(Ce, {})
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
/* @__PURE__ */ e(
|
|
424
|
+
"button",
|
|
425
|
+
{
|
|
426
|
+
type: "button",
|
|
427
|
+
className: `md-mermaid-toolbar-btn${i === "code" ? " md-mermaid-toolbar-btn--active" : ""}`,
|
|
428
|
+
onClick: () => o("code"),
|
|
429
|
+
title: "代码模式",
|
|
430
|
+
"aria-label": "代码模式",
|
|
431
|
+
children: /* @__PURE__ */ e(xe, {})
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
] }),
|
|
435
|
+
i === "preview" && M && /* @__PURE__ */ C("div", { className: "md-mermaid-toolbar-group", children: [
|
|
436
|
+
/* @__PURE__ */ e(
|
|
437
|
+
"button",
|
|
438
|
+
{
|
|
439
|
+
type: "button",
|
|
440
|
+
className: "md-mermaid-toolbar-btn",
|
|
441
|
+
onClick: T,
|
|
442
|
+
disabled: !L,
|
|
443
|
+
title: "缩小",
|
|
444
|
+
"aria-label": "缩小",
|
|
445
|
+
children: /* @__PURE__ */ e(re, {})
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
/* @__PURE__ */ C("span", { className: "md-mermaid-zoom-label", children: [
|
|
449
|
+
Math.round(I.scale * 100),
|
|
450
|
+
"%"
|
|
451
|
+
] }),
|
|
452
|
+
/* @__PURE__ */ e(
|
|
453
|
+
"button",
|
|
454
|
+
{
|
|
455
|
+
type: "button",
|
|
456
|
+
className: "md-mermaid-toolbar-btn",
|
|
457
|
+
onClick: B,
|
|
458
|
+
disabled: !w,
|
|
459
|
+
title: "放大",
|
|
460
|
+
"aria-label": "放大",
|
|
461
|
+
children: /* @__PURE__ */ e(ne, {})
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ e(
|
|
465
|
+
"button",
|
|
466
|
+
{
|
|
467
|
+
type: "button",
|
|
468
|
+
className: "md-mermaid-toolbar-btn",
|
|
469
|
+
onClick: s,
|
|
470
|
+
title: "重置",
|
|
471
|
+
"aria-label": "重置缩放",
|
|
472
|
+
children: /* @__PURE__ */ e(ae, {})
|
|
473
|
+
}
|
|
474
|
+
)
|
|
475
|
+
] }),
|
|
476
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-toolbar-group", children: [
|
|
477
|
+
i === "preview" && M && /* @__PURE__ */ C(H, { children: [
|
|
478
|
+
/* @__PURE__ */ e(
|
|
479
|
+
"button",
|
|
480
|
+
{
|
|
481
|
+
type: "button",
|
|
482
|
+
className: "md-mermaid-toolbar-btn",
|
|
483
|
+
onClick: N,
|
|
484
|
+
title: "全屏",
|
|
485
|
+
"aria-label": "全屏查看",
|
|
486
|
+
children: /* @__PURE__ */ e(Ne, {})
|
|
487
|
+
}
|
|
488
|
+
),
|
|
489
|
+
/* @__PURE__ */ e(
|
|
490
|
+
"button",
|
|
491
|
+
{
|
|
492
|
+
type: "button",
|
|
493
|
+
className: "md-mermaid-toolbar-btn",
|
|
494
|
+
onClick: m,
|
|
495
|
+
title: "下载 PNG",
|
|
496
|
+
"aria-label": "下载",
|
|
497
|
+
children: /* @__PURE__ */ e(ce, {})
|
|
498
|
+
}
|
|
499
|
+
)
|
|
500
|
+
] }),
|
|
501
|
+
i === "code" && /* @__PURE__ */ e(
|
|
502
|
+
"button",
|
|
503
|
+
{
|
|
504
|
+
type: "button",
|
|
505
|
+
className: `md-mermaid-toolbar-btn${h ? " md-mermaid-toolbar-btn--success" : ""}`,
|
|
506
|
+
onClick: F,
|
|
507
|
+
title: h ? "已复制" : "复制代码",
|
|
508
|
+
"aria-label": h ? "已复制" : "复制代码",
|
|
509
|
+
children: h ? /* @__PURE__ */ e(Le, {}) : /* @__PURE__ */ e(ze, {})
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
] })
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ e("div", { className: "md-mermaid-content", ref: x, children: u ? (
|
|
515
|
+
// Loading 骨架屏
|
|
516
|
+
/* @__PURE__ */ e("div", { className: "md-mermaid-skeleton", children: /* @__PURE__ */ e("div", { className: "md-mermaid-skeleton-box" }) })
|
|
517
|
+
) : i === "preview" && M && (r != null && r.svg) ? (
|
|
518
|
+
// 图片模式
|
|
519
|
+
/* @__PURE__ */ e("div", { className: "md-mermaid-preview", style: { overflow: "hidden" }, children: /* @__PURE__ */ e(
|
|
520
|
+
"div",
|
|
521
|
+
{
|
|
522
|
+
className: "md-mermaid-svg-container",
|
|
523
|
+
style: D,
|
|
524
|
+
dangerouslySetInnerHTML: { __html: r.svg }
|
|
525
|
+
}
|
|
526
|
+
) })
|
|
527
|
+
) : (
|
|
528
|
+
// 代码模式
|
|
529
|
+
/* @__PURE__ */ C("div", { className: "md-mermaid-code", children: [
|
|
530
|
+
/* @__PURE__ */ e("pre", { children: /* @__PURE__ */ e("code", { className: "language-mermaid", children: t }) }),
|
|
531
|
+
r && !r.success && /* @__PURE__ */ C("div", { className: "md-mermaid-error", children: [
|
|
532
|
+
/* @__PURE__ */ e("span", { children: "渲染失败: " }),
|
|
533
|
+
/* @__PURE__ */ e("span", { children: r.error })
|
|
534
|
+
] })
|
|
535
|
+
] })
|
|
536
|
+
) }),
|
|
537
|
+
M && (r == null ? void 0 : r.svg) && /* @__PURE__ */ e(
|
|
538
|
+
se,
|
|
539
|
+
{
|
|
540
|
+
svg: r.svg,
|
|
541
|
+
open: d,
|
|
542
|
+
onClose: () => v(!1),
|
|
543
|
+
onDownload: m
|
|
544
|
+
}
|
|
545
|
+
)
|
|
546
|
+
] });
|
|
547
|
+
};
|
|
548
|
+
oe.displayName = "MermaidBlock";
|
|
549
|
+
function Ve(t) {
|
|
550
|
+
const n = t.children;
|
|
551
|
+
if (!U.isValidElement(n)) return !1;
|
|
552
|
+
const c = n.props, l = c == null ? void 0 : c.className;
|
|
553
|
+
return typeof l == "string" ? l.includes("language-mermaid") : !1;
|
|
554
|
+
}
|
|
555
|
+
function Re(t) {
|
|
556
|
+
if (!U.isValidElement(t)) return "";
|
|
557
|
+
const n = t.props, c = n == null ? void 0 : n.children;
|
|
558
|
+
return typeof c == "string" ? c : Array.isArray(c) ? c.map((l) => typeof l == "string" ? l : "").join("") : "";
|
|
559
|
+
}
|
|
560
|
+
function Be(t) {
|
|
561
|
+
return t ? t === !0 ? { enabled: !0 } : t.enabled !== !1 ? t : null : null;
|
|
562
|
+
}
|
|
563
|
+
const Te = ({
|
|
564
|
+
children: t,
|
|
565
|
+
components: n,
|
|
566
|
+
className: c,
|
|
567
|
+
copyButton: l = !0,
|
|
568
|
+
onCodeCopy: a,
|
|
569
|
+
mermaid: i,
|
|
570
|
+
...o
|
|
571
|
+
}) => {
|
|
572
|
+
const r = Be(i), b = O(() => {
|
|
573
|
+
if (!t) return null;
|
|
574
|
+
const u = J(t, o), d = {
|
|
575
|
+
pre: (v) => {
|
|
576
|
+
if (r && Ve(v)) {
|
|
577
|
+
const h = Re(v.children);
|
|
578
|
+
return /* @__PURE__ */ e(
|
|
579
|
+
oe,
|
|
580
|
+
{
|
|
581
|
+
code: h,
|
|
582
|
+
theme: r.theme,
|
|
583
|
+
onCopy: a
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
return l ? /* @__PURE__ */ e(K, { showCopyButton: l, onCopy: a, ...v }) : /* @__PURE__ */ e("pre", { ...v });
|
|
588
|
+
},
|
|
589
|
+
...n
|
|
590
|
+
};
|
|
591
|
+
return W(u, {
|
|
592
|
+
Fragment: H,
|
|
593
|
+
jsx: e,
|
|
594
|
+
jsxs: C,
|
|
595
|
+
components: d
|
|
71
596
|
});
|
|
72
|
-
}, [
|
|
73
|
-
return /* @__PURE__ */
|
|
597
|
+
}, [t, n, l, a, r, o]);
|
|
598
|
+
return /* @__PURE__ */ e("div", { className: c, children: b });
|
|
74
599
|
};
|
|
75
|
-
|
|
76
|
-
function
|
|
77
|
-
const { components:
|
|
78
|
-
return
|
|
79
|
-
if (!
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
Fragment:
|
|
83
|
-
jsx:
|
|
84
|
-
jsxs:
|
|
85
|
-
components:
|
|
600
|
+
Te.displayName = "Markdown";
|
|
601
|
+
function We(t, n = {}) {
|
|
602
|
+
const { components: c = {}, ...l } = n;
|
|
603
|
+
return O(() => {
|
|
604
|
+
if (!t) return null;
|
|
605
|
+
const a = J(t, l);
|
|
606
|
+
return W(a, {
|
|
607
|
+
Fragment: H,
|
|
608
|
+
jsx: e,
|
|
609
|
+
jsxs: C,
|
|
610
|
+
components: c
|
|
86
611
|
});
|
|
87
|
-
}, [
|
|
612
|
+
}, [t, c, l]);
|
|
88
613
|
}
|
|
89
|
-
const
|
|
90
|
-
({ block:
|
|
91
|
-
if (!
|
|
614
|
+
const le = P(
|
|
615
|
+
({ block: t, components: n }) => {
|
|
616
|
+
if (!t.hast) return null;
|
|
92
617
|
try {
|
|
93
|
-
return
|
|
94
|
-
jsx:
|
|
95
|
-
jsxs:
|
|
96
|
-
Fragment:
|
|
97
|
-
components:
|
|
618
|
+
return W(t.hast, {
|
|
619
|
+
jsx: e,
|
|
620
|
+
jsxs: C,
|
|
621
|
+
Fragment: H,
|
|
622
|
+
components: n
|
|
98
623
|
});
|
|
99
624
|
} catch {
|
|
100
625
|
return null;
|
|
101
626
|
}
|
|
102
627
|
},
|
|
103
|
-
(
|
|
628
|
+
(t, n) => t.block.key === n.block.key && t.block.stable && n.block.stable
|
|
104
629
|
);
|
|
105
|
-
|
|
106
|
-
function
|
|
630
|
+
le.displayName = "StableBlock";
|
|
631
|
+
function _e(t = {}) {
|
|
107
632
|
const {
|
|
108
|
-
components:
|
|
109
|
-
minUpdateInterval:
|
|
110
|
-
immediate:
|
|
111
|
-
outputRate:
|
|
112
|
-
...
|
|
113
|
-
} =
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
633
|
+
components: n,
|
|
634
|
+
minUpdateInterval: c = 16,
|
|
635
|
+
immediate: l = !1,
|
|
636
|
+
outputRate: a = "medium",
|
|
637
|
+
...i
|
|
638
|
+
} = t, o = k(Q(i)), r = k(new ee(a)), [b, u] = E(0), [f, d] = E(!1), [v, h] = E(0), [g, x] = E("idle"), V = k(0), y = k(null), I = p(() => {
|
|
639
|
+
const R = performance.now(), $ = R - V.current;
|
|
640
|
+
l || $ >= c ? (V.current = R, u((_) => _ + 1)) : y.current === null && (y.current = window.requestAnimationFrame(() => {
|
|
641
|
+
y.current = null, V.current = performance.now(), u((_) => _ + 1);
|
|
117
642
|
}));
|
|
118
|
-
}, [
|
|
119
|
-
(
|
|
120
|
-
|
|
643
|
+
}, [c, l]), B = p(
|
|
644
|
+
(R) => {
|
|
645
|
+
o.current.append(R), I();
|
|
121
646
|
},
|
|
122
|
-
[
|
|
123
|
-
),
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(
|
|
128
|
-
|
|
647
|
+
[I]
|
|
648
|
+
), T = p(
|
|
649
|
+
(R) => {
|
|
650
|
+
o.current.reset(), d(!1), h(0), x("running"), r.current.start(
|
|
651
|
+
R,
|
|
652
|
+
($) => {
|
|
653
|
+
$ && o.current.append($), h(r.current.progress), I();
|
|
129
654
|
},
|
|
130
655
|
() => {
|
|
131
|
-
|
|
656
|
+
o.current.finish(), d(!0), h(1), x("complete"), I();
|
|
132
657
|
}
|
|
133
658
|
);
|
|
134
659
|
},
|
|
135
|
-
[
|
|
136
|
-
),
|
|
137
|
-
|
|
138
|
-
}, []),
|
|
139
|
-
|
|
140
|
-
}, []),
|
|
141
|
-
|
|
142
|
-
}, []),
|
|
143
|
-
|
|
144
|
-
}, []),
|
|
145
|
-
|
|
660
|
+
[I]
|
|
661
|
+
), s = p(() => {
|
|
662
|
+
r.current.pause(), x(r.current.status);
|
|
663
|
+
}, []), w = p(() => {
|
|
664
|
+
r.current.resume(), x(r.current.status);
|
|
665
|
+
}, []), L = p(() => {
|
|
666
|
+
r.current.skipToEnd(), x(r.current.status), h(1);
|
|
667
|
+
}, []), D = p(() => {
|
|
668
|
+
r.current.stop(), o.current.finish(), d(!0), x("complete"), y.current !== null && (cancelAnimationFrame(y.current), y.current = null), u((R) => R + 1);
|
|
669
|
+
}, []), F = p(() => {
|
|
670
|
+
r.current.stop(), o.current.reset(), d(!1), h(0), x("idle"), y.current !== null && (cancelAnimationFrame(y.current), y.current = null), u((R) => R + 1);
|
|
146
671
|
}, []);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, [
|
|
150
|
-
|
|
672
|
+
z(() => {
|
|
673
|
+
r.current.setRate(a);
|
|
674
|
+
}, [a]), z(() => () => {
|
|
675
|
+
r.current.stop(), y.current !== null && cancelAnimationFrame(y.current);
|
|
151
676
|
}, []);
|
|
152
|
-
const
|
|
153
|
-
(
|
|
154
|
-
|
|
677
|
+
const m = o.current.getState(), N = o.current.getStats(), M = o.current.getContent(), S = O(() => m.blocks.map(
|
|
678
|
+
(R) => e(
|
|
679
|
+
le,
|
|
155
680
|
{
|
|
156
|
-
block:
|
|
157
|
-
components:
|
|
681
|
+
block: R,
|
|
682
|
+
components: n
|
|
158
683
|
},
|
|
159
|
-
|
|
684
|
+
R.key
|
|
160
685
|
)
|
|
161
|
-
), [
|
|
686
|
+
), [m.blocks, n, b]);
|
|
162
687
|
return {
|
|
163
|
-
element:
|
|
688
|
+
element: O(() => m.blocks.length === 0 ? null : e(H, { children: S }), [S, m.blocks.length]),
|
|
164
689
|
append: B,
|
|
165
|
-
start:
|
|
166
|
-
pause:
|
|
167
|
-
resume:
|
|
168
|
-
skipToEnd:
|
|
169
|
-
reset:
|
|
170
|
-
finish:
|
|
171
|
-
blocks:
|
|
172
|
-
stats:
|
|
173
|
-
isComplete:
|
|
174
|
-
content:
|
|
175
|
-
progress:
|
|
690
|
+
start: T,
|
|
691
|
+
pause: s,
|
|
692
|
+
resume: w,
|
|
693
|
+
skipToEnd: L,
|
|
694
|
+
reset: F,
|
|
695
|
+
finish: D,
|
|
696
|
+
blocks: m.blocks,
|
|
697
|
+
stats: N,
|
|
698
|
+
isComplete: f,
|
|
699
|
+
content: M,
|
|
700
|
+
progress: v,
|
|
176
701
|
outputStatus: g
|
|
177
702
|
};
|
|
178
703
|
}
|
|
179
|
-
const
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
] }),
|
|
184
|
-
src:
|
|
185
|
-
alt:
|
|
186
|
-
className:
|
|
187
|
-
"data-width":
|
|
188
|
-
"data-height":
|
|
189
|
-
...
|
|
704
|
+
const De = 16, Fe = "data:image/svg+xml,", He = () => /* @__PURE__ */ C("svg", { width: "48", height: "36", viewBox: "0 0 48 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
705
|
+
/* @__PURE__ */ e("rect", { x: "0", y: "0", width: "48", height: "36", rx: "3", className: "md-image-skeleton-icon" }),
|
|
706
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "10", r: "5", className: "md-image-skeleton-icon-detail" }),
|
|
707
|
+
/* @__PURE__ */ e("path", { d: "M0 36 L0 24 L16 16 L28 26 L48 12 L48 36 Z", className: "md-image-skeleton-icon-detail" })
|
|
708
|
+
] }), ie = P(({
|
|
709
|
+
src: t,
|
|
710
|
+
alt: n,
|
|
711
|
+
className: c,
|
|
712
|
+
"data-width": l,
|
|
713
|
+
"data-height": a,
|
|
714
|
+
...i
|
|
190
715
|
}) => {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}, [
|
|
195
|
-
const g =
|
|
716
|
+
const r = (t == null ? void 0 : t.startsWith(Fe)) ? void 0 : t, b = l ? Number(l) : 200, u = a ? Number(a) : 120, [f, d] = E(!0), v = k(null), h = k(null);
|
|
717
|
+
me(() => {
|
|
718
|
+
v.current && r && v.current.complete && v.current.naturalWidth > 0 && d(!1);
|
|
719
|
+
}, [r]);
|
|
720
|
+
const g = p(() => {
|
|
196
721
|
h.current && clearTimeout(h.current), h.current = setTimeout(() => {
|
|
197
|
-
|
|
198
|
-
},
|
|
722
|
+
d(!1);
|
|
723
|
+
}, De);
|
|
199
724
|
}, []);
|
|
200
|
-
return /* @__PURE__ */
|
|
725
|
+
return /* @__PURE__ */ C(
|
|
201
726
|
"span",
|
|
202
727
|
{
|
|
203
|
-
className: `md-image-container ${
|
|
204
|
-
style: { width:
|
|
728
|
+
className: `md-image-container ${c || ""}`,
|
|
729
|
+
style: { width: b, height: u },
|
|
205
730
|
children: [
|
|
206
|
-
|
|
731
|
+
r && /* @__PURE__ */ e(
|
|
207
732
|
"img",
|
|
208
733
|
{
|
|
209
|
-
ref:
|
|
210
|
-
src:
|
|
211
|
-
alt:
|
|
734
|
+
ref: v,
|
|
735
|
+
src: r,
|
|
736
|
+
alt: n,
|
|
212
737
|
onLoad: g,
|
|
213
738
|
className: "md-image",
|
|
214
|
-
...
|
|
739
|
+
...i
|
|
215
740
|
}
|
|
216
741
|
),
|
|
217
|
-
|
|
742
|
+
f && /* @__PURE__ */ e("span", { className: "md-image-skeleton", children: /* @__PURE__ */ e(He, {}) })
|
|
218
743
|
]
|
|
219
744
|
}
|
|
220
745
|
);
|
|
221
746
|
});
|
|
222
|
-
|
|
223
|
-
let q = !1,
|
|
224
|
-
async function
|
|
747
|
+
ie.displayName = "StreamingImage";
|
|
748
|
+
let q = !1, Y = null;
|
|
749
|
+
async function ue() {
|
|
225
750
|
if (!q)
|
|
226
|
-
return
|
|
751
|
+
return Y || (Y = (async () => {
|
|
227
752
|
await import("katex/dist/katex.min.css"), q = !0;
|
|
228
|
-
})(),
|
|
753
|
+
})(), Y);
|
|
229
754
|
}
|
|
230
|
-
const
|
|
231
|
-
q ||
|
|
232
|
-
}, []), /* @__PURE__ */
|
|
233
|
-
|
|
234
|
-
function
|
|
235
|
-
return
|
|
755
|
+
const Ae = P(({ children: t }) => (z(() => {
|
|
756
|
+
q || ue();
|
|
757
|
+
}, []), /* @__PURE__ */ e(H, { children: t })));
|
|
758
|
+
Ae.displayName = "MathProvider";
|
|
759
|
+
function $e() {
|
|
760
|
+
return ue();
|
|
236
761
|
}
|
|
237
|
-
const
|
|
238
|
-
({ block:
|
|
239
|
-
if (!
|
|
762
|
+
const de = P(
|
|
763
|
+
({ block: t, components: n }) => {
|
|
764
|
+
if (!t.hast) return null;
|
|
240
765
|
try {
|
|
241
|
-
return
|
|
242
|
-
jsx:
|
|
243
|
-
jsxs:
|
|
244
|
-
Fragment:
|
|
245
|
-
components:
|
|
766
|
+
return W(t.hast, {
|
|
767
|
+
jsx: e,
|
|
768
|
+
jsxs: C,
|
|
769
|
+
Fragment: H,
|
|
770
|
+
components: n
|
|
246
771
|
});
|
|
247
772
|
} catch {
|
|
248
|
-
return /* @__PURE__ */
|
|
773
|
+
return /* @__PURE__ */ e("div", { className: "parse-error", children: t.source });
|
|
249
774
|
}
|
|
250
775
|
},
|
|
251
|
-
(
|
|
776
|
+
(t, n) => t.block.key === n.block.key && t.block.stable && n.block.stable
|
|
252
777
|
);
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
content:
|
|
256
|
-
source:
|
|
257
|
-
outputRate:
|
|
258
|
-
isComplete:
|
|
259
|
-
onComplete:
|
|
260
|
-
onBlockStable:
|
|
261
|
-
onProgress:
|
|
262
|
-
components:
|
|
263
|
-
className:
|
|
264
|
-
minUpdateInterval:
|
|
265
|
-
autoStart:
|
|
266
|
-
copyButton:
|
|
267
|
-
onCodeCopy:
|
|
778
|
+
de.displayName = "StableBlock";
|
|
779
|
+
const Oe = ({
|
|
780
|
+
content: t,
|
|
781
|
+
source: n,
|
|
782
|
+
outputRate: c = "medium",
|
|
783
|
+
isComplete: l = !1,
|
|
784
|
+
onComplete: a,
|
|
785
|
+
onBlockStable: i,
|
|
786
|
+
onProgress: o,
|
|
787
|
+
components: r,
|
|
788
|
+
className: b,
|
|
789
|
+
minUpdateInterval: u = 16,
|
|
790
|
+
autoStart: f = !0,
|
|
791
|
+
copyButton: d = !0,
|
|
792
|
+
onCodeCopy: v,
|
|
268
793
|
...h
|
|
269
794
|
}) => {
|
|
270
|
-
|
|
271
|
-
h.math &&
|
|
795
|
+
z(() => {
|
|
796
|
+
h.math && $e();
|
|
272
797
|
}, [h.math]);
|
|
273
|
-
const g =
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
798
|
+
const g = k(Q(h)), x = k(new ee(c)), V = k(""), y = k(void 0), I = k([]), [, B] = U.useReducer((m) => m + 1, 0), T = k(0), s = k(null), w = () => {
|
|
799
|
+
const m = performance.now();
|
|
800
|
+
m - T.current >= u ? (T.current = m, B()) : s.current === null && (s.current = window.requestAnimationFrame(() => {
|
|
801
|
+
s.current = null, T.current = performance.now(), B();
|
|
277
802
|
}));
|
|
278
803
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(
|
|
283
|
-
|
|
804
|
+
z(() => {
|
|
805
|
+
n !== void 0 && n !== y.current && (y.current = n, f && n && (g.current.reset(), V.current = "", x.current.start(
|
|
806
|
+
n,
|
|
807
|
+
(m) => {
|
|
808
|
+
m && (g.current.append(m), V.current += m), o == null || o(x.current.progress), w();
|
|
284
809
|
},
|
|
285
810
|
() => {
|
|
286
|
-
g.current.finish(),
|
|
811
|
+
g.current.finish(), a == null || a(), w();
|
|
287
812
|
}
|
|
288
813
|
)));
|
|
289
|
-
}, [
|
|
290
|
-
if (
|
|
814
|
+
}, [n, f, a, o]), z(() => {
|
|
815
|
+
if (n !== void 0)
|
|
291
816
|
return;
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
if (
|
|
295
|
-
const
|
|
296
|
-
|
|
817
|
+
const m = V.current, N = t || "";
|
|
818
|
+
if (N !== m) {
|
|
819
|
+
if (N.startsWith(m)) {
|
|
820
|
+
const M = N.slice(m.length);
|
|
821
|
+
M && g.current.append(M);
|
|
297
822
|
} else
|
|
298
|
-
g.current.reset(),
|
|
299
|
-
|
|
823
|
+
g.current.reset(), N && g.current.append(N);
|
|
824
|
+
V.current = N, w();
|
|
300
825
|
}
|
|
301
|
-
}, [
|
|
302
|
-
|
|
303
|
-
}, [
|
|
304
|
-
|
|
305
|
-
}, [
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
}),
|
|
826
|
+
}, [t, n]), z(() => {
|
|
827
|
+
n === void 0 && l && (g.current.finish(), s.current !== null && (cancelAnimationFrame(s.current), s.current = null), B(), a == null || a());
|
|
828
|
+
}, [l, a, n]), z(() => {
|
|
829
|
+
x.current.setRate(c);
|
|
830
|
+
}, [c]), z(() => {
|
|
831
|
+
if (i) {
|
|
832
|
+
const m = g.current.getState().blocks, N = I.current;
|
|
833
|
+
m.forEach((M, S) => {
|
|
834
|
+
const A = N[S];
|
|
835
|
+
M.stable && (!A || !A.stable) && i(M);
|
|
836
|
+
}), I.current = m;
|
|
312
837
|
}
|
|
313
|
-
}),
|
|
314
|
-
|
|
838
|
+
}), z(() => () => {
|
|
839
|
+
x.current.stop(), s.current !== null && cancelAnimationFrame(s.current);
|
|
315
840
|
}, []);
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
if (
|
|
319
|
-
return (
|
|
320
|
-
|
|
841
|
+
const L = g.current.getState(), D = n !== void 0 ? x.current.status === "complete" : l, F = O(() => {
|
|
842
|
+
const m = (N) => {
|
|
843
|
+
if (d)
|
|
844
|
+
return (M) => /* @__PURE__ */ e(
|
|
845
|
+
K,
|
|
321
846
|
{
|
|
322
|
-
showCopyButton:
|
|
323
|
-
onCopy:
|
|
324
|
-
...
|
|
847
|
+
showCopyButton: N.stable && d,
|
|
848
|
+
onCopy: v,
|
|
849
|
+
...M
|
|
325
850
|
}
|
|
326
851
|
);
|
|
327
852
|
};
|
|
328
|
-
return
|
|
329
|
-
const
|
|
330
|
-
img:
|
|
331
|
-
...
|
|
332
|
-
...
|
|
853
|
+
return L.blocks.map((N) => {
|
|
854
|
+
const M = m(N), S = {
|
|
855
|
+
img: ie,
|
|
856
|
+
...M ? { pre: M } : {},
|
|
857
|
+
...r
|
|
333
858
|
};
|
|
334
|
-
return /* @__PURE__ */
|
|
335
|
-
|
|
859
|
+
return /* @__PURE__ */ e(
|
|
860
|
+
de,
|
|
336
861
|
{
|
|
337
|
-
block:
|
|
338
|
-
components:
|
|
862
|
+
block: N,
|
|
863
|
+
components: S
|
|
339
864
|
},
|
|
340
|
-
|
|
865
|
+
N.key
|
|
341
866
|
);
|
|
342
867
|
});
|
|
343
|
-
}, [
|
|
344
|
-
return /* @__PURE__ */
|
|
868
|
+
}, [L.blocks, r, d, v]);
|
|
869
|
+
return /* @__PURE__ */ e("div", { className: b, "data-streaming": !D, children: F });
|
|
345
870
|
};
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
const { text:
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
if (!(
|
|
352
|
-
|
|
871
|
+
Oe.displayName = "StreamingMarkdown";
|
|
872
|
+
const Pe = P((t) => {
|
|
873
|
+
const { text: n, animationConfig: c } = t, { fadeDuration: l = 200, easing: a = "ease-in-out" } = c || {}, [i, o] = E([]), r = k("");
|
|
874
|
+
z(() => {
|
|
875
|
+
if (n === r.current) return;
|
|
876
|
+
if (!(r.current && n.indexOf(r.current) === 0)) {
|
|
877
|
+
o([n]), r.current = n;
|
|
353
878
|
return;
|
|
354
879
|
}
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
}, [
|
|
358
|
-
const
|
|
359
|
-
return /* @__PURE__ */
|
|
880
|
+
const u = n.slice(r.current.length);
|
|
881
|
+
u && (o((f) => [...f, u]), r.current = n);
|
|
882
|
+
}, [n]);
|
|
883
|
+
const b = `md-fade-in ${l}ms ${a} forwards`;
|
|
884
|
+
return /* @__PURE__ */ e(H, { children: i.map((u, f) => /* @__PURE__ */ e(
|
|
360
885
|
"span",
|
|
361
886
|
{
|
|
362
887
|
className: "md-animation-text",
|
|
363
|
-
style: { animation:
|
|
364
|
-
children:
|
|
888
|
+
style: { animation: b },
|
|
889
|
+
children: u
|
|
365
890
|
},
|
|
366
|
-
`animation-text-${
|
|
891
|
+
`animation-text-${f}`
|
|
367
892
|
)) });
|
|
368
893
|
});
|
|
369
|
-
|
|
370
|
-
let
|
|
894
|
+
Pe.displayName = "AnimationText";
|
|
895
|
+
let X = null;
|
|
371
896
|
try {
|
|
372
|
-
|
|
897
|
+
X = require("dompurify");
|
|
373
898
|
} catch {
|
|
374
899
|
}
|
|
375
|
-
function
|
|
376
|
-
return
|
|
900
|
+
function je() {
|
|
901
|
+
return X !== null;
|
|
377
902
|
}
|
|
378
|
-
function
|
|
379
|
-
if (
|
|
380
|
-
return
|
|
381
|
-
const
|
|
903
|
+
function qe(t, n) {
|
|
904
|
+
if (!X)
|
|
905
|
+
return t;
|
|
906
|
+
const c = {
|
|
382
907
|
ADD_ATTR: ["target", "rel", "data-block-key", "data-pending", "data-predicted"],
|
|
383
|
-
...
|
|
908
|
+
...n
|
|
384
909
|
};
|
|
385
|
-
return
|
|
910
|
+
return X.default.sanitize(t, c);
|
|
386
911
|
}
|
|
387
|
-
function
|
|
388
|
-
if (
|
|
912
|
+
function G(t) {
|
|
913
|
+
if (t.type === "root")
|
|
389
914
|
return {
|
|
390
|
-
...
|
|
915
|
+
...t,
|
|
391
916
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
|
-
children:
|
|
917
|
+
children: t.children.map((a) => a.type === "element" ? G(a) : a)
|
|
393
918
|
};
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
for (const [
|
|
397
|
-
const
|
|
398
|
-
if (!(
|
|
399
|
-
if ((
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
919
|
+
const n = ["onclick", "onerror", "onload", "onmouseover", "onfocus", "onblur"], c = ["javascript:", "vbscript:", "data:text/html"], l = {};
|
|
920
|
+
if (t.properties)
|
|
921
|
+
for (const [a, i] of Object.entries(t.properties)) {
|
|
922
|
+
const o = a.toLowerCase();
|
|
923
|
+
if (!(n.includes(o) || o.startsWith("on"))) {
|
|
924
|
+
if ((o === "href" || o === "src") && typeof i == "string") {
|
|
925
|
+
const r = i.toLowerCase().trim();
|
|
926
|
+
if (c.some((b) => r.startsWith(b)))
|
|
402
927
|
continue;
|
|
403
928
|
}
|
|
404
|
-
|
|
929
|
+
l[a] = i;
|
|
405
930
|
}
|
|
406
931
|
}
|
|
407
932
|
return {
|
|
408
|
-
...
|
|
409
|
-
properties:
|
|
933
|
+
...t,
|
|
934
|
+
properties: l,
|
|
410
935
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
-
children:
|
|
936
|
+
children: t.children.map((a) => a.type === "element" ? G(a) : a)
|
|
412
937
|
};
|
|
413
938
|
}
|
|
414
939
|
export {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
940
|
+
Pe as AnimationText,
|
|
941
|
+
K as CodeBlock,
|
|
942
|
+
Te as Markdown,
|
|
943
|
+
oe as MermaidBlock,
|
|
944
|
+
se as MermaidFullscreenViewer,
|
|
945
|
+
ie as StreamingImage,
|
|
946
|
+
Oe as StreamingMarkdown,
|
|
947
|
+
je as isDOMPurifyAvailable,
|
|
948
|
+
G as sanitizeHast,
|
|
949
|
+
qe as sanitizeHtml,
|
|
950
|
+
We as useMarkdown,
|
|
951
|
+
_e as useStreamingMarkdown,
|
|
952
|
+
te as useZoom
|
|
425
953
|
};
|