dishui 0.0.97 β 0.0.101
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/.release-verified.json +2 -2
- package/dist/ai.js +17 -15
- package/dist/components/Card/Ticket.d.ts +52 -0
- package/dist/components/Card/Ticket2.js +218 -0
- package/dist/components/Card/Ticket2.js.map +1 -0
- package/dist/components/Card/index.d.ts +12 -0
- package/dist/components/Card/index.js +142 -139
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/ai/AgentRunCard/index.d.ts +38 -0
- package/dist/components/ai/AgentRunCard/index.js +100 -0
- package/dist/components/ai/AgentRunCard/index.js.map +1 -0
- package/dist/components/ai/IssueCard/index.d.ts +39 -0
- package/dist/components/ai/IssueCard/index.js +78 -0
- package/dist/components/ai/IssueCard/index.js.map +1 -0
- package/dist/components/ai/index.d.ts +4 -0
- package/dist/components/pro/Flow/constants.js +3 -3
- package/dist/components/pro/Flow/constants.js.map +1 -1
- package/dist/components/pro/Flow/nodes/shapes.js +3 -3
- package/dist/components/pro/Flow/nodes/shapes.js.map +1 -1
- package/dist/components/pro/Flow/utils/themeColor.d.ts +2 -2
- package/dist/components/pro/Flow/utils/themeColor.js +2 -2
- package/dist/components/pro/Flow/utils/themeColor.js.map +1 -1
- package/dist/components/pro/Kanban/Kanban.d.ts +3 -0
- package/dist/components/pro/Kanban/Kanban.js +339 -0
- package/dist/components/pro/Kanban/Kanban.js.map +1 -0
- package/dist/components/pro/Kanban/Swimlanes.d.ts +3 -0
- package/dist/components/pro/Kanban/Swimlanes.js +60 -0
- package/dist/components/pro/Kanban/Swimlanes.js.map +1 -0
- package/dist/components/pro/Kanban/index.d.ts +5 -0
- package/dist/components/pro/Kanban/types.d.ts +103 -0
- package/dist/components/pro/Kanban/useKanbanDrag.d.ts +17 -0
- package/dist/components/pro/Kanban/useKanbanDrag.js +69 -0
- package/dist/components/pro/Kanban/useKanbanDrag.js.map +1 -0
- package/dist/components/pro/Kanban/utils.d.ts +13 -0
- package/dist/components/pro/Kanban/utils.js +48 -0
- package/dist/components/pro/Kanban/utils.js.map +1 -0
- package/dist/components/pro/RichTextEditor/AIRewrite.js +158 -127
- package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
- package/dist/components/pro/RichTextEditor/BlockHandle.d.ts +2 -0
- package/dist/components/pro/RichTextEditor/BlockHandle.js +156 -115
- package/dist/components/pro/RichTextEditor/BlockHandle.js.map +1 -1
- package/dist/components/pro/RichTextEditor/RichTextEditor.js +136 -159
- package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js +44 -41
- package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js +59 -53
- package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js +48 -44
- package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js +67 -63
- package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.d.ts +1 -0
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js +182 -129
- package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.d.ts +1 -0
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.js +3 -3
- package/dist/components/pro/RichTextEditor/Toolbar/ToolbarButton.js.map +1 -1
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.d.ts +3 -0
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.js +31 -0
- package/dist/components/pro/RichTextEditor/Toolbar/useAnchoredDropdown.js.map +1 -0
- package/dist/components/pro/RichTextEditor/index.d.ts +1 -1
- package/dist/components/pro/RichTextEditor/types.d.ts +78 -11
- package/dist/components/pro/RichTextEditor/types.js +11 -0
- package/dist/components/pro/RichTextEditor/types.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +128 -122
- package/dist/kanban.js +5 -0
- package/dist/utils/i18n.js +20 -0
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +1 -1
- package/dist/utils/menu.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { defaultLabels as e } from "./types.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import t from "../../ai/StreamingText/index.js";
|
|
3
|
+
import n from "../../ai/LoadingState/index.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useId as a, useRef as o, useState as s } from "react";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
6
|
//#region src/components/pro/RichTextEditor/AIRewrite.tsx
|
|
5
|
-
var
|
|
7
|
+
var u = [
|
|
6
8
|
{
|
|
7
9
|
key: "rewrite",
|
|
8
10
|
labelKey: "aiRewrite",
|
|
@@ -44,7 +46,7 @@ var c = [
|
|
|
44
46
|
icon: "π¬"
|
|
45
47
|
}
|
|
46
48
|
];
|
|
47
|
-
function
|
|
49
|
+
function d(e, t) {
|
|
48
50
|
return e === "custom" ? t || "Follow the user instructions." : t || {
|
|
49
51
|
rewrite: "Rewrite the following text to improve clarity and readability. Keep the same meaning and tone. Return only the rewritten text.",
|
|
50
52
|
shorten: "Shorten the following text while preserving its key meaning. Be concise. Return only the shortened text.",
|
|
@@ -56,7 +58,7 @@ function l(e, t) {
|
|
|
56
58
|
casual: "Rewrite the following text in a casual, friendly tone. Return only the rewritten text."
|
|
57
59
|
}[e];
|
|
58
60
|
}
|
|
59
|
-
async function*
|
|
61
|
+
async function* f(e) {
|
|
60
62
|
let t = e.body?.getReader();
|
|
61
63
|
if (!t) throw Error("No response body");
|
|
62
64
|
let n = new TextDecoder(), r = "", i = [];
|
|
@@ -81,7 +83,8 @@ async function* u(e) {
|
|
|
81
83
|
t.releaseLock();
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
async function*
|
|
86
|
+
async function* p(e, t, n, r) {
|
|
87
|
+
if (!e.gateway || !e.model) throw Error("OpenAI protocol requires gateway and model");
|
|
85
88
|
let i = JSON.stringify({
|
|
86
89
|
model: e.model,
|
|
87
90
|
messages: [{
|
|
@@ -103,7 +106,7 @@ async function* d(e, t, n, r) {
|
|
|
103
106
|
signal: r
|
|
104
107
|
});
|
|
105
108
|
if (!a.ok) throw Error(`AI API error: ${a.status} ${a.statusText}`);
|
|
106
|
-
for await (let e of
|
|
109
|
+
for await (let e of f(a)) {
|
|
107
110
|
if (e.trim() === "[DONE]") return;
|
|
108
111
|
let t;
|
|
109
112
|
try {
|
|
@@ -116,7 +119,8 @@ async function* d(e, t, n, r) {
|
|
|
116
119
|
typeof n == "string" && (yield n);
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
|
-
async function*
|
|
122
|
+
async function* m(e, t, n, r) {
|
|
123
|
+
if (!e.gateway || !e.model) throw Error("Anthropic protocol requires gateway and model");
|
|
120
124
|
let i = JSON.stringify({
|
|
121
125
|
model: e.model,
|
|
122
126
|
max_tokens: 4096,
|
|
@@ -138,7 +142,7 @@ async function* f(e, t, n, r) {
|
|
|
138
142
|
signal: r
|
|
139
143
|
});
|
|
140
144
|
if (!a.ok) throw Error(`AI API error: ${a.status} ${a.statusText}`);
|
|
141
|
-
for await (let e of
|
|
145
|
+
for await (let e of f(a)) {
|
|
142
146
|
let t;
|
|
143
147
|
try {
|
|
144
148
|
t = JSON.parse(e);
|
|
@@ -150,103 +154,112 @@ async function* f(e, t, n, r) {
|
|
|
150
154
|
t?.type === "content_block_delta" && typeof t.delta?.text == "string" && (yield t.delta.text);
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
|
-
function
|
|
157
|
+
function h(e, t, n, r, i, a) {
|
|
154
158
|
if (e.protocol === "custom") {
|
|
155
159
|
if (!e.customHandler) throw Error("Custom AI protocol requires customHandler");
|
|
156
160
|
return e.customHandler({
|
|
157
161
|
text: t,
|
|
158
162
|
action: r === "custom" ? "rewrite" : r,
|
|
159
|
-
|
|
163
|
+
systemPrompt: n,
|
|
164
|
+
signal: i,
|
|
165
|
+
prompt: a?.prompt ?? "",
|
|
166
|
+
selectedText: a?.selectedText ?? t,
|
|
167
|
+
mode: a?.mode ?? "replace"
|
|
160
168
|
});
|
|
161
169
|
}
|
|
162
|
-
return e.protocol === "anthropic" ?
|
|
170
|
+
return e.protocol === "anthropic" ? m(e, t, n, i) : p(e, t, n, i);
|
|
163
171
|
}
|
|
164
|
-
var
|
|
165
|
-
let
|
|
172
|
+
var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRange: _, onClose: v }) => {
|
|
173
|
+
let y = {
|
|
166
174
|
...e,
|
|
167
|
-
...
|
|
168
|
-
}, [
|
|
169
|
-
let e =
|
|
170
|
-
|
|
175
|
+
...m
|
|
176
|
+
}, b = a(), [x, S] = s(""), [C, w] = s(!1), [T, E] = s(""), [D, O] = s(null), k = o(null), A = o(null), [j, M] = s(() => !f.isDestroyed && f.isEditable), [N, P] = s(!1), F = o(f.state.doc), I = o(!1), L = r(() => {
|
|
177
|
+
let e = k.current;
|
|
178
|
+
k.current = null, e?.abort();
|
|
171
179
|
}, []);
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
i(() => {
|
|
181
|
+
F.current = f.state.doc, I.current = !1, P(!1), E(""), w(!1), O(null);
|
|
174
182
|
let e = () => {
|
|
175
|
-
|
|
183
|
+
M(!f.isDestroyed && f.isEditable), (f.isDestroyed || !f.isEditable || f.state.doc !== F.current) && (I.current = !0, P(!0), L(), w(!1), E(""), O("The document or editing permissions changed. Close and reopen AI Assistant."));
|
|
176
184
|
};
|
|
177
|
-
return e(),
|
|
178
|
-
|
|
185
|
+
return e(), f.on("update", e), f.on("transaction", e), f.on("destroy", e), () => {
|
|
186
|
+
L(), f.off("update", e), f.off("transaction", e), f.off("destroy", e);
|
|
179
187
|
};
|
|
180
188
|
}, [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
f,
|
|
190
|
+
g,
|
|
191
|
+
_.from,
|
|
192
|
+
_.to,
|
|
193
|
+
L
|
|
186
194
|
]);
|
|
187
|
-
let
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
let R = g;
|
|
196
|
+
i(() => {
|
|
197
|
+
A.current && A.current.focus();
|
|
190
198
|
}, []);
|
|
191
|
-
let
|
|
192
|
-
if (
|
|
193
|
-
let n =
|
|
194
|
-
if (
|
|
195
|
-
let r = e === "custom" ?
|
|
196
|
-
|
|
197
|
-
let
|
|
198
|
-
|
|
199
|
+
let z = r(async (e = "custom", t) => {
|
|
200
|
+
if (f.isDestroyed || !f.isEditable || I.current || k.current) return;
|
|
201
|
+
let n = R ? "replace" : "insert";
|
|
202
|
+
if (n === "insert" && !x.trim()) return;
|
|
203
|
+
let r = e === "custom" ? n === "replace" ? "Edit the selected text according to the user instruction. Return only the replacement text." : "Generate text according to the user instruction. Return only the text to insert." : d(e, t), i = [p.systemPrompt, r].filter(Boolean).join("\n\n"), a = n === "replace" ? x.trim() ? `Instruction:\n${x.trim()}\n\nSelected text:\n${R}` : R : x.trim();
|
|
204
|
+
w(!0), E(""), O(null);
|
|
205
|
+
let o = new AbortController();
|
|
206
|
+
k.current = o;
|
|
199
207
|
try {
|
|
200
208
|
let t = "";
|
|
201
|
-
for await (let
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
for await (let r of h(p, a, i, e, o.signal, {
|
|
210
|
+
prompt: x.trim(),
|
|
211
|
+
selectedText: R,
|
|
212
|
+
mode: n
|
|
213
|
+
})) {
|
|
214
|
+
if (o.signal.aborted || k.current !== o) break;
|
|
215
|
+
t += r, E(t);
|
|
204
216
|
}
|
|
205
217
|
} catch (e) {
|
|
206
|
-
if (
|
|
207
|
-
|
|
218
|
+
if (o.signal.aborted || k.current !== o) return;
|
|
219
|
+
E(""), O(String(e instanceof Error ? e.message : e));
|
|
208
220
|
} finally {
|
|
209
|
-
|
|
221
|
+
k.current === o && (k.current = null, w(!1));
|
|
210
222
|
}
|
|
211
223
|
}, [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
]),
|
|
217
|
-
if (!
|
|
218
|
-
let { from: e, to: t } =
|
|
219
|
-
if (
|
|
220
|
-
|
|
224
|
+
f,
|
|
225
|
+
p,
|
|
226
|
+
R,
|
|
227
|
+
x
|
|
228
|
+
]), B = r(() => {
|
|
229
|
+
if (!T || k.current || f.isDestroyed || !f.isEditable || I.current) return;
|
|
230
|
+
let { from: e, to: t } = _;
|
|
231
|
+
if (f.state.doc !== F.current || !Number.isInteger(e) || !Number.isInteger(t) || e < 0 || t < e || t > f.state.doc.content.size) {
|
|
232
|
+
O("The original selection is no longer valid. Close and reopen AI Assistant.");
|
|
221
233
|
return;
|
|
222
234
|
}
|
|
223
|
-
|
|
235
|
+
f.view.dispatch(f.state.tr.insertText(T, e, t)), E(""), S(""), v();
|
|
224
236
|
}, [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
]),
|
|
230
|
-
|
|
231
|
-
}, [
|
|
232
|
-
e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(),
|
|
233
|
-
}, [
|
|
234
|
-
return /* @__PURE__ */
|
|
237
|
+
f,
|
|
238
|
+
T,
|
|
239
|
+
_,
|
|
240
|
+
v
|
|
241
|
+
]), V = r(() => {
|
|
242
|
+
L(), E(""), w(!1), O(null);
|
|
243
|
+
}, [L]), H = r((e) => {
|
|
244
|
+
e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), z());
|
|
245
|
+
}, [z]);
|
|
246
|
+
return /* @__PURE__ */ l("div", {
|
|
235
247
|
className: "rte-ai-panel-v2",
|
|
236
248
|
children: [
|
|
237
|
-
/* @__PURE__ */
|
|
249
|
+
/* @__PURE__ */ l("div", {
|
|
238
250
|
className: "rte-ai-panel-v2__header",
|
|
239
|
-
children: [/* @__PURE__ */
|
|
251
|
+
children: [/* @__PURE__ */ l("span", {
|
|
240
252
|
className: "rte-ai-panel-v2__title",
|
|
241
|
-
children: ["β¨ ",
|
|
242
|
-
}), /* @__PURE__ */
|
|
253
|
+
children: ["β¨ ", y.ai || "AI Assistant"]
|
|
254
|
+
}), /* @__PURE__ */ c("button", {
|
|
243
255
|
type: "button",
|
|
244
256
|
className: "rte-ai-panel-v2__close-btn",
|
|
245
257
|
onClick: () => {
|
|
246
|
-
|
|
258
|
+
L(), v();
|
|
247
259
|
},
|
|
248
|
-
title:
|
|
249
|
-
|
|
260
|
+
title: y.aiClose,
|
|
261
|
+
"aria-label": y.aiClose,
|
|
262
|
+
children: /* @__PURE__ */ l("svg", {
|
|
250
263
|
width: "14",
|
|
251
264
|
height: "14",
|
|
252
265
|
viewBox: "0 0 24 24",
|
|
@@ -255,12 +268,12 @@ var m = ({ editor: u, aiConfig: d, labels: f, initialSelection: m, selectionRang
|
|
|
255
268
|
strokeWidth: "2",
|
|
256
269
|
strokeLinecap: "round",
|
|
257
270
|
strokeLinejoin: "round",
|
|
258
|
-
children: [/* @__PURE__ */
|
|
271
|
+
children: [/* @__PURE__ */ c("line", {
|
|
259
272
|
x1: "18",
|
|
260
273
|
y1: "6",
|
|
261
274
|
x2: "6",
|
|
262
275
|
y2: "18"
|
|
263
|
-
}), /* @__PURE__ */
|
|
276
|
+
}), /* @__PURE__ */ c("line", {
|
|
264
277
|
x1: "6",
|
|
265
278
|
y1: "6",
|
|
266
279
|
x2: "18",
|
|
@@ -269,105 +282,123 @@ var m = ({ editor: u, aiConfig: d, labels: f, initialSelection: m, selectionRang
|
|
|
269
282
|
})
|
|
270
283
|
})]
|
|
271
284
|
}),
|
|
272
|
-
/* @__PURE__ */
|
|
285
|
+
/* @__PURE__ */ l("div", {
|
|
273
286
|
className: "rte-ai-panel-v2__prompt-section",
|
|
274
|
-
children: [/* @__PURE__ */
|
|
287
|
+
children: [/* @__PURE__ */ c("label", {
|
|
275
288
|
className: "rte-ai-panel-v2__label",
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
htmlFor: b,
|
|
290
|
+
children: y.aiPromptLabel
|
|
291
|
+
}), /* @__PURE__ */ c("textarea", {
|
|
292
|
+
id: b,
|
|
293
|
+
ref: A,
|
|
279
294
|
className: "rte-ai-panel-v2__prompt-input",
|
|
280
|
-
value:
|
|
281
|
-
onChange: (e) =>
|
|
282
|
-
onKeyDown:
|
|
283
|
-
placeholder:
|
|
295
|
+
value: x,
|
|
296
|
+
onChange: (e) => S(e.target.value),
|
|
297
|
+
onKeyDown: H,
|
|
298
|
+
placeholder: y.aiPromptPlaceholder,
|
|
284
299
|
rows: 3,
|
|
285
|
-
disabled:
|
|
300
|
+
disabled: C || !j || N
|
|
286
301
|
})]
|
|
287
302
|
}),
|
|
288
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ l("div", {
|
|
289
304
|
className: "rte-ai-panel-v2__selection-section",
|
|
290
|
-
children: [/* @__PURE__ */
|
|
305
|
+
children: [/* @__PURE__ */ c("span", {
|
|
291
306
|
className: "rte-ai-panel-v2__label",
|
|
292
|
-
children:
|
|
293
|
-
}), /* @__PURE__ */
|
|
307
|
+
children: y.aiSelectedText
|
|
308
|
+
}), /* @__PURE__ */ c("div", {
|
|
294
309
|
className: "rte-ai-panel-v2__selection-box",
|
|
295
|
-
children:
|
|
310
|
+
children: R ? /* @__PURE__ */ c("span", { children: R.length > 300 ? R.slice(0, 300) + "..." : R }) : /* @__PURE__ */ c("span", {
|
|
296
311
|
className: "rte-ai-panel-v2__empty",
|
|
297
|
-
children:
|
|
312
|
+
children: y.aiInsertHint
|
|
298
313
|
})
|
|
299
314
|
})]
|
|
300
315
|
}),
|
|
301
|
-
/* @__PURE__ */
|
|
316
|
+
/* @__PURE__ */ c("div", {
|
|
302
317
|
className: "rte-ai-panel-v2__quick-actions",
|
|
303
|
-
children:
|
|
318
|
+
children: u.map(({ key: e, labelKey: t, icon: n }) => /* @__PURE__ */ l("button", {
|
|
304
319
|
type: "button",
|
|
305
320
|
className: "rte-ai-panel-v2__quick-btn",
|
|
306
|
-
onClick: () =>
|
|
307
|
-
disabled:
|
|
308
|
-
title:
|
|
309
|
-
children: [/* @__PURE__ */
|
|
321
|
+
onClick: () => z(e),
|
|
322
|
+
disabled: C || !j || N || !R.trim(),
|
|
323
|
+
title: R ? y[t] : y.aiInsertHint,
|
|
324
|
+
children: [/* @__PURE__ */ c("span", { children: n }), /* @__PURE__ */ c("span", { children: y[t] })]
|
|
310
325
|
}, e))
|
|
311
326
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
327
|
+
/* @__PURE__ */ l("div", {
|
|
313
328
|
className: "rte-ai-panel-v2__actions",
|
|
314
|
-
children: [/* @__PURE__ */
|
|
329
|
+
children: [/* @__PURE__ */ c("button", {
|
|
315
330
|
type: "button",
|
|
316
331
|
className: "rte-ai-panel-v2__generate-btn",
|
|
317
|
-
onClick: () =>
|
|
318
|
-
disabled:
|
|
319
|
-
children:
|
|
320
|
-
|
|
321
|
-
" ",
|
|
322
|
-
_.aiProcessing
|
|
323
|
-
] }) : "β¨ Generate"
|
|
324
|
-
}), b && /* @__PURE__ */ o("button", {
|
|
332
|
+
onClick: () => z(),
|
|
333
|
+
disabled: C || !j || N || !x.trim() && !R.trim(),
|
|
334
|
+
children: C ? y.aiProcessing : `β¨ ${y.aiGenerate}`
|
|
335
|
+
}), C && /* @__PURE__ */ c("button", {
|
|
325
336
|
type: "button",
|
|
326
337
|
className: "rte-ai-panel-v2__cancel-btn",
|
|
327
|
-
onClick:
|
|
328
|
-
children:
|
|
338
|
+
onClick: V,
|
|
339
|
+
children: y.aiCancel
|
|
329
340
|
})]
|
|
330
341
|
}),
|
|
331
|
-
|
|
342
|
+
C && !T && /* @__PURE__ */ c(n, {
|
|
343
|
+
className: "rte-ai-panel-v2__loading",
|
|
344
|
+
label: y.aiProcessing,
|
|
345
|
+
variant: "dots",
|
|
346
|
+
layout: "block",
|
|
347
|
+
size: "sm"
|
|
348
|
+
}),
|
|
349
|
+
T && /* @__PURE__ */ l("div", {
|
|
332
350
|
className: "rte-ai-panel-v2__result",
|
|
333
351
|
children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
className: "rte-ai-panel-
|
|
336
|
-
children: "
|
|
352
|
+
/* @__PURE__ */ l("div", {
|
|
353
|
+
className: "rte-ai-panel-v2__result-header",
|
|
354
|
+
children: [/* @__PURE__ */ c("span", {
|
|
355
|
+
className: "rte-ai-panel-v2__label",
|
|
356
|
+
children: y.aiResult
|
|
357
|
+
}), /* @__PURE__ */ l("span", {
|
|
358
|
+
className: `rte-ai-panel-v2__stream-status ${C ? "rte-ai-panel-v2__stream-status--live" : ""}`,
|
|
359
|
+
role: "status",
|
|
360
|
+
children: [/* @__PURE__ */ c("span", {
|
|
361
|
+
className: "rte-ai-panel-v2__stream-dot",
|
|
362
|
+
"aria-hidden": "true"
|
|
363
|
+
}), C ? y.aiProcessing : `${T.length} chars`]
|
|
364
|
+
})]
|
|
337
365
|
}),
|
|
338
|
-
/* @__PURE__ */
|
|
366
|
+
/* @__PURE__ */ c("div", {
|
|
339
367
|
className: "rte-ai-panel-v2__result-text",
|
|
340
|
-
children:
|
|
368
|
+
children: /* @__PURE__ */ c(t, {
|
|
369
|
+
text: T,
|
|
370
|
+
streaming: C
|
|
371
|
+
})
|
|
341
372
|
}),
|
|
342
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ l("div", {
|
|
343
374
|
className: "rte-ai-panel-v2__result-actions",
|
|
344
|
-
children: [/* @__PURE__ */
|
|
375
|
+
children: [/* @__PURE__ */ c("button", {
|
|
345
376
|
type: "button",
|
|
346
377
|
className: "rte-ai-panel-v2__accept-btn",
|
|
347
|
-
disabled:
|
|
348
|
-
onClick:
|
|
349
|
-
children:
|
|
350
|
-
}), /* @__PURE__ */
|
|
378
|
+
disabled: C || !j || N,
|
|
379
|
+
onClick: B,
|
|
380
|
+
children: y.aiAccept
|
|
381
|
+
}), /* @__PURE__ */ c("button", {
|
|
351
382
|
type: "button",
|
|
352
383
|
className: "rte-ai-panel-v2__reject-btn",
|
|
353
|
-
onClick:
|
|
354
|
-
children:
|
|
384
|
+
onClick: V,
|
|
385
|
+
children: y.aiReject
|
|
355
386
|
})]
|
|
356
387
|
})
|
|
357
388
|
]
|
|
358
389
|
}),
|
|
359
|
-
|
|
390
|
+
D && /* @__PURE__ */ l("div", {
|
|
360
391
|
className: "rte-ai-panel-v2__error",
|
|
361
|
-
children: [/* @__PURE__ */
|
|
392
|
+
children: [/* @__PURE__ */ c("span", { children: D }), /* @__PURE__ */ c("button", {
|
|
362
393
|
type: "button",
|
|
363
|
-
onClick: () =>
|
|
364
|
-
children:
|
|
394
|
+
onClick: () => O(null),
|
|
395
|
+
children: y.aiDismiss
|
|
365
396
|
})]
|
|
366
397
|
})
|
|
367
398
|
]
|
|
368
399
|
});
|
|
369
400
|
};
|
|
370
401
|
//#endregion
|
|
371
|
-
export {
|
|
402
|
+
export { g as default };
|
|
372
403
|
|
|
373
404
|
//# sourceMappingURL=AIRewrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIRewrite.js","names":[],"sources":["../../../../src/components/pro/RichTextEditor/AIRewrite.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect } from 'react';\nimport type { Editor } from '@tiptap/react';\nimport type { AIConfig, AIAction, RichTextEditorLabels } from './types';\nimport { defaultLabels } from './types';\n\ninterface AIRewriteProps {\n editor: Editor;\n aiConfig: AIConfig;\n labels?: RichTextEditorLabels;\n initialSelection: string;\n selectionRange: { from: number; to: number };\n onClose: () => void;\n}\n\nconst QUICK_ACTIONS: { key: AIAction; labelKey: keyof RichTextEditorLabels; icon: string }[] = [\n { key: 'rewrite', labelKey: 'aiRewrite', icon: 'β' },\n { key: 'shorten', labelKey: 'aiShorten', icon: 'π' },\n { key: 'expand', labelKey: 'aiExpand', icon: 'π' },\n { key: 'fix_grammar', labelKey: 'aiFixGrammar', icon: 'β' },\n { key: 'translate_en', labelKey: 'aiTranslateEn', icon: 'EN' },\n { key: 'translate_zh', labelKey: 'aiTranslateZh', icon: 'δΈ' },\n { key: 'professional', labelKey: 'aiProfessional', icon: 'πΌ' },\n { key: 'casual', labelKey: 'aiCasual', icon: 'π¬' },\n];\n\nfunction getSystemPrompt(action: AIAction | 'custom', customPrompt?: string): string {\n if (action === 'custom') return customPrompt || 'Follow the user instructions.';\n const prompts: Record<AIAction, string> = {\n rewrite: 'Rewrite the following text to improve clarity and readability. Keep the same meaning and tone. Return only the rewritten text.',\n shorten: 'Shorten the following text while preserving its key meaning. Be concise. Return only the shortened text.',\n expand: 'Expand the following text with more details and examples while keeping the same tone. Return only the expanded text.',\n fix_grammar: 'Fix any grammar, spelling, and punctuation errors in the following text. Return only the corrected text.',\n translate_en: 'Translate the following text to English. Return only the translated text.',\n translate_zh: 'Translate the following text to Chinese. Return only the translated text.',\n professional: 'Rewrite the following text in a professional, formal tone. Return only the rewritten text.',\n casual: 'Rewrite the following text in a casual, friendly tone. Return only the rewritten text.',\n };\n return customPrompt || prompts[action];\n}\n\nasync function* readSSE(response: Response): AsyncGenerator<string> {\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No response body');\n const decoder = new TextDecoder();\n let buffer = '';\n let data: string[] = [];\n try {\n while (true) {\n const { done, value } = await reader.read();\n buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });\n // Normalize CRLF only when the complete line is available (chunks may split it).\n let newline: number;\n while ((newline = buffer.indexOf('\\n')) !== -1) {\n const line = buffer.slice(0, newline).replace(/\\r$/, '');\n buffer = buffer.slice(newline + 1);\n if (!line) {\n if (data.length) yield data.join('\\n');\n data = [];\n } else if (line.startsWith('data:')) {\n data.push(line.slice(5).replace(/^ /, ''));\n }\n }\n if (done) {\n if (buffer.startsWith('data:')) data.push(buffer.slice(5).replace(/^ /, '').replace(/\\r$/, ''));\n if (data.length) yield data.join('\\n');\n return;\n }\n }\n } finally {\n try { await reader.cancel(); } catch { /* The request may already be aborted. */ }\n reader.releaseLock();\n }\n}\n\nasync function* streamOpenAI(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n signal: AbortSignal,\n): AsyncGenerator<string> {\n const body = JSON.stringify({\n model: config.model,\n messages: [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: text },\n ],\n stream: true,\n });\n\n const response = await fetch(config.gateway, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}),\n ...config.headers,\n },\n body,\n signal,\n });\n\n if (!response.ok) throw new Error(`AI API error: ${response.status} ${response.statusText}`);\n for await (const payload of readSSE(response)) {\n if (payload.trim() === '[DONE]') return;\n let data;\n try { data = JSON.parse(payload); } catch { continue; }\n if (data?.error) throw new Error(data.error.message || 'AI stream error');\n const content = data?.choices?.[0]?.delta?.content;\n if (typeof content === 'string') yield content;\n }\n}\n\nasync function* streamAnthropic(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n signal: AbortSignal,\n): AsyncGenerator<string> {\n const body = JSON.stringify({\n model: config.model,\n max_tokens: 4096,\n system: systemPrompt,\n messages: [{ role: 'user', content: text }],\n stream: true,\n });\n\n const response = await fetch(config.gateway, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(config.apiKey ? { 'x-api-key': config.apiKey } : {}),\n 'anthropic-version': '2023-06-01',\n ...config.headers,\n },\n body,\n signal,\n });\n\n if (!response.ok) throw new Error(`AI API error: ${response.status} ${response.statusText}`);\n for await (const payload of readSSE(response)) {\n let data;\n try { data = JSON.parse(payload); } catch { continue; }\n if (data?.type === 'error') throw new Error(data.error?.message || 'AI stream error');\n if (data?.type === 'message_stop') return;\n if (data?.type === 'content_block_delta' && typeof data.delta?.text === 'string') yield data.delta.text;\n }\n}\n\nfunction getStream(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n action: AIAction | 'custom',\n signal: AbortSignal,\n): AsyncIterable<string> {\n if (config.protocol === 'custom') {\n if (!config.customHandler) throw new Error('Custom AI protocol requires customHandler');\n return config.customHandler({ text, action: action === 'custom' ? 'rewrite' : action, signal });\n }\n if (config.protocol === 'anthropic') return streamAnthropic(config, text, systemPrompt, signal);\n return streamOpenAI(config, text, systemPrompt, signal);\n}\n\nconst AIRewrite: React.FC<AIRewriteProps> = ({ editor, aiConfig, labels: propsLabels, initialSelection, selectionRange, onClose }) => {\n const labels = { ...defaultLabels, ...propsLabels };\n const [prompt, setPrompt] = useState('');\n const [isProcessing, setIsProcessing] = useState(false);\n const [streamedText, setStreamedText] = useState('');\n const [error, setError] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const promptRef = useRef<HTMLTextAreaElement>(null);\n const [editable, setEditable] = useState(() => !editor.isDestroyed && editor.isEditable);\n const [invalid, setInvalid] = useState(false);\n const sourceDoc = useRef(editor.state.doc);\n const invalidRef = useRef(false);\n\n const cancelRequest = useCallback(() => {\n const request = abortRef.current;\n abortRef.current = null;\n request?.abort();\n }, []);\n\n useEffect(() => {\n sourceDoc.current = editor.state.doc;\n invalidRef.current = false;\n setInvalid(false);\n setStreamedText('');\n setIsProcessing(false);\n setError(null);\n const invalidate = () => {\n setEditable(!editor.isDestroyed && editor.isEditable);\n if (editor.isDestroyed || !editor.isEditable || editor.state.doc !== sourceDoc.current) {\n invalidRef.current = true;\n setInvalid(true);\n cancelRequest();\n setIsProcessing(false);\n setStreamedText('');\n setError('The document or editing permissions changed. Close and reopen AI Assistant.');\n }\n };\n invalidate();\n editor.on('update', invalidate);\n editor.on('transaction', invalidate);\n editor.on('destroy', invalidate);\n return () => {\n cancelRequest();\n editor.off('update', invalidate);\n editor.off('transaction', invalidate);\n editor.off('destroy', invalidate);\n };\n }, [editor, initialSelection, selectionRange.from, selectionRange.to, cancelRequest]);\n\n const selectedText = initialSelection;\n\n useEffect(() => {\n if (promptRef.current) promptRef.current.focus();\n }, []);\n\n const handleGenerate = useCallback(async (action: AIAction | 'custom' = 'custom', customPromptOverride?: string) => {\n if (editor.isDestroyed || !editor.isEditable || invalidRef.current || abortRef.current) return;\n const text = selectedText || editor.state.doc.textContent;\n if (!text.trim() && !prompt.trim()) return;\n\n const systemPrompt = action === 'custom'\n ? (prompt || 'Improve the following text. Return only the improved text.')\n : getSystemPrompt(action, customPromptOverride);\n\n const userText = action === 'custom' && prompt\n ? `Instructions: ${prompt}\\n\\nText:\\n${text}`\n : text;\n\n setIsProcessing(true);\n setStreamedText('');\n setError(null);\n\n const abort = new AbortController();\n abortRef.current = abort;\n\n try {\n let result = '';\n for await (const chunk of getStream(aiConfig, userText, systemPrompt, action, abort.signal)) {\n if (abort.signal.aborted || abortRef.current !== abort) break;\n result += chunk;\n setStreamedText(result);\n }\n } catch (err: unknown) {\n if (abort.signal.aborted || abortRef.current !== abort) return;\n setStreamedText('');\n setError(String(err instanceof Error ? err.message : err));\n } finally {\n if (abortRef.current === abort) {\n abortRef.current = null;\n setIsProcessing(false);\n }\n }\n }, [editor, aiConfig, selectedText, prompt]);\n\n const handleAccept = useCallback(() => {\n if (!streamedText || abortRef.current || editor.isDestroyed || !editor.isEditable || invalidRef.current) return;\n const { from, to } = selectionRange;\n if (editor.state.doc !== sourceDoc.current || !Number.isInteger(from) || !Number.isInteger(to) || from < 0 || to < from || to > editor.state.doc.content.size) {\n setError('The original selection is no longer valid. Close and reopen AI Assistant.');\n return;\n }\n // AI output is plain text, never HTML. Use the captured range even if the cursor moved.\n editor.view.dispatch(editor.state.tr.insertText(streamedText, from, to));\n setStreamedText('');\n setPrompt('');\n onClose();\n }, [editor, streamedText, selectionRange, onClose]);\n\n const handleReject = useCallback(() => {\n cancelRequest();\n setStreamedText('');\n setIsProcessing(false);\n setError(null);\n }, [cancelRequest]);\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n handleGenerate();\n }\n }, [handleGenerate]);\n\n return (\n <div className=\"rte-ai-panel-v2\">\n <div className=\"rte-ai-panel-v2__header\">\n <span className=\"rte-ai-panel-v2__title\">β¨ {labels.ai || 'AI Assistant'}</span>\n <button type=\"button\" className=\"rte-ai-panel-v2__close-btn\" onClick={() => { cancelRequest(); onClose(); }} title=\"Close\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>\n {/* Prompt input */}\n <div className=\"rte-ai-panel-v2__prompt-section\">\n <label className=\"rte-ai-panel-v2__label\">Prompt</label>\n <textarea\n ref={promptRef}\n className=\"rte-ai-panel-v2__prompt-input\"\n value={prompt}\n onChange={(e) => setPrompt(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder=\"Describe what AI should do... (Ctrl+Enter to generate)\"\n rows={3}\n disabled={isProcessing || !editable || invalid}\n />\n </div>\n\n {/* Selected text display */}\n <div className=\"rte-ai-panel-v2__selection-section\">\n <label className=\"rte-ai-panel-v2__label\">Selected Text</label>\n <div className=\"rte-ai-panel-v2__selection-box\">\n {selectedText ? (\n <span>{selectedText.length > 300 ? selectedText.slice(0, 300) + '...' : selectedText}</span>\n ) : (\n <span className=\"rte-ai-panel-v2__empty\">No text selected (will use all content)</span>\n )}\n </div>\n </div>\n\n {/* Quick actions */}\n <div className=\"rte-ai-panel-v2__quick-actions\">\n {QUICK_ACTIONS.map(({ key, labelKey, icon }) => (\n <button\n key={key}\n type=\"button\"\n className=\"rte-ai-panel-v2__quick-btn\"\n onClick={() => handleGenerate(key)}\n disabled={isProcessing || !editable || invalid}\n title={labels[labelKey]}\n >\n <span>{icon}</span>\n <span>{labels[labelKey]}</span>\n </button>\n ))}\n </div>\n\n {/* Generate button */}\n <div className=\"rte-ai-panel-v2__actions\">\n <button\n type=\"button\"\n className=\"rte-ai-panel-v2__generate-btn\"\n onClick={() => handleGenerate()}\n disabled={isProcessing || !editable || invalid || (!prompt.trim() && !selectedText.trim())}\n >\n {isProcessing ? (\n <><div className=\"rte-ai-panel__spinner\" /> {labels.aiProcessing}</>\n ) : (\n 'β¨ Generate'\n )}\n </button>\n {isProcessing && (\n <button type=\"button\" className=\"rte-ai-panel-v2__cancel-btn\" onClick={handleReject}>\n Cancel\n </button>\n )}\n </div>\n\n {/* Streaming result */}\n {streamedText && (\n <div className=\"rte-ai-panel-v2__result\">\n <label className=\"rte-ai-panel-v2__label\">Result</label>\n <div className=\"rte-ai-panel-v2__result-text\">{streamedText}</div>\n <div className=\"rte-ai-panel-v2__result-actions\">\n <button type=\"button\" className=\"rte-ai-panel-v2__accept-btn\" disabled={isProcessing || !editable || invalid} onClick={handleAccept}>\n {labels.aiAccept}\n </button>\n <button type=\"button\" className=\"rte-ai-panel-v2__reject-btn\" onClick={handleReject}>\n {labels.aiReject}\n </button>\n </div>\n </div>\n )}\n\n {/* Error */}\n {error && (\n <div className=\"rte-ai-panel-v2__error\">\n <span>{error}</span>\n <button type=\"button\" onClick={() => setError(null)}>Dismiss</button>\n </div>\n )}\n </div>\n );\n};\n\nexport default AIRewrite;\n"],"mappings":";;;;AAcA,IAAM,IAAyF;CAC7F;EAAE,KAAK;EAAW,UAAU;EAAa,MAAM;CAAI;CACnD;EAAE,KAAK;EAAW,UAAU;EAAa,MAAM;CAAK;CACpD;EAAE,KAAK;EAAU,UAAU;EAAY,MAAM;CAAK;CAClD;EAAE,KAAK;EAAe,UAAU;EAAgB,MAAM;CAAI;CAC1D;EAAE,KAAK;EAAgB,UAAU;EAAiB,MAAM;C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,SAAS;OACpE,UAAA,EAAO;MACF,CAAA,CACL;;IACF;;GAIN,KACC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,QAAD,EAAA,UAAO,EAAY,CAAA,GACnB,kBAAC,UAAD;KAAQ,MAAK;KAAS,eAAe,EAAS,IAAI;KAAG,UAAA;IAAe,CAAA,CACjE;;EAEJ;;AAET"}
|
|
1
|
+
{"version":3,"file":"AIRewrite.js","names":[],"sources":["../../../../src/components/pro/RichTextEditor/AIRewrite.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect, useId } from 'react';\nimport type { Editor } from '@tiptap/react';\nimport type { AIConfig, AIAction, RichTextEditorLabels } from './types';\nimport { defaultLabels } from './types';\nimport StreamingText from '../../ai/StreamingText';\nimport LoadingState from '../../ai/LoadingState';\n\ninterface AIRewriteProps {\n editor: Editor;\n aiConfig: AIConfig;\n labels?: RichTextEditorLabels;\n initialSelection: string;\n selectionRange: { from: number; to: number };\n onClose: () => void;\n}\n\nconst QUICK_ACTIONS: { key: AIAction; labelKey: keyof RichTextEditorLabels; icon: string }[] = [\n { key: 'rewrite', labelKey: 'aiRewrite', icon: 'β' },\n { key: 'shorten', labelKey: 'aiShorten', icon: 'π' },\n { key: 'expand', labelKey: 'aiExpand', icon: 'π' },\n { key: 'fix_grammar', labelKey: 'aiFixGrammar', icon: 'β' },\n { key: 'translate_en', labelKey: 'aiTranslateEn', icon: 'EN' },\n { key: 'translate_zh', labelKey: 'aiTranslateZh', icon: 'δΈ' },\n { key: 'professional', labelKey: 'aiProfessional', icon: 'πΌ' },\n { key: 'casual', labelKey: 'aiCasual', icon: 'π¬' },\n];\n\nfunction getSystemPrompt(action: AIAction | 'custom', customPrompt?: string): string {\n if (action === 'custom') return customPrompt || 'Follow the user instructions.';\n const prompts: Record<AIAction, string> = {\n rewrite: 'Rewrite the following text to improve clarity and readability. Keep the same meaning and tone. Return only the rewritten text.',\n shorten: 'Shorten the following text while preserving its key meaning. Be concise. Return only the shortened text.',\n expand: 'Expand the following text with more details and examples while keeping the same tone. Return only the expanded text.',\n fix_grammar: 'Fix any grammar, spelling, and punctuation errors in the following text. Return only the corrected text.',\n translate_en: 'Translate the following text to English. Return only the translated text.',\n translate_zh: 'Translate the following text to Chinese. Return only the translated text.',\n professional: 'Rewrite the following text in a professional, formal tone. Return only the rewritten text.',\n casual: 'Rewrite the following text in a casual, friendly tone. Return only the rewritten text.',\n };\n return customPrompt || prompts[action];\n}\n\nasync function* readSSE(response: Response): AsyncGenerator<string> {\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No response body');\n const decoder = new TextDecoder();\n let buffer = '';\n let data: string[] = [];\n try {\n while (true) {\n const { done, value } = await reader.read();\n buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });\n // Normalize CRLF only when the complete line is available (chunks may split it).\n let newline: number;\n while ((newline = buffer.indexOf('\\n')) !== -1) {\n const line = buffer.slice(0, newline).replace(/\\r$/, '');\n buffer = buffer.slice(newline + 1);\n if (!line) {\n if (data.length) yield data.join('\\n');\n data = [];\n } else if (line.startsWith('data:')) {\n data.push(line.slice(5).replace(/^ /, ''));\n }\n }\n if (done) {\n if (buffer.startsWith('data:')) data.push(buffer.slice(5).replace(/^ /, '').replace(/\\r$/, ''));\n if (data.length) yield data.join('\\n');\n return;\n }\n }\n } finally {\n try { await reader.cancel(); } catch { /* The request may already be aborted. */ }\n reader.releaseLock();\n }\n}\n\nasync function* streamOpenAI(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n signal: AbortSignal,\n): AsyncGenerator<string> {\n if (!config.gateway || !config.model) throw new Error('OpenAI protocol requires gateway and model');\n const body = JSON.stringify({\n model: config.model,\n messages: [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: text },\n ],\n stream: true,\n });\n\n const response = await fetch(config.gateway, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}),\n ...config.headers,\n },\n body,\n signal,\n });\n\n if (!response.ok) throw new Error(`AI API error: ${response.status} ${response.statusText}`);\n for await (const payload of readSSE(response)) {\n if (payload.trim() === '[DONE]') return;\n let data;\n try { data = JSON.parse(payload); } catch { continue; }\n if (data?.error) throw new Error(data.error.message || 'AI stream error');\n const content = data?.choices?.[0]?.delta?.content;\n if (typeof content === 'string') yield content;\n }\n}\n\nasync function* streamAnthropic(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n signal: AbortSignal,\n): AsyncGenerator<string> {\n if (!config.gateway || !config.model) throw new Error('Anthropic protocol requires gateway and model');\n const body = JSON.stringify({\n model: config.model,\n max_tokens: 4096,\n system: systemPrompt,\n messages: [{ role: 'user', content: text }],\n stream: true,\n });\n\n const response = await fetch(config.gateway, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(config.apiKey ? { 'x-api-key': config.apiKey } : {}),\n 'anthropic-version': '2023-06-01',\n ...config.headers,\n },\n body,\n signal,\n });\n\n if (!response.ok) throw new Error(`AI API error: ${response.status} ${response.statusText}`);\n for await (const payload of readSSE(response)) {\n let data;\n try { data = JSON.parse(payload); } catch { continue; }\n if (data?.type === 'error') throw new Error(data.error?.message || 'AI stream error');\n if (data?.type === 'message_stop') return;\n if (data?.type === 'content_block_delta' && typeof data.delta?.text === 'string') yield data.delta.text;\n }\n}\n\nfunction getStream(\n config: AIConfig,\n text: string,\n systemPrompt: string,\n action: AIAction | 'custom',\n signal: AbortSignal,\n request?: { prompt: string; selectedText: string; mode: 'replace' | 'insert' },\n): AsyncIterable<string> {\n if (config.protocol === 'custom') {\n if (!config.customHandler) throw new Error('Custom AI protocol requires customHandler');\n return config.customHandler({\n text,\n action: action === 'custom' ? 'rewrite' : action,\n systemPrompt,\n signal,\n prompt: request?.prompt ?? '',\n selectedText: request?.selectedText ?? text,\n mode: request?.mode ?? 'replace',\n });\n }\n if (config.protocol === 'anthropic') return streamAnthropic(config, text, systemPrompt, signal);\n return streamOpenAI(config, text, systemPrompt, signal);\n}\n\nconst AIRewrite: React.FC<AIRewriteProps> = ({ editor, aiConfig, labels: propsLabels, initialSelection, selectionRange, onClose }) => {\n const labels = { ...defaultLabels, ...propsLabels };\n const promptId = useId();\n const [prompt, setPrompt] = useState('');\n const [isProcessing, setIsProcessing] = useState(false);\n const [streamedText, setStreamedText] = useState('');\n const [error, setError] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const promptRef = useRef<HTMLTextAreaElement>(null);\n const [editable, setEditable] = useState(() => !editor.isDestroyed && editor.isEditable);\n const [invalid, setInvalid] = useState(false);\n const sourceDoc = useRef(editor.state.doc);\n const invalidRef = useRef(false);\n\n const cancelRequest = useCallback(() => {\n const request = abortRef.current;\n abortRef.current = null;\n request?.abort();\n }, []);\n\n useEffect(() => {\n sourceDoc.current = editor.state.doc;\n invalidRef.current = false;\n setInvalid(false);\n setStreamedText('');\n setIsProcessing(false);\n setError(null);\n const invalidate = () => {\n setEditable(!editor.isDestroyed && editor.isEditable);\n if (editor.isDestroyed || !editor.isEditable || editor.state.doc !== sourceDoc.current) {\n invalidRef.current = true;\n setInvalid(true);\n cancelRequest();\n setIsProcessing(false);\n setStreamedText('');\n setError('The document or editing permissions changed. Close and reopen AI Assistant.');\n }\n };\n invalidate();\n editor.on('update', invalidate);\n editor.on('transaction', invalidate);\n editor.on('destroy', invalidate);\n return () => {\n cancelRequest();\n editor.off('update', invalidate);\n editor.off('transaction', invalidate);\n editor.off('destroy', invalidate);\n };\n }, [editor, initialSelection, selectionRange.from, selectionRange.to, cancelRequest]);\n\n const selectedText = initialSelection;\n\n useEffect(() => {\n if (promptRef.current) promptRef.current.focus();\n }, []);\n\n const handleGenerate = useCallback(async (action: AIAction | 'custom' = 'custom', customPromptOverride?: string) => {\n if (editor.isDestroyed || !editor.isEditable || invalidRef.current || abortRef.current) return;\n const mode = selectedText ? 'replace' : 'insert';\n if (mode === 'insert' && !prompt.trim()) return;\n\n const actionPrompt = action === 'custom'\n ? (mode === 'replace'\n ? 'Edit the selected text according to the user instruction. Return only the replacement text.'\n : 'Generate text according to the user instruction. Return only the text to insert.')\n : getSystemPrompt(action, customPromptOverride);\n const systemPrompt = [aiConfig.systemPrompt, actionPrompt].filter(Boolean).join('\\n\\n');\n const userText = mode === 'replace'\n ? (prompt.trim()\n ? `Instruction:\\n${prompt.trim()}\\n\\nSelected text:\\n${selectedText}`\n : selectedText)\n : prompt.trim();\n\n setIsProcessing(true);\n setStreamedText('');\n setError(null);\n\n const abort = new AbortController();\n abortRef.current = abort;\n\n try {\n let result = '';\n for await (const chunk of getStream(aiConfig, userText, systemPrompt, action, abort.signal, {\n prompt: prompt.trim(),\n selectedText,\n mode,\n })) {\n if (abort.signal.aborted || abortRef.current !== abort) break;\n result += chunk;\n setStreamedText(result);\n }\n } catch (err: unknown) {\n if (abort.signal.aborted || abortRef.current !== abort) return;\n setStreamedText('');\n setError(String(err instanceof Error ? err.message : err));\n } finally {\n if (abortRef.current === abort) {\n abortRef.current = null;\n setIsProcessing(false);\n }\n }\n }, [editor, aiConfig, selectedText, prompt]);\n\n const handleAccept = useCallback(() => {\n if (!streamedText || abortRef.current || editor.isDestroyed || !editor.isEditable || invalidRef.current) return;\n const { from, to } = selectionRange;\n if (editor.state.doc !== sourceDoc.current || !Number.isInteger(from) || !Number.isInteger(to) || from < 0 || to < from || to > editor.state.doc.content.size) {\n setError('The original selection is no longer valid. Close and reopen AI Assistant.');\n return;\n }\n // AI output is plain text, never HTML. Use the captured range even if the cursor moved.\n editor.view.dispatch(editor.state.tr.insertText(streamedText, from, to));\n setStreamedText('');\n setPrompt('');\n onClose();\n }, [editor, streamedText, selectionRange, onClose]);\n\n const handleReject = useCallback(() => {\n cancelRequest();\n setStreamedText('');\n setIsProcessing(false);\n setError(null);\n }, [cancelRequest]);\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n handleGenerate();\n }\n }, [handleGenerate]);\n\n return (\n <div className=\"rte-ai-panel-v2\">\n <div className=\"rte-ai-panel-v2__header\">\n <span className=\"rte-ai-panel-v2__title\">β¨ {labels.ai || 'AI Assistant'}</span>\n <button type=\"button\" className=\"rte-ai-panel-v2__close-btn\" onClick={() => { cancelRequest(); onClose(); }} title={labels.aiClose} aria-label={labels.aiClose}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>\n {/* Prompt input */}\n <div className=\"rte-ai-panel-v2__prompt-section\">\n <label className=\"rte-ai-panel-v2__label\" htmlFor={promptId}>{labels.aiPromptLabel}</label>\n <textarea\n id={promptId}\n ref={promptRef}\n className=\"rte-ai-panel-v2__prompt-input\"\n value={prompt}\n onChange={(e) => setPrompt(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={labels.aiPromptPlaceholder}\n rows={3}\n disabled={isProcessing || !editable || invalid}\n />\n </div>\n\n {/* Selected text display */}\n <div className=\"rte-ai-panel-v2__selection-section\">\n <span className=\"rte-ai-panel-v2__label\">{labels.aiSelectedText}</span>\n <div className=\"rte-ai-panel-v2__selection-box\">\n {selectedText ? (\n <span>{selectedText.length > 300 ? selectedText.slice(0, 300) + '...' : selectedText}</span>\n ) : (\n <span className=\"rte-ai-panel-v2__empty\">{labels.aiInsertHint}</span>\n )}\n </div>\n </div>\n\n {/* Quick actions */}\n <div className=\"rte-ai-panel-v2__quick-actions\">\n {QUICK_ACTIONS.map(({ key, labelKey, icon }) => (\n <button\n key={key}\n type=\"button\"\n className=\"rte-ai-panel-v2__quick-btn\"\n onClick={() => handleGenerate(key)}\n disabled={isProcessing || !editable || invalid || !selectedText.trim()}\n title={selectedText ? labels[labelKey] : labels.aiInsertHint}\n >\n <span>{icon}</span>\n <span>{labels[labelKey]}</span>\n </button>\n ))}\n </div>\n\n {/* Generate button */}\n <div className=\"rte-ai-panel-v2__actions\">\n <button\n type=\"button\"\n className=\"rte-ai-panel-v2__generate-btn\"\n onClick={() => handleGenerate()}\n disabled={isProcessing || !editable || invalid || (!prompt.trim() && !selectedText.trim())}\n >\n {isProcessing ? labels.aiProcessing : `β¨ ${labels.aiGenerate}`}\n </button>\n {isProcessing && (\n <button type=\"button\" className=\"rte-ai-panel-v2__cancel-btn\" onClick={handleReject}>\n {labels.aiCancel}\n </button>\n )}\n </div>\n\n {/* Streaming result */}\n {isProcessing && !streamedText && (\n <LoadingState\n className=\"rte-ai-panel-v2__loading\"\n label={labels.aiProcessing}\n variant=\"dots\"\n layout=\"block\"\n size=\"sm\"\n />\n )}\n {streamedText && (\n <div className=\"rte-ai-panel-v2__result\">\n <div className=\"rte-ai-panel-v2__result-header\">\n <span className=\"rte-ai-panel-v2__label\">{labels.aiResult}</span>\n <span className={`rte-ai-panel-v2__stream-status ${isProcessing ? 'rte-ai-panel-v2__stream-status--live' : ''}`} role=\"status\">\n <span className=\"rte-ai-panel-v2__stream-dot\" aria-hidden=\"true\" />\n {isProcessing ? labels.aiProcessing : `${streamedText.length} chars`}\n </span>\n </div>\n <div className=\"rte-ai-panel-v2__result-text\">\n <StreamingText text={streamedText} streaming={isProcessing} />\n </div>\n <div className=\"rte-ai-panel-v2__result-actions\">\n <button type=\"button\" className=\"rte-ai-panel-v2__accept-btn\" disabled={isProcessing || !editable || invalid} onClick={handleAccept}>\n {labels.aiAccept}\n </button>\n <button type=\"button\" className=\"rte-ai-panel-v2__reject-btn\" onClick={handleReject}>\n {labels.aiReject}\n </button>\n </div>\n </div>\n )}\n\n {/* Error */}\n {error && (\n <div className=\"rte-ai-panel-v2__error\">\n <span>{error}</span>\n <button type=\"button\" onClick={() => setError(null)}>{labels.aiDismiss}</button>\n </div>\n )}\n </div>\n );\n};\n\nexport default AIRewrite;\n"],"mappings":";;;;;;AAgBA,IAAM,IAAyF;CA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AAD;KAAQ,MAAK;KAAS,eAAe,EAAS,IAAI;KAAI,UAAA,EAAO;IAAkB,CAAA,CAC5E;;EAEJ;;AAET"}
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import type { Editor } from '@tiptap/react';
|
|
3
3
|
interface BlockHandleProps {
|
|
4
4
|
editor: Editor;
|
|
5
|
+
/** Keep the left control rail visible instead of revealing it only on hover. */
|
|
6
|
+
persistent?: boolean;
|
|
5
7
|
}
|
|
6
8
|
declare const BlockHandle: React.FC<BlockHandleProps>;
|
|
7
9
|
export default BlockHandle;
|