react-docs-ui 0.6.17 → 0.6.19
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-W60DtiEW.js → AIChatDialog-BnAX3dRn.js} +2 -2
- package/dist/{AISelectionTrigger-MaBGhxTE.js → AISelectionTrigger-SLyb8Vep.js} +2 -2
- package/dist/{AISettingsPanel-aiMnncnQ.js → AISettingsPanel-Bsd_wLP4.js} +3 -3
- package/dist/{DocsApp-BN6Bo0YD.js → DocsApp-CybQmyB8.js} +3669 -3285
- package/dist/{GlobalContextMenu-DG6x5Y5w.js → GlobalContextMenu-BtVjQk0v.js} +1 -1
- package/dist/{MdxContent-CMB8ZbXo.js → MdxContent-CH9GcMIg.js} +310 -306
- package/dist/{MdxContent.lazy-C4rcCv4v.js → MdxContent.lazy-D7XJ-ZHl.js} +1 -1
- package/dist/{SearchDialog-tUSKKsxW.js → SearchDialog-DWVre6R9.js} +66 -56
- package/dist/{SearchRuntime-5fXpxDsi.js → SearchRuntime-D0rSMKV3.js} +6 -5
- package/dist/_basePickBy-D8oNWNf8.js +166 -0
- package/dist/_baseUniq-DHuXxixa.js +682 -0
- package/dist/arc-j69r3jDe.js +80 -0
- package/dist/architecture-PBZL5I3N-DvHexcWL.js +3 -0
- package/dist/architectureDiagram-2XIMDMQ5-DmhcSwl7.js +4045 -0
- package/dist/array-DHiPsILf.js +6 -0
- package/dist/blockDiagram-WCTKOSBZ-B6A-w3LB.js +3025 -0
- package/dist/c4Diagram-IC4MRINW-AmEpu2Zd.js +2964 -0
- package/dist/channel-CqxMgZ5t.js +5 -0
- package/dist/chunk-4BX2VUAB-D3p73nhw.js +8 -0
- package/dist/chunk-55IACEB6-CLgZJbYv.js +8 -0
- package/dist/chunk-7E7YKBS2-CKRA8Egz.js +23 -0
- package/dist/chunk-7R4GIKGN-C19ZEV_b.js +2596 -0
- package/dist/chunk-C72U2L5F-B6IP-vol.js +23 -0
- package/dist/chunk-EGIJ26TM-Cw4ft_Ra.js +23 -0
- package/dist/chunk-FMBD7UC4-D-Ronn4l.js +5 -0
- package/dist/chunk-GEFDOKGD-8e2771NL.js +1121 -0
- package/dist/chunk-GLR3WWYH-ShSppUzV.js +41 -0
- package/dist/chunk-HHEYEP7N-CU-ZzGab.js +9 -0
- package/dist/chunk-JSJVCQXG-D49UMhzO.js +60 -0
- package/dist/chunk-KX2RTZJC-BDcxmH0D.js +25 -0
- package/dist/chunk-KYZI473N-B9L8Kk83.js +3434 -0
- package/dist/chunk-L3YUKLVL-CEVeJJT9.js +23 -0
- package/dist/chunk-MX3YWQON-CVZUx3EI.js +80 -0
- package/dist/chunk-NBPlniwU.js +23 -0
- package/dist/chunk-NQ4KR5QH-BWRGvKed.js +2002 -0
- package/dist/chunk-O4XLMI2P-BlC0d_Zr.js +511 -0
- package/dist/chunk-OZEHJAEY-BuORg3qI.js +64 -0
- package/dist/chunk-PQ6SQG4A-BggLWIDB.js +67 -0
- package/dist/chunk-PU5JKC2W-CeOPBYeP.js +1885 -0
- package/dist/chunk-QZHKN3VN-3LiJhn2O.js +15 -0
- package/dist/chunk-R5LLSJPH-B8KdhC9h.js +35 -0
- package/dist/chunk-WL4C6EOR-DLbU3P3W.js +3194 -0
- package/dist/chunk-XIRO2GV7-Bv7JEVD4.js +30 -0
- package/dist/chunk-XPW4576I-Bu03pPNP.js +1146 -0
- package/dist/chunk-XZSTWKYB-CpQJcKKv.js +15797 -0
- package/dist/chunk-YBOYWFTD-BAPGCoDq.js +32 -0
- package/dist/classDiagram-VBA2DB6C-D4y64v83.js +29 -0
- package/dist/classDiagram-v2-RAHNMMFH-DXkt0Wd4.js +29 -0
- package/dist/clone-B2fVtDap.js +8 -0
- package/dist/cose-bilkent-S5V4N54A-BX63fiTJ.js +2250 -0
- package/dist/cytoscape.esm-D1tmL96B.js +18100 -0
- package/dist/dagre-BM10A37c.js +1483 -0
- package/dist/dagre-KLK3FWXG-BkGeaeJf.js +294 -0
- package/dist/defaultLocale-CS9riXxY.js +201 -0
- package/dist/diagram-E7M64L7V-BCpOexcP.js +527 -0
- package/dist/diagram-IFDJBPK2-lSNeST-Z.js +213 -0
- package/dist/diagram-P4PSJMXO-Dd8HMHpS.js +133 -0
- package/dist/dist-DeXxBykG.js +50 -0
- package/dist/docs-app.es.js +1 -1
- package/dist/erDiagram-INFDFZHY-DjNq2UqZ.js +1666 -0
- package/dist/flowDiagram-PKNHOUZH-AUeVhXRc.js +4161 -0
- package/dist/ganttDiagram-A5KZAMGK-DZIM1zx8.js +3072 -0
- package/dist/gitGraph-HDMCJU4V-BiirFMfI.js +3 -0
- package/dist/gitGraphDiagram-K3NZZRJ6-CpR0vINe.js +625 -0
- package/dist/graphlib-DOjl69i0.js +225 -0
- package/dist/info-3K5VOQVL-CfGgZztt.js +3 -0
- package/dist/infoDiagram-LFFYTUFH-DAJ9foHI.js +19 -0
- package/dist/init-B4NvJPDj.js +15 -0
- package/dist/isArrayLikeObject-DLIYDRni.js +578 -0
- package/dist/isEmpty-DhbfzuZy.js +35 -0
- package/dist/ishikawaDiagram-PHBUUO56-B7xss2de.js +717 -0
- package/dist/journeyDiagram-4ABVD52K-BbX80Gcw.js +883 -0
- package/dist/kanban-definition-K7BYSVSG-BQ87hifQ.js +971 -0
- package/dist/line-DfLnhEwA.js +34 -0
- package/dist/linear-CWB56ned.js +289 -0
- package/dist/math-DHDNczAo.js +10 -0
- package/dist/{shiki-highlighter-BmQSSJpS.js → mdx-components-m1cGPhc8.js} +1437 -1338
- package/dist/mermaid-parser.core-l4wHnGuN.js +59 -0
- package/dist/mermaid.core-CtkJeRVj.js +919 -0
- package/dist/mindmap-definition-YRQLILUH-Cnl-qPDR.js +964 -0
- package/dist/ordinal-CD64W6lf.js +65 -0
- package/dist/packet-RMMSAZCW-DfA9M99B.js +3 -0
- package/dist/path-BjiRrKY7.js +85 -0
- package/dist/pie-UPGHQEXC-Bujrkgkt.js +3 -0
- package/dist/pieDiagram-SKSYHLDU-xow4mVuZ.js +165 -0
- package/dist/quadrantDiagram-337W2JSQ-CV2tMWXO.js +1974 -0
- package/dist/radar-KQ55EAFF-DEzDT04F.js +3 -0
- package/dist/react-docs-ui.css +1 -1
- package/dist/react-docs-ui.es.js +19 -19
- package/dist/requirementDiagram-Z7DCOOCP-Bx6NAgqy.js +2201 -0
- package/dist/rough.esm-BOvWpVpy.js +1352 -0
- package/dist/sankeyDiagram-WA2Y5GQK-CvTU-CXN.js +920 -0
- package/dist/sequenceDiagram-2WXFIKYE-1wYHvZEI.js +4109 -0
- package/dist/src-DI0MZP4m.js +2146 -0
- package/dist/stateDiagram-RAJIS63D-DFmbSHPX.js +217 -0
- package/dist/stateDiagram-v2-FVOUBMTO-TjYtTjLB.js +27 -0
- package/dist/timeline-definition-YZTLITO2-BAK411Yg.js +830 -0
- package/dist/treemap-KZPCXAKY-DThdSsPR.js +3 -0
- package/dist/types/components/AnnouncementBar.d.ts +12 -0
- package/dist/types/components/AnnouncementBar.d.ts.map +1 -0
- package/dist/types/components/DocsLayout.d.ts +10 -2
- package/dist/types/components/DocsLayout.d.ts.map +1 -1
- package/dist/types/components/HeaderNav.d.ts +17 -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 -1
- package/dist/types/components/MobileSidebar.d.ts.map +1 -1
- package/dist/types/components/PageFeedback.d.ts +11 -0
- package/dist/types/components/PageFeedback.d.ts.map +1 -0
- package/dist/types/components/PageMetaActions.d.ts +15 -0
- package/dist/types/components/PageMetaActions.d.ts.map +1 -0
- package/dist/types/components/PageNavigation.d.ts +2 -1
- package/dist/types/components/PageNavigation.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/SidebarNav.d.ts +2 -1
- package/dist/types/components/SidebarNav.d.ts.map +1 -1
- package/dist/types/components/mdx-components/Mermaid.d.ts +6 -0
- package/dist/types/components/mdx-components/Mermaid.d.ts.map +1 -0
- package/dist/types/components/mdx-components/Tabs.d.ts +13 -0
- package/dist/types/components/mdx-components/Tabs.d.ts.map +1 -0
- package/dist/types/components/mdx-components/index.d.ts +2 -0
- package/dist/types/components/mdx-components/index.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/lib/component-scanner.d.ts.map +1 -1
- package/dist/types/lib/config.d.ts +52 -0
- package/dist/types/lib/config.d.ts.map +1 -1
- package/dist/types/lib/navigation.d.ts +1 -1
- package/dist/types/lib/navigation.d.ts.map +1 -1
- package/dist/types/lib/page-meta.d.ts +16 -0
- package/dist/types/lib/page-meta.d.ts.map +1 -0
- package/dist/types/lib/search/build/index-generator.d.ts.map +1 -1
- package/dist/types/lib/search/build/types.d.ts +1 -0
- package/dist/types/lib/search/build/types.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/versioning.d.ts +6 -0
- package/dist/types/lib/versioning.d.ts.map +1 -0
- package/dist/vennDiagram-LZ73GAT5-B7dft0U9.js +1858 -0
- package/dist/xychartDiagram-JWTSCODW-CXtfEnJM.js +2041 -0
- package/package.json +6 -2
- /package/dist/{AIProvider-C1_b1iKH.js → AIProvider-niZNPSGi.js} +0 -0
- /package/dist/{context-menu-CB7erSoV.js → context-menu-BIQsQup7.js} +0 -0
- /package/dist/{dialog-DQ6nkP0y.js → dialog-D8otbqQL.js} +0 -0
- /package/dist/{mdx-components-Dxpipc50.js → mdx-components-TEc3uhbY.js} +0 -0
- /package/dist/{use-toast-d9VPBjMn.js → use-toast-DK69oadB.js} +0 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as u } from "./
|
|
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
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { SKIP as
|
|
17
|
-
import
|
|
1
|
+
import { t as e } from "./utils-Ct96Mtjw.js";
|
|
2
|
+
import { S as t, b as n, c as r, d as i, h as a, l as o, p as s, s as c, t as l, v as u, x as d, y as f } from "./mdx-components-m1cGPhc8.js";
|
|
3
|
+
import { t as p } from "./use-toast-DK69oadB.js";
|
|
4
|
+
import { l as m, r as h, t as g, u as _ } from "./dialog-D8otbqQL.js";
|
|
5
|
+
import * as v from "react";
|
|
6
|
+
import { Check as y, Copy as b, Download as ee, ExternalLink as x, Maximize as te, Minimize as ne, RefreshCw as re, RotateCcw as ie, RotateCw as ae, Search as oe, X as se, ZoomIn as ce, ZoomOut as le } from "lucide-react";
|
|
7
|
+
import { Link as ue, useParams as S } from "react-router-dom";
|
|
8
|
+
import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
9
|
+
import E from "remark-gfm";
|
|
10
|
+
import D from "remark-math";
|
|
11
|
+
import O from "react-markdown";
|
|
12
|
+
import k from "rehype-autolink-headings";
|
|
13
|
+
import de from "rehype-slug";
|
|
14
|
+
import A from "rehype-raw";
|
|
15
|
+
import j from "rehype-katex";
|
|
16
|
+
import { SKIP as M, visit as N } from "unist-util-visit";
|
|
17
|
+
import P from "katex-physics";
|
|
18
18
|
//#region src/lib/rehype-component.ts
|
|
19
|
-
function
|
|
19
|
+
function F(e) {
|
|
20
20
|
let t = /* @__PURE__ */ new Map();
|
|
21
21
|
for (let [n] of Object.entries(e)) {
|
|
22
22
|
let e = n.toLowerCase(), r = e.replace(/\./g, "-");
|
|
23
23
|
t.set(e, n), t.set(r, n);
|
|
24
24
|
}
|
|
25
25
|
return () => (e) => {
|
|
26
|
-
|
|
26
|
+
N(e, "element", (e) => {
|
|
27
27
|
let n = e.tagName.toLowerCase(), r = t.get(n);
|
|
28
28
|
r && (e.tagName = r, e.properties = e.properties || {}, e.properties.isComponent = !0);
|
|
29
29
|
});
|
|
@@ -31,7 +31,7 @@ function I(e) {
|
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/lib/image-viewer.ts
|
|
34
|
-
var
|
|
34
|
+
var I = {
|
|
35
35
|
"zh-cn": {
|
|
36
36
|
preview: "预览图片",
|
|
37
37
|
zoomIn: "放大",
|
|
@@ -73,27 +73,27 @@ var L = {
|
|
|
73
73
|
imageLoadError: "Failed to load image"
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function L(e = "zh-cn", t) {
|
|
77
77
|
return {
|
|
78
|
-
...
|
|
78
|
+
...I[e === "en" ? "en" : "zh-cn"],
|
|
79
79
|
...t
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/components/ImageViewer.tsx
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
return Math.min(
|
|
84
|
+
var R = .2, z = 5, fe = .2;
|
|
85
|
+
function B(e) {
|
|
86
|
+
return Math.min(z, Math.max(R, Number(e.toFixed(2))));
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function pe(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 me(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 he(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,263 +101,263 @@ function pe(e) {
|
|
|
101
101
|
return !1;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function V({ open:
|
|
105
|
-
let
|
|
104
|
+
function V({ open: r, onOpenChange: i, src: a, alt: o, title: s, lang: c = "zh-cn", labels: l }) {
|
|
105
|
+
let y = v.useMemo(() => L(c, l), [c, l]), b = v.useRef(null), ue = v.useRef(null), [S, C] = v.useState(1), [E, D] = v.useState(0), [O, k] = v.useState("fit"), [de, A] = v.useState(!1), [j, M] = v.useState(!1), [N, P] = v.useState({
|
|
106
106
|
x: 0,
|
|
107
107
|
y: 0
|
|
108
|
-
}), [
|
|
109
|
-
|
|
108
|
+
}), [F, I] = v.useState(!1), V = v.useRef(/* @__PURE__ */ new Map()), H = v.useRef(null), U = v.useRef(null), W = o?.trim() || s?.trim() || y.imageAltFallback, G = v.useCallback(() => {
|
|
109
|
+
C(1), D(0), k("fit"), M(!1), P({
|
|
110
110
|
x: 0,
|
|
111
111
|
y: 0
|
|
112
|
-
}),
|
|
112
|
+
}), I(!1), V.current.clear(), H.current = null, U.current = null;
|
|
113
113
|
}, []);
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
|
|
114
|
+
v.useEffect(() => {
|
|
115
|
+
if (r) {
|
|
116
|
+
G();
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
}, [
|
|
121
|
-
document.fullscreenElement ||
|
|
122
|
-
}, [
|
|
119
|
+
A(!1);
|
|
120
|
+
}, [r, G]), v.useEffect(() => {
|
|
121
|
+
document.fullscreenElement || A(!1);
|
|
122
|
+
}, [r]), v.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 ge = v.useMemo(() => ({
|
|
131
|
+
transform: `translate(${N.x}px, ${N.y}px) scale(${S}) rotate(${E}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
|
+
E,
|
|
138
|
+
S,
|
|
139
|
+
N.x,
|
|
140
|
+
N.y
|
|
141
|
+
]), K = v.useCallback(() => {
|
|
142
|
+
k("actual"), C((e) => B(e + fe));
|
|
143
|
+
}, []), q = v.useCallback(() => {
|
|
144
|
+
k("actual"), C((e) => B(e - fe));
|
|
145
|
+
}, []), J = v.useCallback(() => {
|
|
146
|
+
k("fit"), C(1), P({
|
|
147
147
|
x: 0,
|
|
148
148
|
y: 0
|
|
149
149
|
});
|
|
150
|
-
}, []),
|
|
151
|
-
|
|
150
|
+
}, []), Y = v.useCallback(() => {
|
|
151
|
+
k("actual"), C(1), P({
|
|
152
152
|
x: 0,
|
|
153
153
|
y: 0
|
|
154
154
|
});
|
|
155
|
-
}, []), X =
|
|
156
|
-
|
|
157
|
-
}, []), Z =
|
|
158
|
-
|
|
159
|
-
}, []), _e =
|
|
160
|
-
let e =
|
|
155
|
+
}, []), X = v.useCallback(() => {
|
|
156
|
+
D((e) => e - 90);
|
|
157
|
+
}, []), Z = v.useCallback(() => {
|
|
158
|
+
D((e) => e + 90);
|
|
159
|
+
}, []), _e = v.useCallback(async () => {
|
|
160
|
+
let e = pe(a, s, o), t = null;
|
|
161
161
|
try {
|
|
162
|
-
if (
|
|
163
|
-
|
|
162
|
+
if (he(a)) {
|
|
163
|
+
me(a, e), p({ description: y.downloadSuccess });
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
} catch {}
|
|
167
167
|
try {
|
|
168
|
-
let n = await fetch(
|
|
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), me(t, e), p({ description: y.downloadSuccess });
|
|
172
172
|
} catch {
|
|
173
|
-
|
|
173
|
+
p({
|
|
174
174
|
variant: "destructive",
|
|
175
|
-
description:
|
|
175
|
+
description: y.downloadError
|
|
176
176
|
});
|
|
177
177
|
} finally {
|
|
178
178
|
t && URL.revokeObjectURL(t);
|
|
179
179
|
}
|
|
180
180
|
}, [
|
|
181
|
-
s,
|
|
182
|
-
S.downloadError,
|
|
183
|
-
S.downloadSuccess,
|
|
184
181
|
o,
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
y.downloadError,
|
|
183
|
+
y.downloadSuccess,
|
|
184
|
+
a,
|
|
185
|
+
s
|
|
186
|
+
]), ve = v.useCallback(() => {
|
|
187
187
|
try {
|
|
188
|
-
window.open(
|
|
188
|
+
window.open(a, "_blank", "noopener,noreferrer");
|
|
189
189
|
} catch {
|
|
190
|
-
|
|
190
|
+
p({
|
|
191
191
|
variant: "destructive",
|
|
192
|
-
description:
|
|
192
|
+
description: y.openInNewTabError
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
}, [
|
|
196
|
-
let e =
|
|
195
|
+
}, [y.openInNewTabError, a]), Q = v.useCallback(async () => {
|
|
196
|
+
let e = b.current;
|
|
197
197
|
if (!e?.requestFullscreen) {
|
|
198
|
-
|
|
198
|
+
p({ description: y.fullscreenError });
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
try {
|
|
202
202
|
document.fullscreenElement ? await document.exitFullscreen() : await e.requestFullscreen();
|
|
203
203
|
} catch {
|
|
204
|
-
|
|
204
|
+
p({ description: y.fullscreenError });
|
|
205
205
|
}
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
if (!
|
|
209
|
-
let
|
|
210
|
-
e.key === "+" ? (e.preventDefault(),
|
|
206
|
+
}, [y.fullscreenError]);
|
|
207
|
+
v.useEffect(() => {
|
|
208
|
+
if (!r) return;
|
|
209
|
+
let e = (e) => {
|
|
210
|
+
e.key === "+" ? (e.preventDefault(), K()) : e.key === "-" ? (e.preventDefault(), q()) : e.key === "0" ? (e.preventDefault(), G()) : e.key === "f" || e.key === "F" ? (e.preventDefault(), Q()) : e.key === "[" ? (e.preventDefault(), X()) : e.key === "]" && (e.preventDefault(), Z());
|
|
211
211
|
};
|
|
212
|
-
return window.addEventListener("keydown",
|
|
213
|
-
window.removeEventListener("keydown",
|
|
212
|
+
return window.addEventListener("keydown", e), () => {
|
|
213
|
+
window.removeEventListener("keydown", e);
|
|
214
214
|
};
|
|
215
215
|
}, [
|
|
216
216
|
Q,
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
r,
|
|
218
|
+
G,
|
|
219
219
|
X,
|
|
220
220
|
Z,
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
K,
|
|
222
|
+
q
|
|
223
223
|
]);
|
|
224
|
-
let $ =
|
|
225
|
-
e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ?
|
|
226
|
-
}, [
|
|
227
|
-
|
|
228
|
-
if (!
|
|
229
|
-
let
|
|
230
|
-
if (
|
|
231
|
-
|
|
224
|
+
let $ = v.useCallback((e) => {
|
|
225
|
+
e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ? K() : q();
|
|
226
|
+
}, [K, q]);
|
|
227
|
+
v.useEffect(() => {
|
|
228
|
+
if (!r) return;
|
|
229
|
+
let e = b.current;
|
|
230
|
+
if (e) return e.addEventListener("wheel", $, { passive: !1 }), () => {
|
|
231
|
+
e.removeEventListener("wheel", $);
|
|
232
232
|
};
|
|
233
|
-
}, [$,
|
|
234
|
-
let ye =
|
|
235
|
-
|
|
233
|
+
}, [$, r]);
|
|
234
|
+
let ye = v.useCallback((e) => {
|
|
235
|
+
V.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 =
|
|
242
|
-
|
|
239
|
+
let t = Array.from(V.current.values());
|
|
240
|
+
if (t.length === 2 && U.current) {
|
|
241
|
+
let [e, n] = t, r = Math.hypot(n.x - e.x, n.y - e.y), i = B(U.current.startScale * (r / U.current.startDistance));
|
|
242
|
+
k("actual"), C(i);
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
-
let n =
|
|
246
|
-
!n || n.pointerId !== e.pointerId ||
|
|
245
|
+
let n = H.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 = v.useCallback((e) => {
|
|
251
|
+
e && b.current?.hasPointerCapture(e.pointerId) && b.current.releasePointerCapture(e.pointerId), e && V.current.delete(e.pointerId), H.current = null, V.current.size < 2 && (U.current = null), I(!1);
|
|
252
|
+
}, []), xe = v.useCallback((e) => {
|
|
253
|
+
if (e.button !== 0 || j) return;
|
|
254
|
+
e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), V.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(V.current.values());
|
|
259
259
|
if (t.length === 2) {
|
|
260
260
|
let [e, n] = t;
|
|
261
|
-
|
|
261
|
+
U.current = {
|
|
262
262
|
startDistance: Math.max(1, Math.hypot(n.x - e.x, n.y - e.y)),
|
|
263
|
-
startScale:
|
|
264
|
-
},
|
|
263
|
+
startScale: S
|
|
264
|
+
}, H.current = null, I(!1);
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
H.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
|
+
S,
|
|
277
|
+
N.x,
|
|
278
|
+
N.y
|
|
279
279
|
]);
|
|
280
|
-
|
|
281
|
-
if (!
|
|
282
|
-
let
|
|
283
|
-
let t =
|
|
280
|
+
v.useEffect(() => {
|
|
281
|
+
if (!r) return;
|
|
282
|
+
let e = (e) => {
|
|
283
|
+
let t = b.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", e, {
|
|
287
287
|
passive: !1,
|
|
288
288
|
capture: !0
|
|
289
289
|
}), () => {
|
|
290
|
-
window.removeEventListener("wheel",
|
|
290
|
+
window.removeEventListener("wheel", e, { capture: !0 });
|
|
291
291
|
};
|
|
292
|
-
}, [$,
|
|
293
|
-
let Se =
|
|
292
|
+
}, [$, r]);
|
|
293
|
+
let Se = v.useMemo(() => [
|
|
294
294
|
{
|
|
295
295
|
key: "zoom-in",
|
|
296
|
-
label:
|
|
297
|
-
icon:
|
|
298
|
-
onClick:
|
|
299
|
-
disabled:
|
|
296
|
+
label: y.zoomIn,
|
|
297
|
+
icon: ce,
|
|
298
|
+
onClick: K,
|
|
299
|
+
disabled: j || S >= z
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
302
|
key: "zoom-out",
|
|
303
|
-
label:
|
|
304
|
-
icon:
|
|
305
|
-
onClick:
|
|
306
|
-
disabled:
|
|
303
|
+
label: y.zoomOut,
|
|
304
|
+
icon: le,
|
|
305
|
+
onClick: q,
|
|
306
|
+
disabled: j || S <= R
|
|
307
307
|
},
|
|
308
308
|
{
|
|
309
309
|
key: "fit",
|
|
310
|
-
label:
|
|
311
|
-
icon:
|
|
312
|
-
onClick:
|
|
313
|
-
disabled:
|
|
310
|
+
label: y.fit,
|
|
311
|
+
icon: ne,
|
|
312
|
+
onClick: J,
|
|
313
|
+
disabled: j
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
key: "actual-size",
|
|
317
|
-
label:
|
|
318
|
-
icon:
|
|
319
|
-
onClick:
|
|
320
|
-
disabled:
|
|
317
|
+
label: y.actualSize,
|
|
318
|
+
icon: oe,
|
|
319
|
+
onClick: Y,
|
|
320
|
+
disabled: j
|
|
321
321
|
},
|
|
322
322
|
{
|
|
323
323
|
key: "reset",
|
|
324
|
-
label:
|
|
325
|
-
icon:
|
|
326
|
-
onClick:
|
|
327
|
-
disabled:
|
|
324
|
+
label: y.reset,
|
|
325
|
+
icon: re,
|
|
326
|
+
onClick: G,
|
|
327
|
+
disabled: j
|
|
328
328
|
},
|
|
329
329
|
{
|
|
330
330
|
key: "rotate-left",
|
|
331
|
-
label:
|
|
332
|
-
icon:
|
|
331
|
+
label: y.rotateLeft,
|
|
332
|
+
icon: ie,
|
|
333
333
|
onClick: X,
|
|
334
|
-
disabled:
|
|
334
|
+
disabled: j
|
|
335
335
|
},
|
|
336
336
|
{
|
|
337
337
|
key: "rotate-right",
|
|
338
|
-
label:
|
|
339
|
-
icon:
|
|
338
|
+
label: y.rotateRight,
|
|
339
|
+
icon: ae,
|
|
340
340
|
onClick: Z,
|
|
341
|
-
disabled:
|
|
341
|
+
disabled: j
|
|
342
342
|
},
|
|
343
343
|
{
|
|
344
344
|
key: "fullscreen",
|
|
345
|
-
label:
|
|
346
|
-
icon:
|
|
345
|
+
label: y.fullscreen,
|
|
346
|
+
icon: te,
|
|
347
347
|
onClick: () => void Q(),
|
|
348
348
|
disabled: !1
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
key: "download",
|
|
352
|
-
label:
|
|
353
|
-
icon:
|
|
352
|
+
label: y.download,
|
|
353
|
+
icon: ee,
|
|
354
354
|
onClick: _e,
|
|
355
|
-
disabled:
|
|
355
|
+
disabled: j
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
key: "new-tab",
|
|
359
|
-
label:
|
|
360
|
-
icon:
|
|
359
|
+
label: y.openInNewTab,
|
|
360
|
+
icon: x,
|
|
361
361
|
onClick: ve,
|
|
362
362
|
disabled: !1
|
|
363
363
|
}
|
|
@@ -365,71 +365,71 @@ function V({ open: e, onOpenChange: a, src: o, alt: s, title: c, lang: _ = "zh-c
|
|
|
365
365
|
_e,
|
|
366
366
|
Q,
|
|
367
367
|
ve,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
368
|
+
j,
|
|
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
|
+
G,
|
|
380
380
|
X,
|
|
381
381
|
Z,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
he,
|
|
382
|
+
S,
|
|
383
|
+
Y,
|
|
385
384
|
J,
|
|
386
|
-
|
|
385
|
+
K,
|
|
386
|
+
q
|
|
387
387
|
]);
|
|
388
|
-
return /* @__PURE__ */
|
|
389
|
-
open:
|
|
390
|
-
onOpenChange:
|
|
391
|
-
children: /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ w(g, {
|
|
389
|
+
open: r,
|
|
390
|
+
onOpenChange: i,
|
|
391
|
+
children: /* @__PURE__ */ T(h, {
|
|
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__ */ w(_, { children: W }),
|
|
396
|
+
/* @__PURE__ */ w(m, { children: y.close }),
|
|
397
|
+
/* @__PURE__ */ T(n, {
|
|
398
398
|
delayDuration: 100,
|
|
399
|
-
children: [/* @__PURE__ */
|
|
399
|
+
children: [/* @__PURE__ */ T("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__ */ T("div", {
|
|
402
402
|
className: "min-w-0",
|
|
403
|
-
children: [/* @__PURE__ */
|
|
403
|
+
children: [/* @__PURE__ */ w("p", {
|
|
404
404
|
className: "truncate text-sm font-medium",
|
|
405
|
-
children:
|
|
406
|
-
}), /* @__PURE__ */
|
|
405
|
+
children: W
|
|
406
|
+
}), /* @__PURE__ */ T("p", {
|
|
407
407
|
className: "text-xs text-zinc-400",
|
|
408
408
|
children: [
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
O === "fit" ? y.fit : `${Math.round(S * 100)}%`,
|
|
410
|
+
E === 0 ? "" : ` · ${E}deg`,
|
|
411
|
+
de ? ` · ${y.fullscreen}` : ""
|
|
412
412
|
]
|
|
413
413
|
})]
|
|
414
|
-
}), /* @__PURE__ */
|
|
414
|
+
}), /* @__PURE__ */ w(t, {
|
|
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: () => i(!1),
|
|
420
|
+
"aria-label": y.close,
|
|
421
|
+
title: y.close,
|
|
422
|
+
children: /* @__PURE__ */ w(se, { className: "h-4 w-4" })
|
|
423
423
|
})]
|
|
424
|
-
}), /* @__PURE__ */
|
|
424
|
+
}), /* @__PURE__ */ w("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__ */ w("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 n = e.icon;
|
|
430
|
+
return /* @__PURE__ */ T(u, { children: [/* @__PURE__ */ w(d, {
|
|
431
431
|
asChild: !0,
|
|
432
|
-
children: /* @__PURE__ */
|
|
432
|
+
children: /* @__PURE__ */ w(t, {
|
|
433
433
|
type: "button",
|
|
434
434
|
size: "icon",
|
|
435
435
|
variant: "secondary",
|
|
@@ -438,43 +438,43 @@ function V({ open: e, onOpenChange: a, src: o, alt: s, title: c, lang: _ = "zh-c
|
|
|
438
438
|
disabled: e.disabled,
|
|
439
439
|
"aria-label": e.label,
|
|
440
440
|
title: e.label,
|
|
441
|
-
children: /* @__PURE__ */
|
|
441
|
+
children: /* @__PURE__ */ w(n, { className: "h-4 w-4" })
|
|
442
442
|
})
|
|
443
|
-
}), /* @__PURE__ */
|
|
443
|
+
}), /* @__PURE__ */ w(f, { children: e.label })] }, e.key);
|
|
444
444
|
})
|
|
445
445
|
})
|
|
446
446
|
})]
|
|
447
447
|
}),
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
ref:
|
|
448
|
+
/* @__PURE__ */ w("div", {
|
|
449
|
+
ref: b,
|
|
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__ */ T("div", {
|
|
456
456
|
className: "flex flex-col items-center gap-2 text-center",
|
|
457
457
|
children: [
|
|
458
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ w("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__ */ w(oe, { className: "h-5 w-5" })
|
|
461
461
|
}),
|
|
462
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ w("p", {
|
|
463
463
|
className: "text-sm font-medium",
|
|
464
|
-
children:
|
|
464
|
+
children: y.imageLoadError
|
|
465
465
|
}),
|
|
466
|
-
/* @__PURE__ */
|
|
466
|
+
/* @__PURE__ */ w("p", {
|
|
467
467
|
className: "max-w-md text-xs text-zinc-400",
|
|
468
|
-
children:
|
|
468
|
+
children: a
|
|
469
469
|
})
|
|
470
470
|
]
|
|
471
|
-
}) : /* @__PURE__ */
|
|
472
|
-
ref:
|
|
473
|
-
src:
|
|
474
|
-
alt:
|
|
475
|
-
className:
|
|
476
|
-
style:
|
|
477
|
-
onError: () =>
|
|
471
|
+
}) : /* @__PURE__ */ w("img", {
|
|
472
|
+
ref: ue,
|
|
473
|
+
src: a,
|
|
474
|
+
alt: W,
|
|
475
|
+
className: e("max-h-full max-w-full select-none rounded-lg object-contain shadow-2xl", O === "fit" ? "h-auto w-auto" : ""),
|
|
476
|
+
style: ge,
|
|
477
|
+
onError: () => M(!0),
|
|
478
478
|
draggable: !1
|
|
479
479
|
})
|
|
480
480
|
})
|
|
@@ -486,7 +486,7 @@ function V({ open: e, onOpenChange: a, src: o, alt: s, title: c, lang: _ = "zh-c
|
|
|
486
486
|
//#region src/components/MdxContent.tsx
|
|
487
487
|
function H() {
|
|
488
488
|
return (e) => {
|
|
489
|
-
|
|
489
|
+
N(e, "element", (e, t, n) => {
|
|
490
490
|
if (e.tagName === "p" && n && typeof t == "number" && e.children.some((e) => e.type === "element" && (U(e) || e.tagName === "pre"))) {
|
|
491
491
|
let r = [], i = [], a = () => {
|
|
492
492
|
i.length > 0 && (r.push({
|
|
@@ -497,7 +497,7 @@ function H() {
|
|
|
497
497
|
}), i = []);
|
|
498
498
|
};
|
|
499
499
|
for (let t of e.children) t.type === "element" && (U(t) || t.tagName === "pre") ? (a(), r.push(t)) : i.push(t);
|
|
500
|
-
return a(), n.children.splice(t, 1, ...r), [
|
|
500
|
+
return a(), n.children.splice(t, 1, ...r), [M, t];
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
503
|
};
|
|
@@ -508,13 +508,15 @@ function U(e) {
|
|
|
508
508
|
return t.charAt(0) === t.charAt(0).toUpperCase() && t.charAt(0) !== t.charAt(0).toLowerCase();
|
|
509
509
|
}
|
|
510
510
|
function W(e) {
|
|
511
|
-
|
|
511
|
+
let t = e, n = "";
|
|
512
|
+
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) => {
|
|
512
513
|
let i = G(n), a = t.toLowerCase().replace(/\./g, "-");
|
|
513
514
|
return `<${a}${i}>${r}</${a}>`;
|
|
514
515
|
}).replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*?)\s*\/>/g, (e, t, n) => {
|
|
515
516
|
let r = G(n), i = t.toLowerCase().replace(/\./g, "-");
|
|
516
517
|
return `<${i}${r}></${i}>`;
|
|
517
518
|
});
|
|
519
|
+
return t;
|
|
518
520
|
}
|
|
519
521
|
function G(e) {
|
|
520
522
|
if (!e) return "";
|
|
@@ -525,7 +527,7 @@ function G(e) {
|
|
|
525
527
|
}
|
|
526
528
|
return t.length > 0 ? " " + t.join(" ") : "";
|
|
527
529
|
}
|
|
528
|
-
function
|
|
530
|
+
function ge(e) {
|
|
529
531
|
let t = {};
|
|
530
532
|
for (let [n, r] of Object.entries(e)) if (n.startsWith("data-")) {
|
|
531
533
|
let e = n.slice(5);
|
|
@@ -548,7 +550,7 @@ function K(e) {
|
|
|
548
550
|
}
|
|
549
551
|
return t;
|
|
550
552
|
}
|
|
551
|
-
var
|
|
553
|
+
var K = {
|
|
552
554
|
js: "JavaScript",
|
|
553
555
|
javascript: "JavaScript",
|
|
554
556
|
ts: "TypeScript",
|
|
@@ -590,10 +592,10 @@ var q = {
|
|
|
590
592
|
diff: "Diff",
|
|
591
593
|
text: "Text"
|
|
592
594
|
};
|
|
593
|
-
function
|
|
594
|
-
let [s, l] =
|
|
595
|
+
function q({ className: e, children: t, meta: n, codeHighlight: r, shikiBundle: a }) {
|
|
596
|
+
let [s, l] = v.useState(""), [u, d] = v.useState(!1), [f, p] = v.useState(!1), m = v.useMemo(() => n?.toLowerCase().includes("showlinenumbers") ?? !1, [n]), h = /language-(\w+)/.exec(e || ""), g = h ? h[1] : "text", _ = i(g), ee = K[g.toLowerCase()] || g.toUpperCase(), x = v.useMemo(() => {
|
|
595
597
|
let e = "";
|
|
596
|
-
return e = typeof
|
|
598
|
+
return e = typeof t == "string" ? t : v.Children.count(t) === 1 && typeof t == "string" ? String(t) : v.Children.toArray(t).map((e) => {
|
|
597
599
|
if (typeof e == "string") return e;
|
|
598
600
|
if (typeof e == "object" && e && "props" in e) {
|
|
599
601
|
let t = e.props;
|
|
@@ -604,8 +606,8 @@ function me({ className: t, children: n, meta: r, codeHighlight: i, shikiBundle:
|
|
|
604
606
|
}
|
|
605
607
|
return "";
|
|
606
608
|
}).join(""), e.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
607
|
-
}, [
|
|
608
|
-
|
|
609
|
+
}, [t]);
|
|
610
|
+
v.useEffect(() => {
|
|
609
611
|
let e = () => {
|
|
610
612
|
d(document.documentElement.classList.contains("dark"));
|
|
611
613
|
};
|
|
@@ -615,21 +617,21 @@ function me({ className: t, children: n, meta: r, codeHighlight: i, shikiBundle:
|
|
|
615
617
|
attributes: !0,
|
|
616
618
|
attributeFilter: ["class"]
|
|
617
619
|
}), () => t.disconnect();
|
|
618
|
-
}, []),
|
|
620
|
+
}, []), v.useEffect(() => {
|
|
619
621
|
o(x, {
|
|
620
|
-
lang:
|
|
621
|
-
theme: c(u,
|
|
622
|
+
lang: _,
|
|
623
|
+
theme: c(u, r, a),
|
|
622
624
|
showLineNumbers: m
|
|
623
|
-
},
|
|
625
|
+
}, r, a).then(l);
|
|
624
626
|
}, [
|
|
625
627
|
x,
|
|
626
|
-
|
|
628
|
+
_,
|
|
627
629
|
u,
|
|
628
630
|
m,
|
|
629
|
-
|
|
631
|
+
r,
|
|
630
632
|
a
|
|
631
633
|
]);
|
|
632
|
-
let te =
|
|
634
|
+
let te = v.useCallback(async () => {
|
|
633
635
|
let e = async (e) => {
|
|
634
636
|
if (navigator.clipboard && window.isSecureContext) await navigator.clipboard.writeText(e);
|
|
635
637
|
else {
|
|
@@ -648,67 +650,67 @@ function me({ className: t, children: n, meta: r, codeHighlight: i, shikiBundle:
|
|
|
648
650
|
console.error("Failed to copy:", e);
|
|
649
651
|
}
|
|
650
652
|
}, [x]);
|
|
651
|
-
return s ? /* @__PURE__ */
|
|
653
|
+
return s ? /* @__PURE__ */ T("div", {
|
|
652
654
|
className: "code-block-wrapper",
|
|
653
655
|
children: [
|
|
654
|
-
/* @__PURE__ */
|
|
656
|
+
/* @__PURE__ */ w("span", {
|
|
655
657
|
className: "code-lang-label",
|
|
656
658
|
children: ee
|
|
657
659
|
}),
|
|
658
|
-
/* @__PURE__ */
|
|
660
|
+
/* @__PURE__ */ w("button", {
|
|
659
661
|
className: "code-copy-btn",
|
|
660
662
|
onClick: te,
|
|
661
663
|
title: f ? "已复制" : "复制代码",
|
|
662
664
|
"aria-label": "复制代码",
|
|
663
|
-
children: f ? /* @__PURE__ */
|
|
665
|
+
children: f ? /* @__PURE__ */ w(y, { className: "h-4 w-4 text-green-500" }) : /* @__PURE__ */ w(b, { className: "h-4 w-4" })
|
|
664
666
|
}),
|
|
665
|
-
/* @__PURE__ */
|
|
667
|
+
/* @__PURE__ */ w("pre", {
|
|
666
668
|
className: `shiki-code-block${m ? " show-line-numbers" : ""}`,
|
|
667
669
|
dangerouslySetInnerHTML: { __html: s }
|
|
668
670
|
})
|
|
669
671
|
]
|
|
670
|
-
}) : /* @__PURE__ */
|
|
672
|
+
}) : /* @__PURE__ */ w("div", {
|
|
671
673
|
className: "code-block-wrapper",
|
|
672
|
-
children: /* @__PURE__ */
|
|
674
|
+
children: /* @__PURE__ */ w("pre", {
|
|
673
675
|
className: "shiki-code-block",
|
|
674
|
-
children: /* @__PURE__ */
|
|
676
|
+
children: /* @__PURE__ */ w("code", { children: x })
|
|
675
677
|
})
|
|
676
678
|
});
|
|
677
679
|
}
|
|
678
680
|
function J({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, node: o, ...s }) {
|
|
679
|
-
let [c, l] =
|
|
680
|
-
return n ? t?.enabled === !1 ? /* @__PURE__ */
|
|
681
|
+
let [c, l] = v.useState(!1), u = v.useMemo(() => L(e, t?.labels), [e, t?.labels]);
|
|
682
|
+
return n ? t?.enabled === !1 ? /* @__PURE__ */ w("img", {
|
|
681
683
|
src: n,
|
|
682
684
|
alt: r || u.imageAltFallback,
|
|
683
685
|
title: i,
|
|
684
686
|
className: a,
|
|
685
687
|
...s
|
|
686
|
-
}) : /* @__PURE__ */
|
|
688
|
+
}) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ T("span", {
|
|
687
689
|
className: "not-prose group relative my-6 block",
|
|
688
|
-
children: [/* @__PURE__ */
|
|
690
|
+
children: [/* @__PURE__ */ w("button", {
|
|
689
691
|
type: "button",
|
|
690
692
|
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",
|
|
691
693
|
onClick: () => l(!0),
|
|
692
694
|
"aria-label": u.preview,
|
|
693
695
|
title: u.preview,
|
|
694
|
-
children: /* @__PURE__ */
|
|
696
|
+
children: /* @__PURE__ */ w("img", {
|
|
695
697
|
src: n,
|
|
696
698
|
alt: r || u.imageAltFallback,
|
|
697
699
|
title: i,
|
|
698
700
|
className: a ?? "h-auto w-full rounded-2xl object-contain",
|
|
699
701
|
...s
|
|
700
702
|
})
|
|
701
|
-
}), /* @__PURE__ */
|
|
703
|
+
}), /* @__PURE__ */ T("button", {
|
|
702
704
|
type: "button",
|
|
703
705
|
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",
|
|
704
706
|
onClick: () => l(!0),
|
|
705
707
|
"aria-label": u.preview,
|
|
706
708
|
children: [
|
|
707
|
-
/* @__PURE__ */
|
|
709
|
+
/* @__PURE__ */ w("span", {
|
|
708
710
|
className: "sr-only",
|
|
709
711
|
children: u.preview
|
|
710
712
|
}),
|
|
711
|
-
/* @__PURE__ */
|
|
713
|
+
/* @__PURE__ */ T("svg", {
|
|
712
714
|
"aria-hidden": "true",
|
|
713
715
|
viewBox: "0 0 24 24",
|
|
714
716
|
className: "h-3.5 w-3.5",
|
|
@@ -717,16 +719,16 @@ function J({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
717
719
|
strokeWidth: "2",
|
|
718
720
|
strokeLinecap: "round",
|
|
719
721
|
strokeLinejoin: "round",
|
|
720
|
-
children: [/* @__PURE__ */
|
|
722
|
+
children: [/* @__PURE__ */ w("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z" }), /* @__PURE__ */ w("circle", {
|
|
721
723
|
cx: "12",
|
|
722
724
|
cy: "12",
|
|
723
725
|
r: "3"
|
|
724
726
|
})]
|
|
725
727
|
}),
|
|
726
|
-
/* @__PURE__ */
|
|
728
|
+
/* @__PURE__ */ w("span", { children: u.preview })
|
|
727
729
|
]
|
|
728
730
|
})]
|
|
729
|
-
}), /* @__PURE__ */
|
|
731
|
+
}), /* @__PURE__ */ w(V, {
|
|
730
732
|
open: c,
|
|
731
733
|
onOpenChange: l,
|
|
732
734
|
src: n,
|
|
@@ -736,39 +738,39 @@ function J({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, n
|
|
|
736
738
|
labels: t?.labels
|
|
737
739
|
})] }) : null;
|
|
738
740
|
}
|
|
739
|
-
function Y({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight:
|
|
740
|
-
let
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}, [
|
|
744
|
-
let
|
|
741
|
+
function Y({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: i, shikiBundle: o }) {
|
|
742
|
+
let c = S(), u = c.lang || "zh-cn", d = c.version, f = s();
|
|
743
|
+
v.useEffect(() => {
|
|
744
|
+
r(i, o);
|
|
745
|
+
}, [i, o]);
|
|
746
|
+
let p = v.useMemo(() => {
|
|
745
747
|
if (!t) return e;
|
|
746
748
|
let n = e.split("\n"), r = !1;
|
|
747
749
|
return n.filter((e) => !r && e.startsWith("# ") ? (r = !0, !1) : !0).join("\n");
|
|
748
|
-
}, [e, t]),
|
|
750
|
+
}, [e, t]), m = v.useMemo(() => W(p), [p]), h = v.useMemo(() => {
|
|
749
751
|
let e = /* @__PURE__ */ new Map();
|
|
750
|
-
return
|
|
751
|
-
let r =
|
|
752
|
-
let r =
|
|
753
|
-
return
|
|
752
|
+
return f && Object.entries(f).forEach(([t, n]) => {
|
|
753
|
+
let r = v.memo(({ children: e, ...t }) => {
|
|
754
|
+
let r = ge(t);
|
|
755
|
+
return v.createElement(n, r, e);
|
|
754
756
|
});
|
|
755
757
|
if (e.set(t, r), t.includes(".")) {
|
|
756
758
|
let [n, i] = t.split("."), a = `${n.toLowerCase()}-${i.toLowerCase()}`;
|
|
757
759
|
e.set(a, r);
|
|
758
760
|
}
|
|
759
761
|
}), e;
|
|
760
|
-
}, [
|
|
761
|
-
return /* @__PURE__ */
|
|
762
|
+
}, [f]), g = v.useMemo(() => Object.fromEntries(h), [h]);
|
|
763
|
+
return /* @__PURE__ */ w("div", {
|
|
762
764
|
className: "prose dark:prose-invert max-w-none",
|
|
763
|
-
children: /* @__PURE__ */
|
|
764
|
-
remarkPlugins: [
|
|
765
|
+
children: /* @__PURE__ */ w(O, {
|
|
766
|
+
remarkPlugins: [E, D],
|
|
765
767
|
rehypePlugins: [
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
768
|
+
de,
|
|
769
|
+
A,
|
|
770
|
+
F(g),
|
|
769
771
|
H,
|
|
770
|
-
[
|
|
771
|
-
[
|
|
772
|
+
[k, { behavior: "append" }],
|
|
773
|
+
[j, {
|
|
772
774
|
strict: !1,
|
|
773
775
|
trust: !0,
|
|
774
776
|
macros: {
|
|
@@ -777,72 +779,74 @@ function Y({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: r, s
|
|
|
777
779
|
"\\Z": "\\mathbb{Z}",
|
|
778
780
|
"\\Q": "\\mathbb{Q}",
|
|
779
781
|
"\\C": "\\mathbb{C}",
|
|
780
|
-
...
|
|
782
|
+
...P
|
|
781
783
|
}
|
|
782
784
|
}]
|
|
783
785
|
],
|
|
784
786
|
components: {
|
|
785
|
-
...
|
|
787
|
+
...g,
|
|
786
788
|
table({ children: e, ...t }) {
|
|
787
|
-
return /* @__PURE__ */
|
|
789
|
+
return /* @__PURE__ */ w("div", {
|
|
788
790
|
className: "overflow-x-auto",
|
|
789
|
-
children: /* @__PURE__ */
|
|
791
|
+
children: /* @__PURE__ */ w("table", {
|
|
790
792
|
...t,
|
|
791
793
|
children: e
|
|
792
794
|
})
|
|
793
795
|
});
|
|
794
796
|
},
|
|
795
797
|
pre({ children: e, ...t }) {
|
|
796
|
-
let n =
|
|
798
|
+
let n = v.Children.toArray(e).find((e) => e?.type === "code" || e?.props?.node?.tagName === "code");
|
|
797
799
|
if (n) {
|
|
798
|
-
let e = n.props, t = e?.className || "", a = e?.node,
|
|
799
|
-
|
|
800
|
+
let e = n.props, t = e?.className || "", r = /language-(\w+)/.exec(t), a = r ? r[1].toLowerCase() : "text", s = e?.node, c = e?.children, u = e?.["data-raw-value"];
|
|
801
|
+
u && (c = u);
|
|
802
|
+
let d = s?.data?.meta || "";
|
|
803
|
+
return a === "mermaid" ? /* @__PURE__ */ w(l, { chart: typeof c == "string" ? c : String(c || "") }) : /* @__PURE__ */ w(q, {
|
|
800
804
|
className: t,
|
|
801
|
-
meta:
|
|
802
|
-
codeHighlight:
|
|
803
|
-
shikiBundle:
|
|
804
|
-
children:
|
|
805
|
+
meta: d,
|
|
806
|
+
codeHighlight: i,
|
|
807
|
+
shikiBundle: o,
|
|
808
|
+
children: c
|
|
805
809
|
});
|
|
806
810
|
}
|
|
807
|
-
return /* @__PURE__ */
|
|
811
|
+
return /* @__PURE__ */ w("pre", {
|
|
808
812
|
...t,
|
|
809
813
|
children: e
|
|
810
814
|
});
|
|
811
815
|
},
|
|
812
816
|
a({ href: e, children: t, ...n }) {
|
|
813
|
-
return e ? e.startsWith("#") ? /* @__PURE__ */
|
|
817
|
+
return e ? e.startsWith("#") ? /* @__PURE__ */ w("a", {
|
|
814
818
|
href: e,
|
|
815
819
|
...n,
|
|
816
820
|
children: t
|
|
817
|
-
}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */
|
|
821
|
+
}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */ w("a", {
|
|
818
822
|
href: e,
|
|
819
823
|
target: "_blank",
|
|
820
824
|
rel: "noopener noreferrer",
|
|
821
825
|
...n,
|
|
822
826
|
children: t
|
|
823
|
-
}) : /* @__PURE__ */
|
|
824
|
-
to:
|
|
827
|
+
}) : /* @__PURE__ */ w(ue, {
|
|
828
|
+
to: a(u, e.startsWith("/") ? e : `/${e}`, d),
|
|
825
829
|
...n,
|
|
826
830
|
children: t
|
|
827
|
-
}) : /* @__PURE__ */
|
|
831
|
+
}) : /* @__PURE__ */ w("a", {
|
|
828
832
|
...n,
|
|
829
833
|
children: t
|
|
830
834
|
});
|
|
831
835
|
},
|
|
832
|
-
img({ src: e, alt: t, title: r, className: i, node: a, ...
|
|
833
|
-
return /* @__PURE__ */
|
|
834
|
-
lang:
|
|
836
|
+
img({ src: e, alt: t, title: r, className: i, node: a, ...o }) {
|
|
837
|
+
return /* @__PURE__ */ w(J, {
|
|
838
|
+
lang: u,
|
|
835
839
|
viewerConfig: n,
|
|
836
840
|
src: e,
|
|
837
841
|
alt: t,
|
|
838
842
|
title: r,
|
|
839
843
|
className: i,
|
|
840
844
|
node: a,
|
|
841
|
-
...
|
|
845
|
+
...o
|
|
842
846
|
});
|
|
843
847
|
}
|
|
844
848
|
},
|
|
845
|
-
children:
|
|
849
|
+
children: m
|
|
846
850
|
})
|
|
847
851
|
});
|
|
848
852
|
}
|