react-docs-ui 0.6.13 → 0.6.15
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/README.md +13 -0
- package/dist/AIChatDialog-W60DtiEW.js +418 -0
- package/dist/AIProvider-C1_b1iKH.js +1066 -0
- package/dist/AISelectionTrigger-MaBGhxTE.js +86 -0
- package/dist/AISettingsPanel-aiMnncnQ.js +524 -0
- package/dist/DocsApp-BBNDiw8A.js +23556 -0
- package/dist/GlobalContextMenu-DG6x5Y5w.js +278 -0
- package/dist/MdxContent-CMB8ZbXo.js +850 -0
- package/dist/MdxContent.lazy-C4rcCv4v.js +1768 -0
- package/dist/SearchDialog-tUSKKsxW.js +403 -0
- package/dist/SearchRuntime-5fXpxDsi.js +23 -0
- package/dist/context-menu-CB7erSoV.js +73 -0
- package/dist/dialog-DQ6nkP0y.js +97 -0
- package/dist/docs-app.es.d.ts +1 -0
- package/dist/docs-app.es.js +7 -9
- package/dist/react-docs-ui.css +2 -1
- package/dist/react-docs-ui.es.js +66 -195
- package/dist/shiki-highlighter-BmQSSJpS.js +7194 -0
- package/dist/theme-provider-fNhx9xK0.js +37 -0
- package/dist/types/components/DocsLayout.d.ts +1 -31
- package/dist/types/components/DocsLayout.d.ts.map +1 -1
- package/dist/types/components/Footer.d.ts +3 -28
- package/dist/types/components/Footer.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 +1 -1
- package/dist/types/components/MobileSidebar.d.ts.map +1 -1
- package/dist/types/components/PageNavigation.d.ts +1 -1
- package/dist/types/components/PageNavigation.d.ts.map +1 -1
- package/dist/types/components/SidebarNav.d.ts +1 -1
- package/dist/types/components/SidebarNav.d.ts.map +1 -1
- package/dist/types/components/TableOfContents.d.ts +1 -1
- package/dist/types/components/TableOfContents.d.ts.map +1 -1
- package/dist/types/components/ai/AIChatDialog.d.ts +1 -1
- package/dist/types/components/ai/AIChatDialog.d.ts.map +1 -1
- package/dist/types/components/ai/AISelectionTrigger.d.ts +1 -1
- package/dist/types/components/ai/AISelectionTrigger.d.ts.map +1 -1
- package/dist/types/components/ai/AISettingsPanel.d.ts +1 -1
- package/dist/types/components/ai/AISettingsPanel.d.ts.map +1 -1
- package/dist/types/components/search/SearchItem.d.ts +1 -2
- package/dist/types/components/search/SearchItem.d.ts.map +1 -1
- package/dist/types/components/ui/button.d.ts +4 -4
- package/dist/types/components/ui/button.d.ts.map +1 -1
- package/dist/types/components/ui/toast.d.ts +3 -3
- package/dist/types/components/ui/toast.d.ts.map +1 -1
- package/dist/types/external-modules.d.ts +38 -0
- package/dist/types/generated/shiki-bundle.d.ts +1 -0
- package/dist/types/generated/shiki-bundle.d.ts.map +1 -1
- package/dist/types/lib/ai/crypto.d.ts.map +1 -1
- package/dist/types/lib/config.d.ts +0 -4
- package/dist/types/lib/config.d.ts.map +1 -1
- package/dist/types/lib/export-utils.d.ts.map +1 -1
- package/dist/types/lib/frontmatter.d.ts +6 -0
- package/dist/types/lib/frontmatter.d.ts.map +1 -0
- package/dist/types/lib/rehype-toc.d.ts.map +1 -1
- package/dist/types/lib/search/search-index-plugin.d.ts.map +1 -1
- package/dist/types/lib/shiki-highlighter.d.ts.map +1 -1
- package/dist/types/mdast.d.ts +53 -0
- package/dist/use-toast-d9VPBjMn.js +98 -0
- package/dist/utils-Ct96Mtjw.js +8 -0
- package/package.json +23 -24
- package/dist/AISettingsPanel-KzfonkeY.js +0 -1171
- package/dist/DocsApp-DTFpyBOl.js +0 -35170
- package/dist/GlobalContextMenu-hGNTKw3S.js +0 -210
- package/dist/MdxContent-B664V_Hk.js +0 -812
- package/dist/MdxContent.lazy-DsQt7MZQ.js +0 -1512
- package/dist/SearchDialog-Cfam5kUW.js +0 -406
- package/dist/SearchRuntime-Dk265vam.js +0 -31
- package/dist/context-menu-CBGG4zJl.js +0 -140
- package/dist/index-ByXnCzVt.js +0 -12
package/README.md
CHANGED
|
@@ -32,6 +32,19 @@ npm run dev
|
|
|
32
32
|
- PWA support
|
|
33
33
|
- AI integration (requires API key)
|
|
34
34
|
|
|
35
|
+
### AI Agent Skills
|
|
36
|
+
|
|
37
|
+
We provide AI Agent Skills to help you work more efficiently with react-docs-ui:
|
|
38
|
+
|
|
39
|
+
- [React Docs UI Skills](https://github.com/shenjianZ/react-docs-skills)
|
|
40
|
+
|
|
41
|
+
These skills can help you:
|
|
42
|
+
- 📝 Write configuration files
|
|
43
|
+
- 📚 Write documentation
|
|
44
|
+
- 🚀 Create new projects
|
|
45
|
+
|
|
46
|
+
Visit the [Skills repository](https://github.com/shenjianZ/react-docs-skills) to learn more.
|
|
47
|
+
|
|
35
48
|
### Exports
|
|
36
49
|
|
|
37
50
|
- Layout: `DocsLayout`
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { h as e } from "./shiki-highlighter-BmQSSJpS.js";
|
|
2
|
+
import { t } from "./utils-Ct96Mtjw.js";
|
|
3
|
+
import { n } from "./AIProvider-C1_b1iKH.js";
|
|
4
|
+
import r, { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
5
|
+
import { AlertCircle as c, AlertTriangle as l, Bot as u, Check as d, CheckCheck as f, CheckCircle as p, Copy as m, GripVertical as h, Loader2 as g, Pencil as _, RefreshCw as v, Send as y, Settings as b, Square as x, Trash2 as S, User as C, X as w } from "lucide-react";
|
|
6
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
7
|
+
import O from "remark-gfm";
|
|
8
|
+
import k from "react-markdown";
|
|
9
|
+
//#region src/components/ai/AIChatMessage.tsx
|
|
10
|
+
function A({ message: e, onRegenerate: n, onEdit: a, onDelete: o }) {
|
|
11
|
+
let [l, h] = s(!1), [y, b] = s(null), [x, A] = s(!1), [j, M] = s(e.content), N = e.role === "user", P = e.isStreaming, F = !!e.error, I = i(async (e) => {
|
|
12
|
+
if (navigator.clipboard && window.isSecureContext) await navigator.clipboard.writeText(e);
|
|
13
|
+
else {
|
|
14
|
+
let t = document.createElement("textarea");
|
|
15
|
+
t.value = e, t.style.position = "fixed", t.style.left = "-9999px", t.style.top = "-9999px", document.body.appendChild(t), t.focus(), t.select();
|
|
16
|
+
try {
|
|
17
|
+
document.execCommand("copy");
|
|
18
|
+
} finally {
|
|
19
|
+
document.body.removeChild(t);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, []), L = i(async () => {
|
|
23
|
+
try {
|
|
24
|
+
await I(e.content), h(!0), setTimeout(() => h(!1), 2e3);
|
|
25
|
+
} catch {
|
|
26
|
+
console.error("Failed to copy message");
|
|
27
|
+
}
|
|
28
|
+
}, [e.content, I]), R = i(async (e, t) => {
|
|
29
|
+
t.stopPropagation();
|
|
30
|
+
try {
|
|
31
|
+
await I(e), b(e), setTimeout(() => b(null), 2e3);
|
|
32
|
+
} catch {
|
|
33
|
+
console.error("Failed to copy code");
|
|
34
|
+
}
|
|
35
|
+
}, [I]), z = i(() => {
|
|
36
|
+
j.trim() && j !== e.content && a?.(j.trim()), A(!1);
|
|
37
|
+
}, [
|
|
38
|
+
j,
|
|
39
|
+
e.content,
|
|
40
|
+
a
|
|
41
|
+
]), B = i(() => {
|
|
42
|
+
M(e.content), A(!1);
|
|
43
|
+
}, [e.content]);
|
|
44
|
+
return /* @__PURE__ */ D("div", {
|
|
45
|
+
className: t("flex gap-3 p-4 group", N ? "flex-row-reverse" : "flex-row"),
|
|
46
|
+
children: [/* @__PURE__ */ E("div", {
|
|
47
|
+
className: t("flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center", N ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground"),
|
|
48
|
+
children: E(N ? C : u, { className: "w-4 h-4" })
|
|
49
|
+
}), /* @__PURE__ */ E("div", {
|
|
50
|
+
className: t("flex-1 min-w-0", N ? "text-right" : "text-left"),
|
|
51
|
+
children: x ? /* @__PURE__ */ D("div", {
|
|
52
|
+
className: "inline-block max-w-full",
|
|
53
|
+
children: [/* @__PURE__ */ E("textarea", {
|
|
54
|
+
value: j,
|
|
55
|
+
onChange: (e) => M(e.target.value),
|
|
56
|
+
className: t("w-full min-w-[200px] max-w-[400px] p-3 rounded-lg border", "bg-background text-sm resize-none", "focus:outline-none focus:ring-2 focus:ring-ring"),
|
|
57
|
+
rows: Math.min(10, j.split("\n").length + 1),
|
|
58
|
+
autoFocus: !0
|
|
59
|
+
}), /* @__PURE__ */ D("div", {
|
|
60
|
+
className: "flex justify-end gap-2 mt-2",
|
|
61
|
+
children: [/* @__PURE__ */ E("button", {
|
|
62
|
+
onClick: B,
|
|
63
|
+
className: "p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
64
|
+
title: "取消",
|
|
65
|
+
children: /* @__PURE__ */ E(w, { className: "w-4 h-4" })
|
|
66
|
+
}), /* @__PURE__ */ E("button", {
|
|
67
|
+
onClick: z,
|
|
68
|
+
className: "p-1.5 rounded text-primary hover:bg-primary/10 transition-colors",
|
|
69
|
+
title: "保存",
|
|
70
|
+
children: /* @__PURE__ */ E(f, { className: "w-4 h-4" })
|
|
71
|
+
})]
|
|
72
|
+
})]
|
|
73
|
+
}) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ D("div", {
|
|
74
|
+
className: t("inline-block max-w-full rounded-lg px-4 py-2", N ? "bg-primary text-primary-foreground" : "bg-muted text-foreground", F && "border border-destructive"),
|
|
75
|
+
children: [e.content ? /* @__PURE__ */ E(k, {
|
|
76
|
+
remarkPlugins: [O],
|
|
77
|
+
components: {
|
|
78
|
+
pre: ({ children: e }) => {
|
|
79
|
+
let t = (e) => {
|
|
80
|
+
if (typeof e == "string") return e;
|
|
81
|
+
if (Array.isArray(e)) return e.map(t).join("");
|
|
82
|
+
if (r.isValidElement(e)) {
|
|
83
|
+
let n = e.props;
|
|
84
|
+
if (n.children) return t(n.children);
|
|
85
|
+
}
|
|
86
|
+
return "";
|
|
87
|
+
}, n = r.Children.toArray(e).find((e) => r.isValidElement(e) && e.type === "code"), i = n && r.isValidElement(n) ? t(n.props.children).replace(/\n$/, "") : "";
|
|
88
|
+
return /* @__PURE__ */ D("div", {
|
|
89
|
+
className: "relative my-3 rounded-lg overflow-hidden border dark:border-zinc-700 border-zinc-200 dark:bg-[#141414] bg-[#fafafa]",
|
|
90
|
+
children: [/* @__PURE__ */ D("div", {
|
|
91
|
+
className: "flex items-center justify-between px-4 py-2 border-b dark:border-zinc-700 border-zinc-200 dark:bg-[#1a1a1a] bg-zinc-100",
|
|
92
|
+
children: [/* @__PURE__ */ E("span", {
|
|
93
|
+
className: "text-xs dark:text-zinc-400 text-zinc-500",
|
|
94
|
+
children: "代码"
|
|
95
|
+
}), i && /* @__PURE__ */ E("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
onClick: (e) => R(i, e),
|
|
98
|
+
className: "flex items-center gap-1 px-2 py-1 text-xs rounded dark:bg-zinc-700 dark:hover:bg-zinc-600 dark:text-zinc-300 bg-zinc-200 hover:bg-zinc-300 text-zinc-600 transition-colors",
|
|
99
|
+
children: y === i ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(p, { className: "w-3.5 h-3.5 text-green-500" }), "已复制"] }) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(m, { className: "w-3.5 h-3.5" }), "复制"] })
|
|
100
|
+
})]
|
|
101
|
+
}), /* @__PURE__ */ E("pre", {
|
|
102
|
+
className: "!m-0 p-4 overflow-x-auto text-sm hljs",
|
|
103
|
+
children: e
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
code: ({ className: e, children: n, ...r }) => /language-(\w+)/.exec(e || "") || e?.includes("hljs") ? /* @__PURE__ */ E("code", {
|
|
108
|
+
className: t(e, "block"),
|
|
109
|
+
...r,
|
|
110
|
+
children: n
|
|
111
|
+
}) : !e && String(n).includes("\n") ? /* @__PURE__ */ E("code", {
|
|
112
|
+
className: "block",
|
|
113
|
+
...r,
|
|
114
|
+
children: n
|
|
115
|
+
}) : /* @__PURE__ */ E("code", {
|
|
116
|
+
className: "px-1.5 py-0.5 rounded dark:bg-zinc-700 bg-zinc-200 text-sm",
|
|
117
|
+
...r,
|
|
118
|
+
children: n
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
children: e.content
|
|
122
|
+
}) : P ? /* @__PURE__ */ D("div", {
|
|
123
|
+
className: "flex items-center gap-2 text-muted-foreground",
|
|
124
|
+
children: [/* @__PURE__ */ E(g, { className: "w-4 h-4 animate-spin" }), /* @__PURE__ */ E("span", { children: "正在思考..." })]
|
|
125
|
+
}) : null, F && /* @__PURE__ */ D("div", {
|
|
126
|
+
className: "flex items-center gap-2 text-destructive mt-2",
|
|
127
|
+
children: [/* @__PURE__ */ E(c, { className: "w-4 h-4" }), /* @__PURE__ */ E("span", {
|
|
128
|
+
className: "text-sm",
|
|
129
|
+
children: e.error
|
|
130
|
+
})]
|
|
131
|
+
})]
|
|
132
|
+
}), !P && /* @__PURE__ */ D("div", {
|
|
133
|
+
className: t("flex items-center gap-2 mt-2 opacity-0 group-hover:opacity-100 transition-opacity", N ? "justify-end" : "justify-start"),
|
|
134
|
+
children: [
|
|
135
|
+
!N && e.content && /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("button", {
|
|
136
|
+
onClick: L,
|
|
137
|
+
className: "p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
138
|
+
title: "复制",
|
|
139
|
+
children: l ? /* @__PURE__ */ E(d, { className: "w-3.5 h-3.5 text-green-500" }) : /* @__PURE__ */ E(m, { className: "w-3.5 h-3.5" })
|
|
140
|
+
}), n && /* @__PURE__ */ E("button", {
|
|
141
|
+
onClick: n,
|
|
142
|
+
className: "p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
143
|
+
title: "重新生成",
|
|
144
|
+
children: /* @__PURE__ */ E(v, { className: "w-3.5 h-3.5" })
|
|
145
|
+
})] }),
|
|
146
|
+
N && a && /* @__PURE__ */ E("button", {
|
|
147
|
+
onClick: () => A(!0),
|
|
148
|
+
className: "p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
149
|
+
title: "编辑",
|
|
150
|
+
children: /* @__PURE__ */ E(_, { className: "w-3.5 h-3.5" })
|
|
151
|
+
}),
|
|
152
|
+
o && /* @__PURE__ */ E("button", {
|
|
153
|
+
onClick: o,
|
|
154
|
+
className: "p-1.5 rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",
|
|
155
|
+
title: "删除",
|
|
156
|
+
children: /* @__PURE__ */ E(S, { className: "w-3.5 h-3.5" })
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
})] })
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/components/ai/AIChatInput.tsx
|
|
165
|
+
function j({ onSend: e, onStop: n, isLoading: r = !1, disabled: i = !1, placeholder: c = "输入消息..." }) {
|
|
166
|
+
let [l, u] = s(""), d = o(null);
|
|
167
|
+
a(() => {
|
|
168
|
+
let e = d.current;
|
|
169
|
+
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 150)}px`);
|
|
170
|
+
}, [l]);
|
|
171
|
+
let f = () => {
|
|
172
|
+
let t = l.trim();
|
|
173
|
+
!t || r || i || (e(t), u(""), d.current && (d.current.style.height = "auto"));
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ D("div", {
|
|
176
|
+
className: "flex items-end gap-2 p-4 border-t bg-background",
|
|
177
|
+
children: [/* @__PURE__ */ E("div", {
|
|
178
|
+
className: "flex-1 relative",
|
|
179
|
+
children: /* @__PURE__ */ E("textarea", {
|
|
180
|
+
ref: d,
|
|
181
|
+
value: l,
|
|
182
|
+
onChange: (e) => u(e.target.value),
|
|
183
|
+
onKeyDown: (e) => {
|
|
184
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), f());
|
|
185
|
+
},
|
|
186
|
+
placeholder: c,
|
|
187
|
+
disabled: i,
|
|
188
|
+
rows: 1,
|
|
189
|
+
className: t("w-full resize-none rounded-lg border bg-background px-4 py-2.5", "text-sm placeholder:text-muted-foreground", "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", "min-h-[40px] max-h-[150px]"),
|
|
190
|
+
style: { height: "40px" }
|
|
191
|
+
})
|
|
192
|
+
}), r ? /* @__PURE__ */ E("button", {
|
|
193
|
+
onClick: n,
|
|
194
|
+
className: t("flex-shrink-0 w-10 h-10 rounded-lg", "flex items-center justify-center", "bg-destructive text-destructive-foreground", "hover:bg-destructive/90 transition-colors"),
|
|
195
|
+
title: "停止生成",
|
|
196
|
+
children: /* @__PURE__ */ E(x, { className: "w-4 h-4" })
|
|
197
|
+
}) : /* @__PURE__ */ E("button", {
|
|
198
|
+
onClick: f,
|
|
199
|
+
disabled: !l.trim() || i,
|
|
200
|
+
className: t("flex-shrink-0 w-10 h-10 rounded-lg", "flex items-center justify-center", "bg-primary text-primary-foreground", "hover:bg-primary/90 transition-colors", "disabled:opacity-50 disabled:cursor-not-allowed"),
|
|
201
|
+
title: "发送消息",
|
|
202
|
+
children: /* @__PURE__ */ E(y, { className: "w-4 h-4" })
|
|
203
|
+
})]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/components/ai/AIChatDialog.tsx
|
|
208
|
+
var M = /* @__PURE__ */ e({ AIChatDialog: () => I }), N = 300, P = 700, F = 500;
|
|
209
|
+
function I() {
|
|
210
|
+
let { isDialogOpen: e, closeDialog: r, openSettings: c, messages: d, isLoading: f, error: p, isConfigured: m, selectedText: g, sendMessage: _, regenerateLast: v, clearHistory: y, stopGeneration: x, editMessage: C, deleteMessage: T } = n(), O = o(null), k = o(null), M = o(null), I = o(null), L = o(!0), [R, z] = s(F), [B, V] = s(!1), [H, U] = s({
|
|
211
|
+
x: 0,
|
|
212
|
+
y: 0
|
|
213
|
+
}), [W, G] = s(!1), K = o({
|
|
214
|
+
x: 0,
|
|
215
|
+
y: 0,
|
|
216
|
+
posX: 0,
|
|
217
|
+
posY: 0
|
|
218
|
+
}), q = i((e = "smooth") => {
|
|
219
|
+
O.current && O.current.scrollIntoView({ behavior: e });
|
|
220
|
+
}, []), J = i(() => {
|
|
221
|
+
let e = k.current;
|
|
222
|
+
if (!e) return;
|
|
223
|
+
let { scrollTop: t, scrollHeight: n, clientHeight: r } = e;
|
|
224
|
+
L.current = n - t - r < 100;
|
|
225
|
+
}, []);
|
|
226
|
+
a(() => {
|
|
227
|
+
if (L.current && O.current) {
|
|
228
|
+
let e = d[d.length - 1]?.isStreaming;
|
|
229
|
+
q(e ? "auto" : "smooth");
|
|
230
|
+
}
|
|
231
|
+
}, [d, q]), a(() => {
|
|
232
|
+
let t = (t) => {
|
|
233
|
+
t.key === "Escape" && e && r();
|
|
234
|
+
};
|
|
235
|
+
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
236
|
+
}, [e, r]);
|
|
237
|
+
let Y = i((e) => {
|
|
238
|
+
e.preventDefault(), V(!0);
|
|
239
|
+
let t = e.clientY, n = R, r = (e) => {
|
|
240
|
+
let r = t - e.clientY;
|
|
241
|
+
z(Math.min(P, Math.max(N, n + r)));
|
|
242
|
+
}, i = () => {
|
|
243
|
+
V(!1), document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
|
|
244
|
+
};
|
|
245
|
+
document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
|
|
246
|
+
}, [R]), X = i((e) => {
|
|
247
|
+
if (e.target.closest("button")) return;
|
|
248
|
+
e.preventDefault(), G(!0), K.current = {
|
|
249
|
+
x: e.clientX,
|
|
250
|
+
y: e.clientY,
|
|
251
|
+
posX: H.x,
|
|
252
|
+
posY: H.y
|
|
253
|
+
};
|
|
254
|
+
let t = (e) => {
|
|
255
|
+
let t = e.clientX - K.current.x, n = e.clientY - K.current.y;
|
|
256
|
+
U({
|
|
257
|
+
x: K.current.posX + t,
|
|
258
|
+
y: K.current.posY + n
|
|
259
|
+
});
|
|
260
|
+
}, n = () => {
|
|
261
|
+
G(!1), document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
|
|
262
|
+
};
|
|
263
|
+
document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
|
|
264
|
+
}, [H]), Z = i(() => {
|
|
265
|
+
U({
|
|
266
|
+
x: 0,
|
|
267
|
+
y: 0
|
|
268
|
+
});
|
|
269
|
+
}, []);
|
|
270
|
+
return !m && e ? /* @__PURE__ */ E("div", {
|
|
271
|
+
className: "fixed inset-x-4 bottom-4 z-50 mx-auto max-w-2xl",
|
|
272
|
+
children: /* @__PURE__ */ D("div", {
|
|
273
|
+
className: t("bg-background border rounded-xl shadow-2xl", "animate-in slide-in-from-bottom-4 duration-300"),
|
|
274
|
+
children: [/* @__PURE__ */ D("div", {
|
|
275
|
+
className: "flex items-center justify-between p-4 border-b",
|
|
276
|
+
children: [/* @__PURE__ */ D("div", {
|
|
277
|
+
className: "flex items-center gap-2",
|
|
278
|
+
children: [/* @__PURE__ */ E(u, { className: "w-5 h-5 text-primary" }), /* @__PURE__ */ E("h3", {
|
|
279
|
+
className: "font-semibold",
|
|
280
|
+
children: "AI 助手"
|
|
281
|
+
})]
|
|
282
|
+
}), /* @__PURE__ */ E("button", {
|
|
283
|
+
onClick: r,
|
|
284
|
+
className: "p-1.5 rounded hover:bg-muted transition-colors",
|
|
285
|
+
children: /* @__PURE__ */ E(w, { className: "w-4 h-4" })
|
|
286
|
+
})]
|
|
287
|
+
}), /* @__PURE__ */ D("div", {
|
|
288
|
+
className: "p-6 text-center",
|
|
289
|
+
children: [
|
|
290
|
+
/* @__PURE__ */ E(l, { className: "w-12 h-12 mx-auto text-muted-foreground mb-4" }),
|
|
291
|
+
/* @__PURE__ */ E("h4", {
|
|
292
|
+
className: "text-lg font-medium mb-2",
|
|
293
|
+
children: "需要配置 AI"
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ E("p", {
|
|
296
|
+
className: "text-muted-foreground mb-4",
|
|
297
|
+
children: "请先配置 AI 提供商和 API 密钥才能使用此功能"
|
|
298
|
+
}),
|
|
299
|
+
/* @__PURE__ */ E("button", {
|
|
300
|
+
onClick: () => {
|
|
301
|
+
r(), c();
|
|
302
|
+
},
|
|
303
|
+
className: "px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",
|
|
304
|
+
children: "前往设置"
|
|
305
|
+
})
|
|
306
|
+
]
|
|
307
|
+
})]
|
|
308
|
+
})
|
|
309
|
+
}) : e ? /* @__PURE__ */ E("div", {
|
|
310
|
+
className: "fixed inset-x-4 bottom-4 z-50 mx-auto max-w-2xl",
|
|
311
|
+
style: { transform: `translate(${H.x}px, ${H.y}px)` },
|
|
312
|
+
children: /* @__PURE__ */ D("div", {
|
|
313
|
+
ref: M,
|
|
314
|
+
className: t("bg-background border rounded-xl shadow-2xl overflow-hidden", "animate-in slide-in-from-bottom-4 duration-300", "flex flex-col", W && "cursor-grabbing", B && "cursor-ns-resize"),
|
|
315
|
+
style: {
|
|
316
|
+
height: `${R}px`,
|
|
317
|
+
maxHeight: "70vh"
|
|
318
|
+
},
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ D("div", {
|
|
321
|
+
className: "flex items-center justify-between p-4 border-b shrink-0 cursor-grab active:cursor-grabbing",
|
|
322
|
+
onMouseDown: X,
|
|
323
|
+
children: [/* @__PURE__ */ D("div", {
|
|
324
|
+
className: "flex items-center gap-2",
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ E(h, { className: "w-4 h-4 text-muted-foreground" }),
|
|
327
|
+
/* @__PURE__ */ E(u, { className: "w-5 h-5 text-primary" }),
|
|
328
|
+
/* @__PURE__ */ E("h3", {
|
|
329
|
+
className: "font-semibold",
|
|
330
|
+
children: "AI 助手"
|
|
331
|
+
})
|
|
332
|
+
]
|
|
333
|
+
}), /* @__PURE__ */ D("div", {
|
|
334
|
+
className: "flex items-center gap-1",
|
|
335
|
+
children: [
|
|
336
|
+
H.x !== 0 || H.y !== 0 ? /* @__PURE__ */ E("button", {
|
|
337
|
+
onClick: Z,
|
|
338
|
+
className: "p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",
|
|
339
|
+
title: "重置位置",
|
|
340
|
+
children: /* @__PURE__ */ E(w, { className: "w-3 h-3" })
|
|
341
|
+
}) : null,
|
|
342
|
+
d.length > 0 && /* @__PURE__ */ E("button", {
|
|
343
|
+
onClick: y,
|
|
344
|
+
className: "p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",
|
|
345
|
+
title: "清除对话",
|
|
346
|
+
children: /* @__PURE__ */ E(S, { className: "w-4 h-4" })
|
|
347
|
+
}),
|
|
348
|
+
/* @__PURE__ */ E("button", {
|
|
349
|
+
onClick: c,
|
|
350
|
+
className: "p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",
|
|
351
|
+
title: "设置",
|
|
352
|
+
children: /* @__PURE__ */ E(b, { className: "w-4 h-4" })
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ E("button", {
|
|
355
|
+
onClick: r,
|
|
356
|
+
className: "p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",
|
|
357
|
+
title: "关闭",
|
|
358
|
+
children: /* @__PURE__ */ E(w, { className: "w-4 h-4" })
|
|
359
|
+
})
|
|
360
|
+
]
|
|
361
|
+
})]
|
|
362
|
+
}),
|
|
363
|
+
g && /* @__PURE__ */ D("div", {
|
|
364
|
+
className: "px-4 py-2 bg-muted/50 border-b shrink-0",
|
|
365
|
+
children: [/* @__PURE__ */ E("div", {
|
|
366
|
+
className: "text-xs text-muted-foreground mb-1",
|
|
367
|
+
children: "选中的内容:"
|
|
368
|
+
}), /* @__PURE__ */ E("div", {
|
|
369
|
+
className: "text-sm line-clamp-2",
|
|
370
|
+
children: g
|
|
371
|
+
})]
|
|
372
|
+
}),
|
|
373
|
+
/* @__PURE__ */ E("div", {
|
|
374
|
+
ref: k,
|
|
375
|
+
className: "flex-1 overflow-y-auto",
|
|
376
|
+
onScroll: J,
|
|
377
|
+
children: d.length === 0 ? /* @__PURE__ */ D("div", {
|
|
378
|
+
className: "flex flex-col items-center justify-center h-full text-muted-foreground p-4",
|
|
379
|
+
children: [/* @__PURE__ */ E(u, { className: "w-12 h-12 mb-4 opacity-50" }), /* @__PURE__ */ D("p", {
|
|
380
|
+
className: "text-center",
|
|
381
|
+
children: [
|
|
382
|
+
"你好!我是 AI 助手。",
|
|
383
|
+
/* @__PURE__ */ E("br", {}),
|
|
384
|
+
"有什么我可以帮助你的吗?"
|
|
385
|
+
]
|
|
386
|
+
})]
|
|
387
|
+
}) : /* @__PURE__ */ D("div", {
|
|
388
|
+
className: "divide-y",
|
|
389
|
+
children: [d.map((e, t) => /* @__PURE__ */ E(A, {
|
|
390
|
+
message: e,
|
|
391
|
+
onRegenerate: e.role === "assistant" && t === d.length - 1 && !f ? v : void 0,
|
|
392
|
+
onEdit: e.role === "user" ? (t) => C(e.id, t) : void 0,
|
|
393
|
+
onDelete: f ? void 0 : () => T(e.id)
|
|
394
|
+
}, e.id)), /* @__PURE__ */ E("div", { ref: O })]
|
|
395
|
+
})
|
|
396
|
+
}),
|
|
397
|
+
p && /* @__PURE__ */ E("div", {
|
|
398
|
+
className: "px-4 py-2 bg-destructive/10 text-destructive text-sm border-t",
|
|
399
|
+
children: p
|
|
400
|
+
}),
|
|
401
|
+
/* @__PURE__ */ E(j, {
|
|
402
|
+
onSend: _,
|
|
403
|
+
onStop: x,
|
|
404
|
+
isLoading: f,
|
|
405
|
+
placeholder: g ? "询问关于选中内容的问题..." : "输入消息..."
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ E("div", {
|
|
408
|
+
ref: I,
|
|
409
|
+
className: "absolute top-0 left-1/2 -translate-x-1/2 w-20 h-2 cursor-ns-resize flex items-center justify-center",
|
|
410
|
+
onMouseDown: Y,
|
|
411
|
+
children: /* @__PURE__ */ E("div", { className: "w-8 h-1 rounded-full bg-muted-foreground/30" })
|
|
412
|
+
})
|
|
413
|
+
]
|
|
414
|
+
})
|
|
415
|
+
}) : null;
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
418
|
+
export { A as i, M as n, j as r, I as t };
|