react-docs-ui 0.7.5 → 0.8.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/AIChatDialog-C2mEAX2T.js +407 -0
- package/dist/{AISelectionTrigger-SLyb8Vep.js → AISelectionTrigger-CWTJRvHo.js} +1 -1
- package/dist/{AISettingsPanel-Bsd_wLP4.js → AISettingsPanel-C9Bb_QtE.js} +1 -1
- package/dist/{DocsApp-B-VaP4ms.js → DocsApp-CTh7Pa9A.js} +3867 -3616
- package/dist/{GlobalContextMenu-BtVjQk0v.js → GlobalContextMenu-DAIKsl1l.js} +1 -1
- package/dist/{MdxContent-CZLqZlNp.js → MdxContent-BAm4izu3.js} +305 -317
- package/dist/{MdxContent.lazy-i9phqEH3.js → MdxContent.lazy-vS9NrZj4.js} +1 -1
- package/dist/{SearchDialog-DWVre6R9.js → SearchDialog-CLbtpf7I.js} +172 -127
- package/dist/{SearchRuntime-D0rSMKV3.js → SearchRuntime--tjedqS6.js} +5 -4
- package/dist/{architectureDiagram-2XIMDMQ5-DmhcSwl7.js → architectureDiagram-2XIMDMQ5-D5B3Bc8w.js} +1 -1
- package/dist/{chunk-GLR3WWYH-ShSppUzV.js → chunk-GLR3WWYH-C7t8eN-i.js} +1 -1
- package/dist/{chunk-NQ4KR5QH-BWRGvKed.js → chunk-NQ4KR5QH-ygKrPhgw.js} +1 -1
- package/dist/{chunk-WL4C6EOR-DLbU3P3W.js → chunk-WL4C6EOR-BX4P121X.js} +1 -1
- package/dist/{classDiagram-VBA2DB6C-D4y64v83.js → classDiagram-VBA2DB6C-CWWKW2ZN.js} +2 -2
- package/dist/{classDiagram-v2-RAHNMMFH-DXkt0Wd4.js → classDiagram-v2-RAHNMMFH-9SKKaVzh.js} +2 -2
- package/dist/{context-menu-BIQsQup7.js → context-menu-DwILPvwC.js} +1 -1
- package/dist/{cose-bilkent-S5V4N54A-BX63fiTJ.js → cose-bilkent-S5V4N54A-DCXUWrka.js} +1 -1
- package/dist/{dialog-D8otbqQL.js → dialog-D68sEJBe.js} +1 -1
- package/dist/docs-app.es.js +1 -1
- package/dist/{erDiagram-INFDFZHY-DjNq2UqZ.js → erDiagram-INFDFZHY-DdivnAXH.js} +1 -1
- package/dist/{flowDiagram-PKNHOUZH-AUeVhXRc.js → flowDiagram-PKNHOUZH-CgCGjn11.js} +1 -1
- package/dist/{mdx-components-m1cGPhc8.js → mdx-components-6beJPZgM.js} +3 -3
- package/dist/{mermaid.core-CtkJeRVj.js → mermaid.core-Dg_svxvF.js} +12 -12
- package/dist/{mindmap-definition-YRQLILUH-Cnl-qPDR.js → mindmap-definition-YRQLILUH-3st_5tCe.js} +1 -1
- package/dist/react-docs-ui.css +1 -1
- package/dist/react-docs-ui.es.js +10 -10
- package/dist/{requirementDiagram-Z7DCOOCP-Bx6NAgqy.js → requirementDiagram-Z7DCOOCP-ClKKAQ0C.js} +1 -1
- package/dist/{stateDiagram-RAJIS63D-DFmbSHPX.js → stateDiagram-RAJIS63D-C8Ab__vp.js} +2 -2
- package/dist/{stateDiagram-v2-FVOUBMTO-TjYtTjLB.js → stateDiagram-v2-FVOUBMTO-BhQBkYI5.js} +2 -2
- package/dist/types/components/Breadcrumb.d.ts +14 -0
- package/dist/types/components/Breadcrumb.d.ts.map +1 -0
- package/dist/types/components/DocsLayout.d.ts.map +1 -1
- package/dist/types/components/ExportToolbar.d.ts +8 -1
- package/dist/types/components/ExportToolbar.d.ts.map +1 -1
- package/dist/types/components/HeaderNav.d.ts.map +1 -1
- package/dist/types/components/MdxContent.d.ts.map +1 -1
- package/dist/types/components/MobileSidebar.d.ts +2 -7
- package/dist/types/components/MobileSidebar.d.ts.map +1 -1
- package/dist/types/components/ReadingProgressBar.d.ts +4 -0
- package/dist/types/components/ReadingProgressBar.d.ts.map +1 -0
- package/dist/types/components/ReleaseMetaBar.d.ts +1 -1
- package/dist/types/components/ReleaseMetaBar.d.ts.map +1 -1
- package/dist/types/components/SearchLauncher.d.ts +2 -1
- package/dist/types/components/SearchLauncher.d.ts.map +1 -1
- package/dist/types/components/ai/AIChatMessage.d.ts.map +1 -1
- package/dist/types/components/search/SearchItem.d.ts.map +1 -1
- package/dist/types/components/search/SearchProvider.d.ts +2 -1
- package/dist/types/components/search/SearchProvider.d.ts.map +1 -1
- package/dist/types/components/search/SearchRuntime.d.ts +2 -1
- package/dist/types/components/search/SearchRuntime.d.ts.map +1 -1
- package/dist/types/hooks/useScrollPosition.d.ts.map +1 -1
- package/dist/types/lib/changelog.d.ts +1 -1
- package/dist/types/lib/changelog.d.ts.map +1 -1
- package/dist/types/lib/config.d.ts +21 -0
- package/dist/types/lib/config.d.ts.map +1 -1
- package/dist/types/lib/reading-time.d.ts +7 -0
- package/dist/types/lib/reading-time.d.ts.map +1 -0
- package/dist/types/lib/search/index.d.ts +2 -1
- package/dist/types/lib/search/index.d.ts.map +1 -1
- package/dist/types/lib/search/runtime/highlighter.d.ts +10 -0
- package/dist/types/lib/search/runtime/highlighter.d.ts.map +1 -1
- package/dist/types/lib/search/runtime/search-engine.d.ts.map +1 -1
- package/dist/types/lib/search/runtime/types.d.ts +1 -0
- package/dist/types/lib/search/runtime/types.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/utils-KFBtT4Mx.js +25 -0
- package/package.json +16 -5
- package/scripts/cli.mjs +20 -0
- package/scripts/generate-changelog-index.mjs +89 -0
- package/scripts/generate-doc-git-meta.mjs +63 -0
- package/scripts/generate-feed.mjs +122 -0
- package/scripts/generate-llms-files.mjs +34 -0
- package/scripts/generate-search-index.mjs +236 -0
- package/scripts/generate-shiki-bundle.mjs +80 -0
- package/scripts/generate-sitemap.mjs +186 -0
- package/dist/AIChatDialog-BnAX3dRn.js +0 -418
- package/dist/utils-Ct96Mtjw.js +0 -8
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as
|
|
3
|
-
import { t as
|
|
4
|
-
import { l as
|
|
5
|
-
import * as
|
|
6
|
-
import { Check as
|
|
7
|
-
import { Link as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import { n as e, r as t, t as n } from "./utils-KFBtT4Mx.js";
|
|
2
|
+
import { S as r, b as i, c as a, d as o, h as s, l as c, p as l, s as u, t as d, v as f, x as p, y as m } from "./mdx-components-6beJPZgM.js";
|
|
3
|
+
import { t as h } from "./use-toast-DK69oadB.js";
|
|
4
|
+
import { l as g, r as _, t as v, u as y } from "./dialog-D68sEJBe.js";
|
|
5
|
+
import * as b from "react";
|
|
6
|
+
import { Check as ee, Copy as x, Download as te, ExternalLink as S, Maximize as ne, Minimize as re, RefreshCw as ie, RotateCcw as ae, RotateCw as oe, Search as se, X as ce, ZoomIn as le, ZoomOut as ue } from "lucide-react";
|
|
7
|
+
import { Link as C, useParams as w } from "react-router-dom";
|
|
8
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
9
|
+
import O from "remark-gfm";
|
|
10
|
+
import k from "remark-math";
|
|
11
|
+
import de from "react-markdown";
|
|
12
12
|
import A from "rehype-autolink-headings";
|
|
13
13
|
import j from "rehype-slug";
|
|
14
14
|
import M from "rehype-raw";
|
|
@@ -73,7 +73,7 @@ var R = {
|
|
|
73
73
|
imageLoadError: "Failed to load image"
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function fe(e = "zh-cn", t) {
|
|
77
77
|
return {
|
|
78
78
|
...R[e === "en" ? "en" : "zh-cn"],
|
|
79
79
|
...t
|
|
@@ -81,19 +81,19 @@ function ue(e = "zh-cn", t) {
|
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/components/ImageViewer.tsx
|
|
84
|
-
var
|
|
84
|
+
var pe = .2, me = 5, he = .2;
|
|
85
85
|
function z(e) {
|
|
86
|
-
return Math.min(
|
|
86
|
+
return Math.min(me, Math.max(pe, Number(e.toFixed(2))));
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function ge(e, t, n) {
|
|
89
89
|
let r = (t || n || "image").trim().split("").map((e) => e.charCodeAt(0) < 32 || "<>:\"/\\|?*".includes(e) ? "-" : e).join("");
|
|
90
90
|
return (e.split("?")[0]?.split("#")[0] ?? e).split("/").pop()?.trim() || r || "image";
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function _e(e, t) {
|
|
93
93
|
let n = document.createElement("a");
|
|
94
94
|
n.href = e, n.download = t, n.rel = "noopener noreferrer", document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function ve(e) {
|
|
97
97
|
if (e.startsWith("blob:") || e.startsWith("data:")) return !0;
|
|
98
98
|
try {
|
|
99
99
|
return new URL(e, window.location.href).origin === window.location.origin;
|
|
@@ -101,66 +101,66 @@ function ge(e) {
|
|
|
101
101
|
return !1;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function B({ open:
|
|
105
|
-
let
|
|
104
|
+
function B({ open: e, onOpenChange: t, src: a, alt: o, title: s, lang: c = "zh-cn", labels: l }) {
|
|
105
|
+
let u = b.useMemo(() => fe(c, l), [c, l]), d = b.useRef(null), ee = b.useRef(null), [x, C] = b.useState(1), [w, T] = b.useState(0), [O, k] = b.useState("fit"), [de, A] = b.useState(!1), [j, M] = b.useState(!1), [N, P] = b.useState({
|
|
106
106
|
x: 0,
|
|
107
107
|
y: 0
|
|
108
|
-
}), [
|
|
109
|
-
|
|
108
|
+
}), [F, I] = b.useState(!1), L = b.useRef(/* @__PURE__ */ new Map()), R = b.useRef(null), B = b.useRef(null), V = o?.trim() || s?.trim() || u.imageAltFallback, H = b.useCallback(() => {
|
|
109
|
+
C(1), T(0), k("fit"), M(!1), P({
|
|
110
110
|
x: 0,
|
|
111
111
|
y: 0
|
|
112
|
-
}),
|
|
112
|
+
}), I(!1), L.current.clear(), R.current = null, B.current = null;
|
|
113
113
|
}, []);
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
|
|
114
|
+
b.useEffect(() => {
|
|
115
|
+
if (e) {
|
|
116
|
+
H();
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
}, [
|
|
121
|
-
document.fullscreenElement ||
|
|
122
|
-
}, [
|
|
119
|
+
A(!1);
|
|
120
|
+
}, [e, H]), b.useEffect(() => {
|
|
121
|
+
document.fullscreenElement || A(!1);
|
|
122
|
+
}, [e]), b.useEffect(() => {
|
|
123
123
|
let e = () => {
|
|
124
|
-
|
|
124
|
+
A(!!document.fullscreenElement);
|
|
125
125
|
};
|
|
126
126
|
return document.addEventListener("fullscreenchange", e), () => {
|
|
127
127
|
document.removeEventListener("fullscreenchange", e);
|
|
128
128
|
};
|
|
129
129
|
}, []);
|
|
130
|
-
let
|
|
131
|
-
transform: `translate(${
|
|
132
|
-
transition:
|
|
133
|
-
cursor:
|
|
130
|
+
let U = b.useMemo(() => ({
|
|
131
|
+
transform: `translate(${N.x}px, ${N.y}px) scale(${x}) rotate(${w}deg)`,
|
|
132
|
+
transition: F ? "none" : "transform 160ms ease",
|
|
133
|
+
cursor: j ? "default" : F ? "grabbing" : "grab"
|
|
134
134
|
}), [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
]),
|
|
142
|
-
|
|
143
|
-
}, []),
|
|
144
|
-
|
|
145
|
-
}, []),
|
|
146
|
-
|
|
135
|
+
F,
|
|
136
|
+
j,
|
|
137
|
+
w,
|
|
138
|
+
x,
|
|
139
|
+
N.x,
|
|
140
|
+
N.y
|
|
141
|
+
]), W = b.useCallback(() => {
|
|
142
|
+
k("actual"), C((e) => z(e + he));
|
|
143
|
+
}, []), G = b.useCallback(() => {
|
|
144
|
+
k("actual"), C((e) => z(e - he));
|
|
145
|
+
}, []), K = b.useCallback(() => {
|
|
146
|
+
k("fit"), C(1), P({
|
|
147
147
|
x: 0,
|
|
148
148
|
y: 0
|
|
149
149
|
});
|
|
150
|
-
}, []),
|
|
151
|
-
|
|
150
|
+
}, []), q = b.useCallback(() => {
|
|
151
|
+
k("actual"), C(1), P({
|
|
152
152
|
x: 0,
|
|
153
153
|
y: 0
|
|
154
154
|
});
|
|
155
|
-
}, []),
|
|
156
|
-
|
|
157
|
-
}, []),
|
|
158
|
-
|
|
159
|
-
}, []),
|
|
160
|
-
let e =
|
|
155
|
+
}, []), J = b.useCallback(() => {
|
|
156
|
+
T((e) => e - 90);
|
|
157
|
+
}, []), Y = b.useCallback(() => {
|
|
158
|
+
T((e) => e + 90);
|
|
159
|
+
}, []), X = b.useCallback(async () => {
|
|
160
|
+
let e = ge(a, s, o), t = null;
|
|
161
161
|
try {
|
|
162
|
-
if (
|
|
163
|
-
|
|
162
|
+
if (ve(a)) {
|
|
163
|
+
_e(a, e), h({ description: u.downloadSuccess });
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
} catch {}
|
|
@@ -168,268 +168,268 @@ function B({ open: r, onOpenChange: i, src: a, alt: o, title: s, lang: c = "zh-c
|
|
|
168
168
|
let n = await fetch(a, { mode: "cors" });
|
|
169
169
|
if (!n.ok) throw Error(`Failed to fetch image: ${n.status}`);
|
|
170
170
|
let r = await n.blob();
|
|
171
|
-
t = URL.createObjectURL(r),
|
|
171
|
+
t = URL.createObjectURL(r), _e(t, e), h({ description: u.downloadSuccess });
|
|
172
172
|
} catch {
|
|
173
|
-
|
|
173
|
+
h({
|
|
174
174
|
variant: "destructive",
|
|
175
|
-
description:
|
|
175
|
+
description: u.downloadError
|
|
176
176
|
});
|
|
177
177
|
} finally {
|
|
178
178
|
t && URL.revokeObjectURL(t);
|
|
179
179
|
}
|
|
180
180
|
}, [
|
|
181
181
|
o,
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
u.downloadError,
|
|
183
|
+
u.downloadSuccess,
|
|
184
184
|
a,
|
|
185
185
|
s
|
|
186
|
-
]),
|
|
186
|
+
]), Z = b.useCallback(() => {
|
|
187
187
|
try {
|
|
188
188
|
window.open(a, "_blank", "noopener,noreferrer");
|
|
189
189
|
} catch {
|
|
190
|
-
|
|
190
|
+
h({
|
|
191
191
|
variant: "destructive",
|
|
192
|
-
description:
|
|
192
|
+
description: u.openInNewTabError
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
}, [
|
|
196
|
-
let e =
|
|
195
|
+
}, [u.openInNewTabError, a]), Q = b.useCallback(async () => {
|
|
196
|
+
let e = d.current;
|
|
197
197
|
if (!e?.requestFullscreen) {
|
|
198
|
-
|
|
198
|
+
h({ description: u.fullscreenError });
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
try {
|
|
202
202
|
document.fullscreenElement ? await document.exitFullscreen() : await e.requestFullscreen();
|
|
203
203
|
} catch {
|
|
204
|
-
|
|
204
|
+
h({ description: u.fullscreenError });
|
|
205
205
|
}
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
if (!
|
|
209
|
-
let
|
|
210
|
-
e.key === "+" ? (e.preventDefault(),
|
|
206
|
+
}, [u.fullscreenError]);
|
|
207
|
+
b.useEffect(() => {
|
|
208
|
+
if (!e) return;
|
|
209
|
+
let t = (e) => {
|
|
210
|
+
e.key === "+" ? (e.preventDefault(), W()) : e.key === "-" ? (e.preventDefault(), G()) : e.key === "0" ? (e.preventDefault(), H()) : e.key === "f" || e.key === "F" ? (e.preventDefault(), Q()) : e.key === "[" ? (e.preventDefault(), J()) : e.key === "]" && (e.preventDefault(), Y());
|
|
211
211
|
};
|
|
212
|
-
return window.addEventListener("keydown",
|
|
213
|
-
window.removeEventListener("keydown",
|
|
212
|
+
return window.addEventListener("keydown", t), () => {
|
|
213
|
+
window.removeEventListener("keydown", t);
|
|
214
214
|
};
|
|
215
215
|
}, [
|
|
216
216
|
Q,
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
e,
|
|
218
|
+
H,
|
|
219
|
+
J,
|
|
219
220
|
Y,
|
|
220
|
-
|
|
221
|
-
G
|
|
222
|
-
K
|
|
221
|
+
W,
|
|
222
|
+
G
|
|
223
223
|
]);
|
|
224
|
-
let $ =
|
|
225
|
-
e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ?
|
|
226
|
-
}, [
|
|
227
|
-
|
|
228
|
-
if (!
|
|
229
|
-
let
|
|
230
|
-
if (
|
|
231
|
-
|
|
224
|
+
let $ = b.useCallback((e) => {
|
|
225
|
+
e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ? W() : G();
|
|
226
|
+
}, [W, G]);
|
|
227
|
+
b.useEffect(() => {
|
|
228
|
+
if (!e) return;
|
|
229
|
+
let t = d.current;
|
|
230
|
+
if (t) return t.addEventListener("wheel", $, { passive: !1 }), () => {
|
|
231
|
+
t.removeEventListener("wheel", $);
|
|
232
232
|
};
|
|
233
|
-
}, [$,
|
|
234
|
-
let ye =
|
|
235
|
-
|
|
233
|
+
}, [$, e]);
|
|
234
|
+
let ye = b.useCallback((e) => {
|
|
235
|
+
L.current.set(e.pointerId, {
|
|
236
236
|
x: e.clientX,
|
|
237
237
|
y: e.clientY
|
|
238
238
|
});
|
|
239
|
-
let t = Array.from(
|
|
240
|
-
if (t.length === 2 &&
|
|
241
|
-
let [e, n] = t, r = Math.hypot(n.x - e.x, n.y - e.y), i = z(
|
|
242
|
-
|
|
239
|
+
let t = Array.from(L.current.values());
|
|
240
|
+
if (t.length === 2 && B.current) {
|
|
241
|
+
let [e, n] = t, r = Math.hypot(n.x - e.x, n.y - e.y), i = z(B.current.startScale * (r / B.current.startDistance));
|
|
242
|
+
k("actual"), C(i);
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
-
let n =
|
|
246
|
-
!n || n.pointerId !== e.pointerId ||
|
|
245
|
+
let n = R.current;
|
|
246
|
+
!n || n.pointerId !== e.pointerId || P({
|
|
247
247
|
x: n.originX + (e.clientX - n.startX),
|
|
248
248
|
y: n.originY + (e.clientY - n.startY)
|
|
249
249
|
});
|
|
250
|
-
}, []), be =
|
|
251
|
-
e &&
|
|
252
|
-
}, []), xe =
|
|
253
|
-
if (e.button !== 0 ||
|
|
254
|
-
e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId),
|
|
250
|
+
}, []), be = b.useCallback((e) => {
|
|
251
|
+
e && d.current?.hasPointerCapture(e.pointerId) && d.current.releasePointerCapture(e.pointerId), e && L.current.delete(e.pointerId), R.current = null, L.current.size < 2 && (B.current = null), I(!1);
|
|
252
|
+
}, []), xe = b.useCallback((e) => {
|
|
253
|
+
if (e.button !== 0 || j) return;
|
|
254
|
+
e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), L.current.set(e.pointerId, {
|
|
255
255
|
x: e.clientX,
|
|
256
256
|
y: e.clientY
|
|
257
257
|
});
|
|
258
|
-
let t = Array.from(
|
|
258
|
+
let t = Array.from(L.current.values());
|
|
259
259
|
if (t.length === 2) {
|
|
260
260
|
let [e, n] = t;
|
|
261
|
-
|
|
261
|
+
B.current = {
|
|
262
262
|
startDistance: Math.max(1, Math.hypot(n.x - e.x, n.y - e.y)),
|
|
263
|
-
startScale:
|
|
264
|
-
},
|
|
263
|
+
startScale: x
|
|
264
|
+
}, R.current = null, I(!1);
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
R.current = {
|
|
268
268
|
pointerId: e.pointerId,
|
|
269
269
|
startX: e.clientX,
|
|
270
270
|
startY: e.clientY,
|
|
271
|
-
originX:
|
|
272
|
-
originY:
|
|
273
|
-
},
|
|
271
|
+
originX: N.x,
|
|
272
|
+
originY: N.y
|
|
273
|
+
}, I(!0);
|
|
274
274
|
}, [
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
j,
|
|
276
|
+
x,
|
|
277
|
+
N.x,
|
|
278
|
+
N.y
|
|
279
279
|
]);
|
|
280
|
-
|
|
281
|
-
if (!
|
|
282
|
-
let
|
|
283
|
-
let t =
|
|
280
|
+
b.useEffect(() => {
|
|
281
|
+
if (!e) return;
|
|
282
|
+
let t = (e) => {
|
|
283
|
+
let t = d.current, n = e.target;
|
|
284
284
|
!t || !(n instanceof Node) || !t.contains(n) || !e.ctrlKey || $(e);
|
|
285
285
|
};
|
|
286
|
-
return window.addEventListener("wheel",
|
|
286
|
+
return window.addEventListener("wheel", t, {
|
|
287
287
|
passive: !1,
|
|
288
288
|
capture: !0
|
|
289
289
|
}), () => {
|
|
290
|
-
window.removeEventListener("wheel",
|
|
290
|
+
window.removeEventListener("wheel", t, { capture: !0 });
|
|
291
291
|
};
|
|
292
|
-
}, [$,
|
|
293
|
-
let Se =
|
|
292
|
+
}, [$, e]);
|
|
293
|
+
let Se = b.useMemo(() => [
|
|
294
294
|
{
|
|
295
295
|
key: "zoom-in",
|
|
296
|
-
label:
|
|
297
|
-
icon:
|
|
298
|
-
onClick:
|
|
299
|
-
disabled:
|
|
296
|
+
label: u.zoomIn,
|
|
297
|
+
icon: le,
|
|
298
|
+
onClick: W,
|
|
299
|
+
disabled: j || x >= me
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
302
|
key: "zoom-out",
|
|
303
|
-
label:
|
|
304
|
-
icon:
|
|
305
|
-
onClick:
|
|
306
|
-
disabled:
|
|
303
|
+
label: u.zoomOut,
|
|
304
|
+
icon: ue,
|
|
305
|
+
onClick: G,
|
|
306
|
+
disabled: j || x <= pe
|
|
307
307
|
},
|
|
308
308
|
{
|
|
309
309
|
key: "fit",
|
|
310
|
-
label:
|
|
311
|
-
icon:
|
|
312
|
-
onClick:
|
|
313
|
-
disabled:
|
|
310
|
+
label: u.fit,
|
|
311
|
+
icon: re,
|
|
312
|
+
onClick: K,
|
|
313
|
+
disabled: j
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
key: "actual-size",
|
|
317
|
-
label:
|
|
318
|
-
icon:
|
|
319
|
-
onClick:
|
|
320
|
-
disabled:
|
|
317
|
+
label: u.actualSize,
|
|
318
|
+
icon: se,
|
|
319
|
+
onClick: q,
|
|
320
|
+
disabled: j
|
|
321
321
|
},
|
|
322
322
|
{
|
|
323
323
|
key: "reset",
|
|
324
|
-
label:
|
|
325
|
-
icon:
|
|
326
|
-
onClick:
|
|
327
|
-
disabled:
|
|
324
|
+
label: u.reset,
|
|
325
|
+
icon: ie,
|
|
326
|
+
onClick: H,
|
|
327
|
+
disabled: j
|
|
328
328
|
},
|
|
329
329
|
{
|
|
330
330
|
key: "rotate-left",
|
|
331
|
-
label:
|
|
332
|
-
icon:
|
|
333
|
-
onClick:
|
|
334
|
-
disabled:
|
|
331
|
+
label: u.rotateLeft,
|
|
332
|
+
icon: ae,
|
|
333
|
+
onClick: J,
|
|
334
|
+
disabled: j
|
|
335
335
|
},
|
|
336
336
|
{
|
|
337
337
|
key: "rotate-right",
|
|
338
|
-
label:
|
|
339
|
-
icon:
|
|
340
|
-
onClick:
|
|
341
|
-
disabled:
|
|
338
|
+
label: u.rotateRight,
|
|
339
|
+
icon: oe,
|
|
340
|
+
onClick: Y,
|
|
341
|
+
disabled: j
|
|
342
342
|
},
|
|
343
343
|
{
|
|
344
344
|
key: "fullscreen",
|
|
345
|
-
label:
|
|
346
|
-
icon:
|
|
345
|
+
label: u.fullscreen,
|
|
346
|
+
icon: ne,
|
|
347
347
|
onClick: () => void Q(),
|
|
348
348
|
disabled: !1
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
key: "download",
|
|
352
|
-
label:
|
|
353
|
-
icon:
|
|
354
|
-
onClick:
|
|
355
|
-
disabled:
|
|
352
|
+
label: u.download,
|
|
353
|
+
icon: te,
|
|
354
|
+
onClick: X,
|
|
355
|
+
disabled: j
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
key: "new-tab",
|
|
359
|
-
label:
|
|
359
|
+
label: u.openInNewTab,
|
|
360
360
|
icon: S,
|
|
361
|
-
onClick:
|
|
361
|
+
onClick: Z,
|
|
362
362
|
disabled: !1
|
|
363
363
|
}
|
|
364
364
|
], [
|
|
365
|
-
Z,
|
|
366
|
-
Q,
|
|
367
|
-
ve,
|
|
368
|
-
N,
|
|
369
|
-
y.actualSize,
|
|
370
|
-
y.download,
|
|
371
|
-
y.fit,
|
|
372
|
-
y.fullscreen,
|
|
373
|
-
y.openInNewTab,
|
|
374
|
-
y.reset,
|
|
375
|
-
y.rotateLeft,
|
|
376
|
-
y.rotateRight,
|
|
377
|
-
y.zoomIn,
|
|
378
|
-
y.zoomOut,
|
|
379
|
-
W,
|
|
380
|
-
Y,
|
|
381
365
|
X,
|
|
382
|
-
|
|
366
|
+
Q,
|
|
367
|
+
Z,
|
|
368
|
+
j,
|
|
369
|
+
u.actualSize,
|
|
370
|
+
u.download,
|
|
371
|
+
u.fit,
|
|
372
|
+
u.fullscreen,
|
|
373
|
+
u.openInNewTab,
|
|
374
|
+
u.reset,
|
|
375
|
+
u.rotateLeft,
|
|
376
|
+
u.rotateRight,
|
|
377
|
+
u.zoomIn,
|
|
378
|
+
u.zoomOut,
|
|
379
|
+
H,
|
|
383
380
|
J,
|
|
381
|
+
Y,
|
|
382
|
+
x,
|
|
384
383
|
q,
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
K,
|
|
385
|
+
W,
|
|
386
|
+
G
|
|
387
387
|
]);
|
|
388
|
-
return /* @__PURE__ */
|
|
389
|
-
open:
|
|
390
|
-
onOpenChange:
|
|
391
|
-
children: /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ E(v, {
|
|
389
|
+
open: e,
|
|
390
|
+
onOpenChange: t,
|
|
391
|
+
children: /* @__PURE__ */ D(_, {
|
|
392
392
|
showCloseButton: !1,
|
|
393
393
|
className: "flex h-[min(94vh,980px)] w-[calc(100vw-0.75rem)] sm:w-[40rem] md:w-[52rem] lg:w-[64rem] xl:w-[74rem] 2xl:w-[86rem] max-w-[calc(100vw-0.75rem)] flex-col gap-3 border-zinc-800 bg-zinc-950 p-3 text-zinc-50 sm:max-w-[calc(100vw-2rem)] sm:p-4",
|
|
394
394
|
children: [
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
/* @__PURE__ */
|
|
397
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ E(y, { children: V }),
|
|
396
|
+
/* @__PURE__ */ E(g, { children: u.close }),
|
|
397
|
+
/* @__PURE__ */ D(i, {
|
|
398
398
|
delayDuration: 100,
|
|
399
|
-
children: [/* @__PURE__ */
|
|
399
|
+
children: [/* @__PURE__ */ D("div", {
|
|
400
400
|
className: "flex items-center justify-between gap-3 rounded-lg border border-zinc-800 bg-zinc-900/80 px-3 py-2",
|
|
401
|
-
children: [/* @__PURE__ */
|
|
401
|
+
children: [/* @__PURE__ */ D("div", {
|
|
402
402
|
className: "min-w-0",
|
|
403
|
-
children: [/* @__PURE__ */
|
|
403
|
+
children: [/* @__PURE__ */ E("p", {
|
|
404
404
|
className: "truncate text-sm font-medium",
|
|
405
|
-
children:
|
|
406
|
-
}), /* @__PURE__ */
|
|
405
|
+
children: V
|
|
406
|
+
}), /* @__PURE__ */ D("p", {
|
|
407
407
|
className: "text-xs text-zinc-400",
|
|
408
408
|
children: [
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
O === "fit" ? u.fit : `${Math.round(x * 100)}%`,
|
|
410
|
+
w === 0 ? "" : ` · ${w}deg`,
|
|
411
|
+
de ? ` · ${u.fullscreen}` : ""
|
|
412
412
|
]
|
|
413
413
|
})]
|
|
414
|
-
}), /* @__PURE__ */
|
|
414
|
+
}), /* @__PURE__ */ E(r, {
|
|
415
415
|
type: "button",
|
|
416
416
|
size: "icon",
|
|
417
417
|
variant: "ghost",
|
|
418
418
|
className: "h-9 w-9 shrink-0 text-zinc-100 hover:bg-zinc-800 hover:text-white",
|
|
419
|
-
onClick: () =>
|
|
420
|
-
"aria-label":
|
|
421
|
-
title:
|
|
422
|
-
children: /* @__PURE__ */
|
|
419
|
+
onClick: () => t(!1),
|
|
420
|
+
"aria-label": u.close,
|
|
421
|
+
title: u.close,
|
|
422
|
+
children: /* @__PURE__ */ E(ce, { className: "h-4 w-4" })
|
|
423
423
|
})]
|
|
424
|
-
}), /* @__PURE__ */
|
|
424
|
+
}), /* @__PURE__ */ E("div", {
|
|
425
425
|
className: "overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900/80 px-2 py-2",
|
|
426
|
-
children: /* @__PURE__ */
|
|
426
|
+
children: /* @__PURE__ */ E("div", {
|
|
427
427
|
className: "flex min-w-max items-center gap-2",
|
|
428
428
|
children: Se.map((e) => {
|
|
429
|
-
let
|
|
430
|
-
return /* @__PURE__ */
|
|
429
|
+
let t = e.icon;
|
|
430
|
+
return /* @__PURE__ */ D(f, { children: [/* @__PURE__ */ E(p, {
|
|
431
431
|
asChild: !0,
|
|
432
|
-
children: /* @__PURE__ */
|
|
432
|
+
children: /* @__PURE__ */ E(r, {
|
|
433
433
|
type: "button",
|
|
434
434
|
size: "icon",
|
|
435
435
|
variant: "secondary",
|
|
@@ -438,43 +438,43 @@ function B({ open: r, onOpenChange: i, src: a, alt: o, title: s, lang: c = "zh-c
|
|
|
438
438
|
disabled: e.disabled,
|
|
439
439
|
"aria-label": e.label,
|
|
440
440
|
title: e.label,
|
|
441
|
-
children: /* @__PURE__ */
|
|
441
|
+
children: /* @__PURE__ */ E(t, { className: "h-4 w-4" })
|
|
442
442
|
})
|
|
443
|
-
}), /* @__PURE__ */
|
|
443
|
+
}), /* @__PURE__ */ E(m, { children: e.label })] }, e.key);
|
|
444
444
|
})
|
|
445
445
|
})
|
|
446
446
|
})]
|
|
447
447
|
}),
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
ref:
|
|
448
|
+
/* @__PURE__ */ E("div", {
|
|
449
|
+
ref: d,
|
|
450
450
|
className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden rounded-xl border border-zinc-800 bg-[radial-gradient(circle_at_top,_rgba(255,255,255,0.08),_transparent_40%),linear-gradient(180deg,_rgba(24,24,27,0.9),_rgba(9,9,11,1))] p-4 touch-none",
|
|
451
451
|
onPointerDown: xe,
|
|
452
452
|
onPointerMove: ye,
|
|
453
453
|
onPointerUp: be,
|
|
454
454
|
onPointerCancel: be,
|
|
455
|
-
children:
|
|
455
|
+
children: j ? /* @__PURE__ */ D("div", {
|
|
456
456
|
className: "flex flex-col items-center gap-2 text-center",
|
|
457
457
|
children: [
|
|
458
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ E("div", {
|
|
459
459
|
className: "rounded-full border border-red-500/40 bg-red-500/10 p-3 text-red-300",
|
|
460
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ E(se, { className: "h-5 w-5" })
|
|
461
461
|
}),
|
|
462
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ E("p", {
|
|
463
463
|
className: "text-sm font-medium",
|
|
464
|
-
children:
|
|
464
|
+
children: u.imageLoadError
|
|
465
465
|
}),
|
|
466
|
-
/* @__PURE__ */
|
|
466
|
+
/* @__PURE__ */ E("p", {
|
|
467
467
|
className: "max-w-md text-xs text-zinc-400",
|
|
468
468
|
children: a
|
|
469
469
|
})
|
|
470
470
|
]
|
|
471
|
-
}) : /* @__PURE__ */
|
|
472
|
-
ref:
|
|
471
|
+
}) : /* @__PURE__ */ E("img", {
|
|
472
|
+
ref: ee,
|
|
473
473
|
src: a,
|
|
474
|
-
alt:
|
|
475
|
-
className:
|
|
476
|
-
style:
|
|
477
|
-
onError: () =>
|
|
474
|
+
alt: V,
|
|
475
|
+
className: n("max-h-full max-w-full select-none rounded-lg object-contain shadow-2xl", O === "fit" ? "h-auto w-auto" : ""),
|
|
476
|
+
style: U,
|
|
477
|
+
onError: () => M(!0),
|
|
478
478
|
draggable: !1
|
|
479
479
|
})
|
|
480
480
|
})
|
|
@@ -530,7 +530,7 @@ function W(e) {
|
|
|
530
530
|
"off"
|
|
531
531
|
].includes(t)) return !1;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function G(e, t) {
|
|
534
534
|
let n = {
|
|
535
535
|
title: e,
|
|
536
536
|
width: U(t?.width),
|
|
@@ -553,18 +553,18 @@ function _e(e, t) {
|
|
|
553
553
|
return t;
|
|
554
554
|
}), n.title = r.replace(/\s{2,}/g, " ").trim() || void 0, n;
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function K(e) {
|
|
557
557
|
let t = e, n = "";
|
|
558
558
|
for (; t !== n;) n = t, t = t.replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*)>([\s\S]*?)<\/\1>/g, (e, t, n, r) => {
|
|
559
|
-
let i =
|
|
559
|
+
let i = q(n), a = t.toLowerCase().replace(/\./g, "-");
|
|
560
560
|
return `<${a}${i}>${r}</${a}>`;
|
|
561
561
|
}).replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*?)\s*\/>/g, (e, t, n) => {
|
|
562
|
-
let r =
|
|
562
|
+
let r = q(n), i = t.toLowerCase().replace(/\./g, "-");
|
|
563
563
|
return `<${i}${r}></${i}>`;
|
|
564
564
|
});
|
|
565
565
|
return t;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function q(e) {
|
|
568
568
|
if (!e) return "";
|
|
569
569
|
let t = [], n = /(\w+)=(?:{([^}]+)}|"([^"]*)"|'([^']*)')/g, r;
|
|
570
570
|
for (; (r = n.exec(e)) !== null;) {
|
|
@@ -573,7 +573,7 @@ function K(e) {
|
|
|
573
573
|
}
|
|
574
574
|
return t.length > 0 ? " " + t.join(" ") : "";
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function J(e) {
|
|
577
577
|
let t = {};
|
|
578
578
|
for (let [n, r] of Object.entries(e)) if (n.startsWith("data-")) {
|
|
579
579
|
let e = n.slice(5);
|
|
@@ -596,7 +596,7 @@ function q(e) {
|
|
|
596
596
|
}
|
|
597
597
|
return t;
|
|
598
598
|
}
|
|
599
|
-
var
|
|
599
|
+
var Y = {
|
|
600
600
|
js: "JavaScript",
|
|
601
601
|
javascript: "JavaScript",
|
|
602
602
|
ts: "TypeScript",
|
|
@@ -638,10 +638,10 @@ var J = {
|
|
|
638
638
|
diff: "Diff",
|
|
639
639
|
text: "Text"
|
|
640
640
|
};
|
|
641
|
-
function
|
|
642
|
-
let [
|
|
641
|
+
function X({ className: n, children: r, meta: i, codeHighlight: a, shikiBundle: s }) {
|
|
642
|
+
let [l, d] = b.useState(""), [f, p] = b.useState(!1), [m, h] = b.useState(!1), g = b.useMemo(() => i?.toLowerCase().includes("showlinenumbers") ?? !1, [i]), _ = /language-(\w+)/.exec(n || ""), v = _ ? _[1] : "text", y = o(v), te = Y[v.toLowerCase()] || v.toUpperCase(), S = b.useMemo(() => {
|
|
643
643
|
let e = "";
|
|
644
|
-
return e = typeof
|
|
644
|
+
return e = typeof r == "string" ? r : b.Children.count(r) === 1 && typeof r == "string" ? String(r) : b.Children.toArray(r).map((e) => {
|
|
645
645
|
if (typeof e == "string") return e;
|
|
646
646
|
if (typeof e == "object" && e && "props" in e) {
|
|
647
647
|
let t = e.props;
|
|
@@ -652,10 +652,10 @@ function Y({ className: e, children: t, meta: n, codeHighlight: r, shikiBundle:
|
|
|
652
652
|
}
|
|
653
653
|
return "";
|
|
654
654
|
}).join(""), e.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
655
|
-
}, [
|
|
656
|
-
|
|
655
|
+
}, [r]);
|
|
656
|
+
b.useEffect(() => {
|
|
657
657
|
let e = () => {
|
|
658
|
-
|
|
658
|
+
p(document.documentElement.classList.contains("dark"));
|
|
659
659
|
};
|
|
660
660
|
e();
|
|
661
661
|
let t = new MutationObserver(() => e());
|
|
@@ -663,68 +663,56 @@ function Y({ className: e, children: t, meta: n, codeHighlight: r, shikiBundle:
|
|
|
663
663
|
attributes: !0,
|
|
664
664
|
attributeFilter: ["class"]
|
|
665
665
|
}), () => t.disconnect();
|
|
666
|
-
}, []),
|
|
667
|
-
|
|
668
|
-
lang:
|
|
669
|
-
theme:
|
|
670
|
-
showLineNumbers:
|
|
671
|
-
},
|
|
666
|
+
}, []), b.useEffect(() => {
|
|
667
|
+
c(S, {
|
|
668
|
+
lang: y,
|
|
669
|
+
theme: u(f, a, s),
|
|
670
|
+
showLineNumbers: g
|
|
671
|
+
}, a, s).then((e) => d(t(e)));
|
|
672
672
|
}, [
|
|
673
673
|
S,
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
674
|
+
y,
|
|
675
|
+
f,
|
|
676
|
+
g,
|
|
677
|
+
a,
|
|
678
|
+
s
|
|
679
679
|
]);
|
|
680
|
-
let
|
|
681
|
-
let e = async (e) => {
|
|
682
|
-
if (navigator.clipboard && window.isSecureContext) await navigator.clipboard.writeText(e);
|
|
683
|
-
else {
|
|
684
|
-
let t = document.createElement("textarea");
|
|
685
|
-
t.value = e, t.style.position = "fixed", t.style.left = "-9999px", t.style.top = "-9999px", document.body.appendChild(t), t.focus(), t.select();
|
|
686
|
-
try {
|
|
687
|
-
document.execCommand("copy");
|
|
688
|
-
} finally {
|
|
689
|
-
document.body.removeChild(t);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
};
|
|
680
|
+
let ne = b.useCallback(async () => {
|
|
693
681
|
try {
|
|
694
|
-
await e(S),
|
|
682
|
+
await e(S), h(!0), setTimeout(() => h(!1), 2e3);
|
|
695
683
|
} catch (e) {
|
|
696
684
|
console.error("Failed to copy:", e);
|
|
697
685
|
}
|
|
698
686
|
}, [S]);
|
|
699
|
-
return
|
|
687
|
+
return l ? /* @__PURE__ */ D("div", {
|
|
700
688
|
className: "code-block-wrapper",
|
|
701
689
|
children: [
|
|
702
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ E("span", {
|
|
703
691
|
className: "code-lang-label",
|
|
704
|
-
children:
|
|
692
|
+
children: te
|
|
705
693
|
}),
|
|
706
|
-
/* @__PURE__ */
|
|
694
|
+
/* @__PURE__ */ E("button", {
|
|
707
695
|
className: "code-copy-btn",
|
|
708
|
-
onClick:
|
|
709
|
-
title:
|
|
696
|
+
onClick: ne,
|
|
697
|
+
title: m ? "已复制" : "复制代码",
|
|
710
698
|
"aria-label": "复制代码",
|
|
711
|
-
children:
|
|
699
|
+
children: m ? /* @__PURE__ */ E(ee, { className: "h-4 w-4 text-green-500" }) : /* @__PURE__ */ E(x, { className: "h-4 w-4" })
|
|
712
700
|
}),
|
|
713
|
-
/* @__PURE__ */
|
|
714
|
-
className: `shiki-code-block${
|
|
715
|
-
dangerouslySetInnerHTML: { __html:
|
|
701
|
+
/* @__PURE__ */ E("pre", {
|
|
702
|
+
className: `shiki-code-block${g ? " show-line-numbers" : ""}`,
|
|
703
|
+
dangerouslySetInnerHTML: { __html: l }
|
|
716
704
|
})
|
|
717
705
|
]
|
|
718
|
-
}) : /* @__PURE__ */
|
|
706
|
+
}) : /* @__PURE__ */ E("div", {
|
|
719
707
|
className: "code-block-wrapper",
|
|
720
|
-
children: /* @__PURE__ */
|
|
708
|
+
children: /* @__PURE__ */ E("pre", {
|
|
721
709
|
className: "shiki-code-block",
|
|
722
|
-
children: /* @__PURE__ */
|
|
710
|
+
children: /* @__PURE__ */ E("code", { children: S })
|
|
723
711
|
})
|
|
724
712
|
});
|
|
725
713
|
}
|
|
726
|
-
function
|
|
727
|
-
let [c, l] =
|
|
714
|
+
function Z({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, node: o, ...s }) {
|
|
715
|
+
let [c, l] = b.useState(!1), u = b.useMemo(() => fe(e, t?.labels), [e, t?.labels]), d = b.useMemo(() => G(i, s), [s, i]), f = d.preview ?? t?.enabled !== !1, p = d.inline === !0, m = !!(d.width || d.height), h = b.useMemo(() => ({
|
|
728
716
|
...s.style,
|
|
729
717
|
width: d.width ?? s.style?.width,
|
|
730
718
|
height: d.height ?? s.style?.height,
|
|
@@ -736,13 +724,13 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
736
724
|
d.width,
|
|
737
725
|
s.style
|
|
738
726
|
]);
|
|
739
|
-
return n ? f ? m || p ? /* @__PURE__ */
|
|
727
|
+
return n ? f ? m || p ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("button", {
|
|
740
728
|
type: "button",
|
|
741
729
|
className: "not-prose inline-flex max-w-full cursor-zoom-in align-middle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
742
730
|
onClick: () => l(!0),
|
|
743
731
|
"aria-label": u.preview,
|
|
744
732
|
title: u.preview,
|
|
745
|
-
children: /* @__PURE__ */
|
|
733
|
+
children: /* @__PURE__ */ E("img", {
|
|
746
734
|
...s,
|
|
747
735
|
src: n,
|
|
748
736
|
alt: r || u.imageAltFallback,
|
|
@@ -750,7 +738,7 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
750
738
|
className: a ?? (p ? "inline-block align-middle" : void 0),
|
|
751
739
|
style: h
|
|
752
740
|
})
|
|
753
|
-
}), /* @__PURE__ */
|
|
741
|
+
}), /* @__PURE__ */ E(B, {
|
|
754
742
|
open: c,
|
|
755
743
|
onOpenChange: l,
|
|
756
744
|
src: n,
|
|
@@ -758,15 +746,15 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
758
746
|
title: d.title,
|
|
759
747
|
lang: e,
|
|
760
748
|
labels: t?.labels
|
|
761
|
-
})] }) : /* @__PURE__ */
|
|
749
|
+
})] }) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ D("span", {
|
|
762
750
|
className: "not-prose group relative my-6 block",
|
|
763
|
-
children: [/* @__PURE__ */
|
|
751
|
+
children: [/* @__PURE__ */ E("button", {
|
|
764
752
|
type: "button",
|
|
765
753
|
className: "block w-full cursor-zoom-in overflow-hidden rounded-2xl border border-border/60 bg-muted/20 shadow-sm transition duration-200 hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
766
754
|
onClick: () => l(!0),
|
|
767
755
|
"aria-label": u.preview,
|
|
768
756
|
title: u.preview,
|
|
769
|
-
children: /* @__PURE__ */
|
|
757
|
+
children: /* @__PURE__ */ E("img", {
|
|
770
758
|
...s,
|
|
771
759
|
src: n,
|
|
772
760
|
alt: r || u.imageAltFallback,
|
|
@@ -774,17 +762,17 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
774
762
|
className: a ?? "h-auto w-full rounded-2xl object-contain",
|
|
775
763
|
style: h
|
|
776
764
|
})
|
|
777
|
-
}), /* @__PURE__ */
|
|
765
|
+
}), /* @__PURE__ */ D("button", {
|
|
778
766
|
type: "button",
|
|
779
767
|
className: "absolute right-3 top-3 inline-flex items-center gap-2 rounded-full border border-white/20 bg-black/65 px-3 py-1.5 text-xs font-medium text-white opacity-0 shadow-lg transition group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70",
|
|
780
768
|
onClick: () => l(!0),
|
|
781
769
|
"aria-label": u.preview,
|
|
782
770
|
children: [
|
|
783
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ E("span", {
|
|
784
772
|
className: "sr-only",
|
|
785
773
|
children: u.preview
|
|
786
774
|
}),
|
|
787
|
-
/* @__PURE__ */
|
|
775
|
+
/* @__PURE__ */ D("svg", {
|
|
788
776
|
"aria-hidden": "true",
|
|
789
777
|
viewBox: "0 0 24 24",
|
|
790
778
|
className: "h-3.5 w-3.5",
|
|
@@ -793,16 +781,16 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
793
781
|
strokeWidth: "2",
|
|
794
782
|
strokeLinecap: "round",
|
|
795
783
|
strokeLinejoin: "round",
|
|
796
|
-
children: [/* @__PURE__ */
|
|
784
|
+
children: [/* @__PURE__ */ E("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z" }), /* @__PURE__ */ E("circle", {
|
|
797
785
|
cx: "12",
|
|
798
786
|
cy: "12",
|
|
799
787
|
r: "3"
|
|
800
788
|
})]
|
|
801
789
|
}),
|
|
802
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ E("span", { children: u.preview })
|
|
803
791
|
]
|
|
804
792
|
})]
|
|
805
|
-
}), /* @__PURE__ */
|
|
793
|
+
}), /* @__PURE__ */ E(B, {
|
|
806
794
|
open: c,
|
|
807
795
|
onOpenChange: l,
|
|
808
796
|
src: n,
|
|
@@ -810,7 +798,7 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
810
798
|
title: d.title,
|
|
811
799
|
lang: e,
|
|
812
800
|
labels: t?.labels
|
|
813
|
-
})] }) : /* @__PURE__ */
|
|
801
|
+
})] }) : /* @__PURE__ */ E("img", {
|
|
814
802
|
...s,
|
|
815
803
|
src: n,
|
|
816
804
|
alt: r || u.imageAltFallback,
|
|
@@ -819,32 +807,32 @@ function X({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
819
807
|
style: h
|
|
820
808
|
}) : null;
|
|
821
809
|
}
|
|
822
|
-
function
|
|
823
|
-
let
|
|
824
|
-
|
|
825
|
-
r
|
|
826
|
-
}, [
|
|
827
|
-
let p =
|
|
810
|
+
function Q({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: r, shikiBundle: i }) {
|
|
811
|
+
let o = w(), c = o.lang || "zh-cn", u = o.version, f = l();
|
|
812
|
+
b.useEffect(() => {
|
|
813
|
+
a(r, i);
|
|
814
|
+
}, [r, i]);
|
|
815
|
+
let p = b.useMemo(() => {
|
|
828
816
|
if (!t) return e;
|
|
829
817
|
let n = e.split("\n"), r = !1;
|
|
830
818
|
return n.filter((e) => !r && e.startsWith("# ") ? (r = !0, !1) : !0).join("\n");
|
|
831
|
-
}, [e, t]), m =
|
|
819
|
+
}, [e, t]), m = b.useMemo(() => K(p), [p]), h = b.useMemo(() => {
|
|
832
820
|
let e = /* @__PURE__ */ new Map();
|
|
833
821
|
return f && Object.entries(f).forEach(([t, n]) => {
|
|
834
|
-
let r =
|
|
835
|
-
let r =
|
|
836
|
-
return
|
|
822
|
+
let r = b.memo(({ children: e, ...t }) => {
|
|
823
|
+
let r = J(t);
|
|
824
|
+
return b.createElement(n, r, e);
|
|
837
825
|
});
|
|
838
826
|
if (e.set(t, r), e.set(t.toLowerCase(), r), t.includes(".")) {
|
|
839
827
|
let [n, i] = t.split("."), a = `${n.toLowerCase()}-${i.toLowerCase()}`;
|
|
840
828
|
e.set(a, r);
|
|
841
829
|
}
|
|
842
830
|
}), e;
|
|
843
|
-
}, [f]), g =
|
|
844
|
-
return /* @__PURE__ */
|
|
831
|
+
}, [f]), g = b.useMemo(() => Object.fromEntries(h), [h]);
|
|
832
|
+
return /* @__PURE__ */ E("div", {
|
|
845
833
|
className: "prose dark:prose-invert max-w-none",
|
|
846
|
-
children: /* @__PURE__ */
|
|
847
|
-
remarkPlugins: [
|
|
834
|
+
children: /* @__PURE__ */ E(de, {
|
|
835
|
+
remarkPlugins: [O, k],
|
|
848
836
|
rehypePlugins: [
|
|
849
837
|
j,
|
|
850
838
|
M,
|
|
@@ -867,56 +855,56 @@ function Z({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: i, s
|
|
|
867
855
|
components: {
|
|
868
856
|
...g,
|
|
869
857
|
table({ children: e, ...t }) {
|
|
870
|
-
return /* @__PURE__ */
|
|
858
|
+
return /* @__PURE__ */ E("div", {
|
|
871
859
|
className: "overflow-x-auto",
|
|
872
|
-
children: /* @__PURE__ */
|
|
860
|
+
children: /* @__PURE__ */ E("table", {
|
|
873
861
|
...t,
|
|
874
862
|
children: e
|
|
875
863
|
})
|
|
876
864
|
});
|
|
877
865
|
},
|
|
878
866
|
pre({ children: e, ...t }) {
|
|
879
|
-
let n =
|
|
867
|
+
let n = b.Children.toArray(e).find((e) => e?.type === "code" || e?.props?.node?.tagName === "code");
|
|
880
868
|
if (n) {
|
|
881
|
-
let e = n.props, t = e?.className || "",
|
|
882
|
-
|
|
883
|
-
let
|
|
884
|
-
return
|
|
869
|
+
let e = n.props, t = e?.className || "", a = /language-(\w+)/.exec(t), o = a ? a[1].toLowerCase() : "text", s = e?.node, c = e?.children, l = e?.["data-raw-value"];
|
|
870
|
+
l && (c = l);
|
|
871
|
+
let u = s?.data?.meta || "";
|
|
872
|
+
return o === "mermaid" ? /* @__PURE__ */ E(d, { chart: typeof c == "string" ? c : String(c || "") }) : /* @__PURE__ */ E(X, {
|
|
885
873
|
className: t,
|
|
886
|
-
meta:
|
|
887
|
-
codeHighlight:
|
|
888
|
-
shikiBundle:
|
|
874
|
+
meta: u,
|
|
875
|
+
codeHighlight: r,
|
|
876
|
+
shikiBundle: i,
|
|
889
877
|
children: c
|
|
890
878
|
});
|
|
891
879
|
}
|
|
892
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ E("pre", {
|
|
893
881
|
...t,
|
|
894
882
|
children: e
|
|
895
883
|
});
|
|
896
884
|
},
|
|
897
885
|
a({ href: e, children: t, ...n }) {
|
|
898
|
-
return e ? e.startsWith("#") ? /* @__PURE__ */
|
|
886
|
+
return e ? e.startsWith("#") ? /* @__PURE__ */ E("a", {
|
|
899
887
|
href: e,
|
|
900
888
|
...n,
|
|
901
889
|
children: t
|
|
902
|
-
}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */
|
|
890
|
+
}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */ E("a", {
|
|
903
891
|
href: e,
|
|
904
892
|
target: "_blank",
|
|
905
893
|
rel: "noopener noreferrer",
|
|
906
894
|
...n,
|
|
907
895
|
children: t
|
|
908
|
-
}) : /* @__PURE__ */
|
|
909
|
-
to:
|
|
896
|
+
}) : /* @__PURE__ */ E(C, {
|
|
897
|
+
to: s(c, e.startsWith("/") ? e : `/${e}`, u),
|
|
910
898
|
...n,
|
|
911
899
|
children: t
|
|
912
|
-
}) : /* @__PURE__ */
|
|
900
|
+
}) : /* @__PURE__ */ E("a", {
|
|
913
901
|
...n,
|
|
914
902
|
children: t
|
|
915
903
|
});
|
|
916
904
|
},
|
|
917
905
|
img({ src: e, alt: t, title: r, className: i, node: a, ...o }) {
|
|
918
|
-
return /* @__PURE__ */
|
|
919
|
-
lang:
|
|
906
|
+
return /* @__PURE__ */ E(Z, {
|
|
907
|
+
lang: c,
|
|
920
908
|
viewerConfig: n,
|
|
921
909
|
src: e,
|
|
922
910
|
alt: t,
|
|
@@ -932,4 +920,4 @@ function Z({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: i, s
|
|
|
932
920
|
});
|
|
933
921
|
}
|
|
934
922
|
//#endregion
|
|
935
|
-
export { B as n,
|
|
923
|
+
export { B as n, Q as t };
|