@blocknote/xl-ai 0.46.2 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote-xl-ai.cjs +1 -1
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +274 -264
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/components/AIMenu/AIMenuController.tsx +66 -59
- package/src/components/AIMenu/PromptSuggestionMenu.tsx +25 -4
package/dist/blocknote-xl-ai.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Chat as
|
|
2
|
-
import { createExtension as
|
|
3
|
-
import { ForkYDocExtension as
|
|
4
|
-
import { suggestChanges as
|
|
5
|
-
import { Slice as
|
|
6
|
-
import { Plugin as
|
|
7
|
-
import { fixTablesKey as
|
|
8
|
-
import { DecorationSet as Z, Decoration as
|
|
9
|
-
import { defaultSelectionBuilder as
|
|
10
|
-
import { b as
|
|
11
|
-
import { C as
|
|
12
|
-
import { jsxs as
|
|
13
|
-
import { useBlockNoteContext as
|
|
14
|
-
import
|
|
15
|
-
import { offset as
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
return new
|
|
19
|
-
key:
|
|
1
|
+
import { Chat as oe } from "@ai-sdk/react";
|
|
2
|
+
import { createExtension as re, createStore as H, getNodeById as ie, UnreachableCaseError as ae, mergeCSSClasses as se } from "@blocknote/core";
|
|
3
|
+
import { ForkYDocExtension as A, ShowSelectionExtension as O, filterSuggestionItems as le, FormattingToolbarExtension as ce } from "@blocknote/core/extensions";
|
|
4
|
+
import { suggestChanges as ue, revertSuggestions as j, applySuggestions as me } from "@handlewithcare/prosemirror-suggest-changes";
|
|
5
|
+
import { Slice as D, Fragment as q } from "prosemirror-model";
|
|
6
|
+
import { Plugin as $, PluginKey as Y } from "prosemirror-state";
|
|
7
|
+
import { fixTablesKey as de } from "prosemirror-tables";
|
|
8
|
+
import { DecorationSet as Z, Decoration as N } from "prosemirror-view";
|
|
9
|
+
import { defaultSelectionBuilder as fe } from "y-prosemirror";
|
|
10
|
+
import { b as ge, s as pe, c as _, a as I } from "./client-De9NkxJ-.js";
|
|
11
|
+
import { C as ht, P as Ct, S as bt, g as vt, d as St, f as yt, h as wt, j as kt, m as It, o as _t, p as xt, i as Mt, e as Lt, k as Pt, t as Tt } from "./client-De9NkxJ-.js";
|
|
12
|
+
import { jsxs as he, jsx as c } from "react/jsx-runtime";
|
|
13
|
+
import { useBlockNoteContext as Ce, useComponentsContext as z, useSuggestionMenuKeyboardHandler as be, useBlockNoteEditor as R, useExtension as P, useExtensionState as J, BlockPopover as ve } from "@blocknote/react";
|
|
14
|
+
import y, { useState as Q, useCallback as L, useMemo as M, useEffect as B, useRef as F } from "react";
|
|
15
|
+
import { offset as Se, flip as ye, size as we, autoUpdate as ke } from "@floating-ui/react";
|
|
16
|
+
const U = new Y("blocknote-agent-cursor");
|
|
17
|
+
function Ie(e) {
|
|
18
|
+
return new $({
|
|
19
|
+
key: U,
|
|
20
20
|
view: (t) => ({}),
|
|
21
21
|
state: {
|
|
22
22
|
init: () => ({
|
|
@@ -33,18 +33,18 @@ function ke(e) {
|
|
|
33
33
|
},
|
|
34
34
|
props: {
|
|
35
35
|
decorations: (t) => {
|
|
36
|
-
const { doc: o } = t, { selection: n } =
|
|
36
|
+
const { doc: o } = t, { selection: n } = U.getState(t), i = [];
|
|
37
37
|
if (!n)
|
|
38
38
|
return Z.create(o, []);
|
|
39
39
|
i.push(
|
|
40
|
-
|
|
40
|
+
N.widget(n.head, () => _e(e), {
|
|
41
41
|
key: "agent-cursor",
|
|
42
42
|
side: 10
|
|
43
43
|
})
|
|
44
44
|
);
|
|
45
|
-
const
|
|
45
|
+
const u = Math.min(n.anchor, n.head), p = Math.max(n.anchor, n.head);
|
|
46
46
|
return i.push(
|
|
47
|
-
|
|
47
|
+
N.inline(u, p, fe(e), {
|
|
48
48
|
inclusiveEnd: !0,
|
|
49
49
|
inclusiveStart: !1
|
|
50
50
|
})
|
|
@@ -53,14 +53,14 @@ function ke(e) {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const _e = (e) => {
|
|
57
57
|
const t = document.createElement("span");
|
|
58
58
|
t.classList.add("bn-collaboration-cursor__base"), t.setAttribute("data-active", "true");
|
|
59
59
|
const o = document.createElement("span");
|
|
60
60
|
o.setAttribute("contentedEditable", "false"), o.classList.add("bn-collaboration-cursor__caret"), o.setAttribute("style", `background-color: ${e.color}`);
|
|
61
61
|
const n = document.createElement("span");
|
|
62
62
|
return n.classList.add("bn-collaboration-cursor__label"), n.setAttribute("style", `background-color: ${e.color}`), n.insertBefore(document.createTextNode(e.name), null), o.insertBefore(n, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(o, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
63
|
-
},
|
|
63
|
+
}, xe = new Y("blocknote-ai-plugin"), C = re(
|
|
64
64
|
({
|
|
65
65
|
editor: e,
|
|
66
66
|
options: t
|
|
@@ -68,9 +68,9 @@ const Ie = (e) => {
|
|
|
68
68
|
const o = H(t ?? {}), n = H({
|
|
69
69
|
aiMenuState: "closed"
|
|
70
70
|
});
|
|
71
|
-
let i,
|
|
72
|
-
const
|
|
73
|
-
return
|
|
71
|
+
let i, u = !1;
|
|
72
|
+
const p = ue();
|
|
73
|
+
return p.props.decorations = void 0, {
|
|
74
74
|
key: "ai",
|
|
75
75
|
options: o,
|
|
76
76
|
store: n,
|
|
@@ -79,7 +79,7 @@ const Ie = (e) => {
|
|
|
79
79
|
document.addEventListener(
|
|
80
80
|
"scroll",
|
|
81
81
|
() => {
|
|
82
|
-
a && (
|
|
82
|
+
a && (u = !1), a = !0;
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
capture: !0,
|
|
@@ -97,16 +97,16 @@ const Ie = (e) => {
|
|
|
97
97
|
);
|
|
98
98
|
},
|
|
99
99
|
prosemirrorPlugins: [
|
|
100
|
-
new
|
|
101
|
-
key:
|
|
100
|
+
new $({
|
|
101
|
+
key: xe,
|
|
102
102
|
filterTransaction: (r) => {
|
|
103
|
-
var
|
|
103
|
+
var s;
|
|
104
104
|
const a = n.state.aiMenuState;
|
|
105
|
-
return !(a !== "closed" && a.status === "ai-writing" && (
|
|
105
|
+
return !(a !== "closed" && a.status === "ai-writing" && (s = r.getMeta(de)) != null && s.fixTables);
|
|
106
106
|
}
|
|
107
107
|
}),
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
p,
|
|
109
|
+
Ie(
|
|
110
110
|
(t == null ? void 0 : t.agentCursor) || { name: "AI", color: "#8bc6ff" }
|
|
111
111
|
)
|
|
112
112
|
],
|
|
@@ -114,14 +114,14 @@ const Ie = (e) => {
|
|
|
114
114
|
* Open the AI menu at a specific block
|
|
115
115
|
*/
|
|
116
116
|
openAIMenuAtBlock(r) {
|
|
117
|
-
var
|
|
118
|
-
(
|
|
117
|
+
var s, m;
|
|
118
|
+
(s = e.getExtension(O)) == null || s.showSelection(!0, "aiMenu"), e.isEditable = !1, n.setState({
|
|
119
119
|
aiMenuState: {
|
|
120
120
|
blockId: r,
|
|
121
121
|
status: "user-input"
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
-
const a = (
|
|
124
|
+
const a = (m = e.domElement) == null ? void 0 : m.querySelector(
|
|
125
125
|
`[data-node-type="blockContainer"][data-id="${r}"]`
|
|
126
126
|
);
|
|
127
127
|
a == null || a.scrollIntoView({ block: "center" });
|
|
@@ -133,7 +133,7 @@ const Ie = (e) => {
|
|
|
133
133
|
var r;
|
|
134
134
|
n.setState({
|
|
135
135
|
aiMenuState: "closed"
|
|
136
|
-
}), i = void 0, (r = e.getExtension(
|
|
136
|
+
}), i = void 0, (r = e.getExtension(O)) == null || r.showSelection(!1, "aiMenu"), e.isEditable = !0, e.focus();
|
|
137
137
|
},
|
|
138
138
|
/**
|
|
139
139
|
* Accept the changes made by the LLM
|
|
@@ -141,35 +141,35 @@ const Ie = (e) => {
|
|
|
141
141
|
acceptChanges() {
|
|
142
142
|
var a;
|
|
143
143
|
const r = e.prosemirrorState.doc;
|
|
144
|
-
e.exec((
|
|
145
|
-
|
|
146
|
-
})), e.exec((
|
|
147
|
-
const
|
|
148
|
-
|
|
144
|
+
e.exec((s, m) => j(s, (l) => {
|
|
145
|
+
m == null || m(l.setMeta("addToHistory", !1));
|
|
146
|
+
})), e.exec((s, m) => {
|
|
147
|
+
const l = s.tr;
|
|
148
|
+
l.replace(
|
|
149
149
|
0,
|
|
150
|
-
|
|
151
|
-
new
|
|
150
|
+
l.doc.content.size,
|
|
151
|
+
new D(q.from(r), 0, 0)
|
|
152
152
|
);
|
|
153
|
-
const
|
|
154
|
-
return
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
const d = s.apply(l);
|
|
154
|
+
return me(d, (f) => {
|
|
155
|
+
m == null || m(
|
|
156
|
+
l.replace(
|
|
157
157
|
0,
|
|
158
|
-
|
|
159
|
-
new
|
|
158
|
+
l.doc.content.size,
|
|
159
|
+
new D(q.from(f.doc), 0, 0)
|
|
160
160
|
)
|
|
161
161
|
);
|
|
162
162
|
});
|
|
163
|
-
}), (a = e.getExtension(
|
|
163
|
+
}), (a = e.getExtension(A)) == null || a.merge({ keepChanges: !0 }), this.closeAIMenu();
|
|
164
164
|
},
|
|
165
165
|
/**
|
|
166
166
|
* Reject the changes made by the LLM
|
|
167
167
|
*/
|
|
168
168
|
rejectChanges() {
|
|
169
169
|
var r;
|
|
170
|
-
e.exec((a,
|
|
171
|
-
|
|
172
|
-
})), (r = e.getExtension(
|
|
170
|
+
e.exec((a, s) => j(a, (m) => {
|
|
171
|
+
s == null || s(m.setMeta("addToHistory", !1));
|
|
172
|
+
})), (r = e.getExtension(A)) == null || r.merge({ keepChanges: !1 }), this.closeAIMenu();
|
|
173
173
|
},
|
|
174
174
|
/**
|
|
175
175
|
* Abort the current LLM request.
|
|
@@ -181,8 +181,8 @@ const Ie = (e) => {
|
|
|
181
181
|
const { aiMenuState: a } = n.state;
|
|
182
182
|
if (a === "closed" || !i || a.status !== "thinking" && a.status !== "ai-writing")
|
|
183
183
|
return;
|
|
184
|
-
const
|
|
185
|
-
i.abortController.abort(r), await
|
|
184
|
+
const s = i.chat;
|
|
185
|
+
i.abortController.abort(r), await s.stop();
|
|
186
186
|
},
|
|
187
187
|
/**
|
|
188
188
|
* Retry the previous LLM call.
|
|
@@ -211,12 +211,12 @@ const Ie = (e) => {
|
|
|
211
211
|
* use {@link executeLLMRequest} instead which will handle the status updates for you.
|
|
212
212
|
*/
|
|
213
213
|
setAIResponseStatus(r) {
|
|
214
|
-
var
|
|
214
|
+
var s;
|
|
215
215
|
const a = n.state.aiMenuState;
|
|
216
216
|
if (a !== "closed")
|
|
217
|
-
if (r === "ai-writing" && ((
|
|
217
|
+
if (r === "ai-writing" && ((s = e.getExtension(O)) == null || s.showSelection(!1, "aiMenu")), typeof r == "object") {
|
|
218
218
|
if (r.status !== "error")
|
|
219
|
-
throw new
|
|
219
|
+
throw new ae(r.status);
|
|
220
220
|
this.store.setState({
|
|
221
221
|
aiMenuState: {
|
|
222
222
|
status: r.status,
|
|
@@ -242,56 +242,56 @@ const Ie = (e) => {
|
|
|
242
242
|
* Execute a call to an LLM and apply the result to the editor
|
|
243
243
|
*/
|
|
244
244
|
async invokeAI(r) {
|
|
245
|
-
var a,
|
|
246
|
-
this.setAIResponseStatus("thinking"), (a = e.getExtension(
|
|
245
|
+
var a, s, m, l;
|
|
246
|
+
this.setAIResponseStatus("thinking"), (a = e.getExtension(A)) == null || a.fork();
|
|
247
247
|
try {
|
|
248
|
-
const
|
|
249
|
-
i ? (i.previousRequestOptions = r, i.abortController =
|
|
248
|
+
const d = new AbortController();
|
|
249
|
+
i ? (i.previousRequestOptions = r, i.abortController = d) : i = {
|
|
250
250
|
previousRequestOptions: r,
|
|
251
|
-
chat: ((
|
|
251
|
+
chat: ((s = r.chatProvider) == null ? void 0 : s.call(r)) || ((l = (m = this.options.state).chatProvider) == null ? void 0 : l.call(m)) || new oe({
|
|
252
252
|
sendAutomaticallyWhen: () => !1,
|
|
253
253
|
transport: r.transport || this.options.state.transport
|
|
254
254
|
}),
|
|
255
|
-
abortController:
|
|
255
|
+
abortController: d
|
|
256
256
|
};
|
|
257
257
|
const f = i.chat;
|
|
258
258
|
r = {
|
|
259
259
|
...o.state,
|
|
260
260
|
...r
|
|
261
261
|
};
|
|
262
|
-
const
|
|
262
|
+
const b = await ge({
|
|
263
263
|
editor: e,
|
|
264
264
|
useSelection: r.useSelection,
|
|
265
265
|
deleteEmptyCursorBlock: r.deleteEmptyCursorBlock,
|
|
266
266
|
streamToolsProvider: r.streamToolsProvider ?? this.options.state.streamToolsProvider,
|
|
267
267
|
documentStateBuilder: r.documentStateBuilder ?? this.options.state.documentStateBuilder,
|
|
268
|
-
onBlockUpdated: (
|
|
269
|
-
const
|
|
270
|
-
if (!
|
|
268
|
+
onBlockUpdated: (k) => {
|
|
269
|
+
const x = n.state.aiMenuState, g = x === "closed" ? void 0 : x;
|
|
270
|
+
if (!g || g.status !== "ai-writing")
|
|
271
271
|
return;
|
|
272
|
-
const
|
|
273
|
-
|
|
272
|
+
const v = ie(
|
|
273
|
+
k,
|
|
274
274
|
e.prosemirrorState.doc
|
|
275
275
|
);
|
|
276
|
-
|
|
276
|
+
v && (n.setState({
|
|
277
277
|
aiMenuState: {
|
|
278
|
-
blockId:
|
|
278
|
+
blockId: k,
|
|
279
279
|
status: "ai-writing"
|
|
280
280
|
}
|
|
281
|
-
}),
|
|
282
|
-
|
|
281
|
+
}), u && e.prosemirrorView.domAtPos(
|
|
282
|
+
v.posBeforeNode + 1
|
|
283
283
|
).node.scrollIntoView({
|
|
284
284
|
block: "center"
|
|
285
285
|
}));
|
|
286
286
|
},
|
|
287
287
|
onStart: () => {
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
u = !0, this.setAIResponseStatus("ai-writing"), b.emptyCursorBlockToDelete && b.editor.getBlock(b.emptyCursorBlockToDelete) && b.editor.removeBlocks([
|
|
289
|
+
b.emptyCursorBlockToDelete
|
|
290
290
|
]);
|
|
291
291
|
}
|
|
292
|
-
}),
|
|
292
|
+
}), w = await pe(
|
|
293
293
|
f,
|
|
294
|
-
|
|
294
|
+
b,
|
|
295
295
|
{
|
|
296
296
|
role: "user",
|
|
297
297
|
parts: [
|
|
@@ -304,21 +304,21 @@ const Ie = (e) => {
|
|
|
304
304
|
r.chatRequestOptions || this.options.state.chatRequestOptions,
|
|
305
305
|
i.abortController.signal
|
|
306
306
|
);
|
|
307
|
-
|
|
308
|
-
result:
|
|
307
|
+
w.ok && f.status !== "error" || d.signal.aborted ? this.setAIResponseStatus("user-reviewing") : (console.warn("Error calling LLM", {
|
|
308
|
+
result: w,
|
|
309
309
|
chatStatus: f.status,
|
|
310
310
|
chatError: f.error
|
|
311
311
|
}), this.setAIResponseStatus({
|
|
312
312
|
status: "error",
|
|
313
|
-
error:
|
|
313
|
+
error: w.ok ? f.error : w.error
|
|
314
314
|
}));
|
|
315
|
-
} catch (
|
|
315
|
+
} catch (d) {
|
|
316
316
|
this.setAIResponseStatus({
|
|
317
317
|
status: "error",
|
|
318
|
-
error:
|
|
318
|
+
error: d
|
|
319
319
|
}), console.error(
|
|
320
320
|
"Unexpected error calling LLM",
|
|
321
|
-
|
|
321
|
+
d,
|
|
322
322
|
i == null ? void 0 : i.chat.messages
|
|
323
323
|
);
|
|
324
324
|
}
|
|
@@ -326,24 +326,24 @@ const Ie = (e) => {
|
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
328
|
);
|
|
329
|
-
var
|
|
329
|
+
var X = {
|
|
330
330
|
color: void 0,
|
|
331
331
|
size: void 0,
|
|
332
332
|
className: void 0,
|
|
333
333
|
style: void 0,
|
|
334
334
|
attr: void 0
|
|
335
|
-
},
|
|
336
|
-
function
|
|
335
|
+
}, K = y.createContext && /* @__PURE__ */ y.createContext(X), Me = ["attr", "size", "title"];
|
|
336
|
+
function Le(e, t) {
|
|
337
337
|
if (e == null) return {};
|
|
338
|
-
var o =
|
|
338
|
+
var o = Pe(e, t), n, i;
|
|
339
339
|
if (Object.getOwnPropertySymbols) {
|
|
340
|
-
var
|
|
341
|
-
for (i = 0; i <
|
|
342
|
-
n =
|
|
340
|
+
var u = Object.getOwnPropertySymbols(e);
|
|
341
|
+
for (i = 0; i < u.length; i++)
|
|
342
|
+
n = u[i], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
|
|
343
343
|
}
|
|
344
344
|
return o;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Pe(e, t) {
|
|
347
347
|
if (e == null) return {};
|
|
348
348
|
var o = {};
|
|
349
349
|
for (var n in e)
|
|
@@ -353,17 +353,17 @@ function Le(e, t) {
|
|
|
353
353
|
}
|
|
354
354
|
return o;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
return
|
|
356
|
+
function T() {
|
|
357
|
+
return T = Object.assign ? Object.assign.bind() : function(e) {
|
|
358
358
|
for (var t = 1; t < arguments.length; t++) {
|
|
359
359
|
var o = arguments[t];
|
|
360
360
|
for (var n in o)
|
|
361
361
|
Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
|
|
362
362
|
}
|
|
363
363
|
return e;
|
|
364
|
-
},
|
|
364
|
+
}, T.apply(this, arguments);
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function W(e, t) {
|
|
367
367
|
var o = Object.keys(e);
|
|
368
368
|
if (Object.getOwnPropertySymbols) {
|
|
369
369
|
var n = Object.getOwnPropertySymbols(e);
|
|
@@ -373,25 +373,25 @@ function U(e, t) {
|
|
|
373
373
|
}
|
|
374
374
|
return o;
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function E(e) {
|
|
377
377
|
for (var t = 1; t < arguments.length; t++) {
|
|
378
378
|
var o = arguments[t] != null ? arguments[t] : {};
|
|
379
|
-
t % 2 ?
|
|
379
|
+
t % 2 ? W(Object(o), !0).forEach(function(n) {
|
|
380
380
|
Te(e, n, o[n]);
|
|
381
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) :
|
|
381
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) : W(Object(o)).forEach(function(n) {
|
|
382
382
|
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(o, n));
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
385
|
return e;
|
|
386
386
|
}
|
|
387
387
|
function Te(e, t, o) {
|
|
388
|
-
return t =
|
|
388
|
+
return t = Ee(t), t in e ? Object.defineProperty(e, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = o, e;
|
|
389
389
|
}
|
|
390
|
-
function
|
|
391
|
-
var t =
|
|
390
|
+
function Ee(e) {
|
|
391
|
+
var t = Ae(e, "string");
|
|
392
392
|
return typeof t == "symbol" ? t : t + "";
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function Ae(e, t) {
|
|
395
395
|
if (typeof e != "object" || !e) return e;
|
|
396
396
|
var o = e[Symbol.toPrimitive];
|
|
397
397
|
if (o !== void 0) {
|
|
@@ -401,52 +401,52 @@ function Ee(e, t) {
|
|
|
401
401
|
}
|
|
402
402
|
return (t === "string" ? String : Number)(e);
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
return e && e.map((t, o) => /* @__PURE__ */
|
|
404
|
+
function ee(e) {
|
|
405
|
+
return e && e.map((t, o) => /* @__PURE__ */ y.createElement(t.tag, E({
|
|
406
406
|
key: o
|
|
407
|
-
}, t.attr),
|
|
407
|
+
}, t.attr), ee(t.child)));
|
|
408
408
|
}
|
|
409
409
|
function h(e) {
|
|
410
|
-
return (t) => /* @__PURE__ */
|
|
411
|
-
attr:
|
|
412
|
-
}, t),
|
|
410
|
+
return (t) => /* @__PURE__ */ y.createElement(Oe, T({
|
|
411
|
+
attr: E({}, e.attr)
|
|
412
|
+
}, t), ee(e.child));
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Oe(e) {
|
|
415
415
|
var t = (o) => {
|
|
416
416
|
var {
|
|
417
417
|
attr: n,
|
|
418
418
|
size: i,
|
|
419
|
-
title:
|
|
420
|
-
} = e,
|
|
421
|
-
return o.className && (a = o.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */
|
|
419
|
+
title: u
|
|
420
|
+
} = e, p = Le(e, Me), r = i || o.size || "1em", a;
|
|
421
|
+
return o.className && (a = o.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ y.createElement("svg", T({
|
|
422
422
|
stroke: "currentColor",
|
|
423
423
|
fill: "currentColor",
|
|
424
424
|
strokeWidth: "0"
|
|
425
|
-
}, o.attr, n,
|
|
425
|
+
}, o.attr, n, p, {
|
|
426
426
|
className: a,
|
|
427
|
-
style:
|
|
427
|
+
style: E(E({
|
|
428
428
|
color: e.color || o.color
|
|
429
429
|
}, o.style), e.style),
|
|
430
430
|
height: r,
|
|
431
431
|
width: r,
|
|
432
432
|
xmlns: "http://www.w3.org/2000/svg"
|
|
433
|
-
}),
|
|
433
|
+
}), u && /* @__PURE__ */ y.createElement("title", null, u), e.children);
|
|
434
434
|
};
|
|
435
|
-
return
|
|
435
|
+
return K !== void 0 ? /* @__PURE__ */ y.createElement(K.Consumer, null, (o) => t(o)) : t(X);
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function te(e) {
|
|
438
438
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z" }, child: [] }] })(e);
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function G(e) {
|
|
441
441
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.8492 11.6983L17.1421 10.9912L7.24264 20.8907H3V16.648L14.3137 5.33432L19.9706 10.9912C20.3611 11.3817 20.3611 12.0149 19.9706 12.4054L12.8995 19.4765L11.4853 18.0622L17.8492 11.6983ZM15.7279 9.57696L14.3137 8.16274L5 17.4765V18.8907H6.41421L15.7279 9.57696ZM18.5563 2.50589L21.3848 5.33432C21.7753 5.72484 21.7753 6.35801 21.3848 6.74853L19.9706 8.16274L15.7279 3.9201L17.1421 2.50589C17.5327 2.11537 18.1658 2.11537 18.5563 2.50589Z" }, child: [] }] })(e);
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Be(e) {
|
|
444
444
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15.1986 9.94447C14.7649 9.5337 14.4859 8.98613 14.4085 8.39384L14.0056 5.31138L11.275 6.79724C10.7503 7.08274 10.1433 7.17888 9.55608 7.06948L6.49998 6.50015L7.06931 9.55625C7.17871 10.1435 7.08257 10.7505 6.79707 11.2751L5.31121 14.0057L8.39367 14.4086C8.98596 14.4861 9.53353 14.7651 9.94431 15.1987L12.0821 17.4557L13.4178 14.6486C13.6745 14.1092 14.109 13.6747 14.6484 13.418L17.4555 12.0823L15.1986 9.94447ZM15.2238 15.5079L13.0111 20.1581C12.8687 20.4573 12.5107 20.5844 12.2115 20.442C12.1448 20.4103 12.0845 20.3665 12.0337 20.3129L8.49229 16.5741C8.39749 16.474 8.27113 16.4096 8.13445 16.3918L3.02816 15.7243C2.69958 15.6814 2.46804 15.3802 2.51099 15.0516C2.52056 14.9784 2.54359 14.9075 2.5789 14.8426L5.04031 10.3192C5.1062 10.1981 5.12839 10.058 5.10314 9.92253L4.16 4.85991C4.09931 4.53414 4.3142 4.22086 4.63997 4.16017C4.7126 4.14664 4.78711 4.14664 4.85974 4.16017L9.92237 5.10331C10.0579 5.12855 10.198 5.10637 10.319 5.04048L14.8424 2.57907C15.1335 2.42068 15.4979 2.52825 15.6562 2.81931C15.6916 2.88421 15.7146 2.95507 15.7241 3.02833L16.3916 8.13462C16.4095 8.2713 16.4739 8.39766 16.5739 8.49245L20.3127 12.0338C20.5533 12.2617 20.5636 12.6415 20.3357 12.8821C20.2849 12.9357 20.2246 12.9795 20.1579 13.0112L15.5078 15.224C15.3833 15.2832 15.283 15.3835 15.2238 15.5079ZM16.0206 17.435L17.4348 16.0208L21.6775 20.2634L20.2633 21.6776L16.0206 17.435Z" }, child: [] }] })(e);
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function ze(e) {
|
|
447
447
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" }, child: [] }] })(e);
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function Re(e) {
|
|
450
450
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" }, child: [] }] })(e);
|
|
451
451
|
}
|
|
452
452
|
function Ve(e) {
|
|
@@ -455,97 +455,101 @@ function Ve(e) {
|
|
|
455
455
|
function He(e) {
|
|
456
456
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M6.23509 6.45329C4.85101 7.89148 4 9.84636 4 12C4 16.4183 7.58172 20 12 20C13.0808 20 14.1116 19.7857 15.0521 19.3972C15.1671 18.6467 14.9148 17.9266 14.8116 17.6746C14.582 17.115 13.8241 16.1582 12.5589 14.8308C12.2212 14.4758 12.2429 14.2035 12.3636 13.3943L12.3775 13.3029C12.4595 12.7486 12.5971 12.4209 14.4622 12.1248C15.4097 11.9746 15.6589 12.3533 16.0043 12.8777C16.0425 12.9358 16.0807 12.9928 16.1198 13.0499C16.4479 13.5297 16.691 13.6394 17.0582 13.8064C17.2227 13.881 17.428 13.9751 17.7031 14.1314C18.3551 14.504 18.3551 14.9247 18.3551 15.8472V15.9518C18.3551 16.3434 18.3168 16.6872 18.2566 16.9859C19.3478 15.6185 20 13.8854 20 12C20 8.70089 18.003 5.8682 15.1519 4.64482C14.5987 5.01813 13.8398 5.54726 13.575 5.91C13.4396 6.09538 13.2482 7.04166 12.6257 7.11976C12.4626 7.14023 12.2438 7.12589 12.012 7.11097C11.3905 7.07058 10.5402 7.01606 10.268 7.75495C10.0952 8.2232 10.0648 9.49445 10.6239 10.1543C10.7134 10.2597 10.7307 10.4547 10.6699 10.6735C10.59 10.9608 10.4286 11.1356 10.3783 11.1717C10.2819 11.1163 10.0896 10.8931 9.95938 10.7412C9.64554 10.3765 9.25405 9.92233 8.74797 9.78176C8.56395 9.73083 8.36166 9.68867 8.16548 9.64736C7.6164 9.53227 6.99443 9.40134 6.84992 9.09302C6.74442 8.8672 6.74488 8.55621 6.74529 8.22764C6.74529 7.8112 6.74529 7.34029 6.54129 6.88256C6.46246 6.70541 6.35689 6.56446 6.23509 6.45329ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22Z" }, child: [] }] })(e);
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function je(e) {
|
|
459
459
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function De(e) {
|
|
462
462
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
|
|
463
463
|
}
|
|
464
464
|
function qe(e) {
|
|
465
465
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M12 4C9.4095 4 7.10606 5.23053 5.64274 7.14274L8 9.5H2V3.5L4.21863 5.71863C6.05061 3.452 8.85558 2 12 2 17.5228 2 22 6.47715 22 12H20C20 7.58172 16.4183 4 12 4ZM4 12C4 16.4183 7.58172 20 12 20 14.5905 20 16.894 18.7695 18.3573 16.8573L16 14.5 22 14.5V20.5L19.7814 18.2814C17.9494 20.548 15.1444 22 12 22 6.47715 22 2 17.5228 2 12H4Z" }, child: [] }] })(e);
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function V(e) {
|
|
468
468
|
return h({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.0007 1.20825 18.3195 3.68108 20.7923 4.99992 18.3195 6.31876 17.0007 8.79159 15.6818 6.31876 13.209 4.99992 15.6818 3.68108 17.0007 1.20825ZM8.00065 4.33325 10.6673 9.33325 15.6673 11.9999 10.6673 14.6666 8.00065 19.6666 5.33398 14.6666.333984 11.9999 5.33398 9.33325 8.00065 4.33325ZM19.6673 16.3333 18.0007 13.2083 16.334 16.3333 13.209 17.9999 16.334 19.6666 18.0007 22.7916 19.6673 19.6666 22.7923 17.9999 19.6673 16.3333Z" }, child: [] }] })(e);
|
|
469
469
|
}
|
|
470
|
-
function
|
|
471
|
-
const e =
|
|
472
|
-
return
|
|
470
|
+
function ne() {
|
|
471
|
+
const e = Ce();
|
|
472
|
+
return _(e.editor);
|
|
473
473
|
}
|
|
474
474
|
const Ze = (e) => {
|
|
475
|
-
const t =
|
|
476
|
-
async (
|
|
477
|
-
|
|
475
|
+
const t = z(), { onManualPromptSubmit: o, promptText: n, onPromptTextChange: i, disabled: u } = e, [p, r] = Q(""), a = n || p, s = L(
|
|
476
|
+
async (g) => {
|
|
477
|
+
g.key === "Enter" && !g.nativeEvent.isComposing && o(a);
|
|
478
478
|
},
|
|
479
|
-
[
|
|
480
|
-
),
|
|
481
|
-
(
|
|
482
|
-
const
|
|
483
|
-
i && i(
|
|
479
|
+
[a, o]
|
|
480
|
+
), m = L(
|
|
481
|
+
(g) => {
|
|
482
|
+
const v = g.currentTarget.value;
|
|
483
|
+
i && i(v), n === void 0 && r(v);
|
|
484
484
|
},
|
|
485
|
-
[i,
|
|
486
|
-
),
|
|
487
|
-
(
|
|
488
|
-
|
|
485
|
+
[i, r, n]
|
|
486
|
+
), l = M(() => le(e.items, a), [a, e.items]), { selectedIndex: d, setSelectedIndex: f, handler: S } = be(l, (g) => g.onItemClick()), b = l.length > 0 && d >= 0 && d < l.length ? `bn-suggestion-menu-item-${d}` : void 0, w = L(
|
|
487
|
+
(g) => {
|
|
488
|
+
g.key === "Enter" && !g.nativeEvent.isComposing ? l.length > 0 ? S(g) : s(g) : S(g);
|
|
489
489
|
},
|
|
490
|
-
[
|
|
490
|
+
[s, S, l.length]
|
|
491
491
|
);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}, [
|
|
492
|
+
B(() => {
|
|
493
|
+
f(0);
|
|
494
|
+
}, [a, f]);
|
|
495
|
+
const k = F(null), x = F(u);
|
|
496
|
+
return B(() => {
|
|
497
|
+
k.current && x.current && !u && k.current.focus(), u && (x.current = !0);
|
|
498
|
+
}, [u]), /* @__PURE__ */ he("div", { className: "bn-combobox", children: [
|
|
495
499
|
/* @__PURE__ */ c(t.Generic.Form.Root, { children: /* @__PURE__ */ c(
|
|
496
500
|
t.Generic.Form.TextInput,
|
|
497
501
|
{
|
|
502
|
+
ref: k,
|
|
498
503
|
className: "bn-combobox-input",
|
|
499
504
|
name: "ai-prompt",
|
|
500
505
|
variant: "large",
|
|
501
506
|
icon: e.icon,
|
|
502
|
-
value:
|
|
503
|
-
autoFocus: !0,
|
|
507
|
+
value: a || "",
|
|
504
508
|
placeholder: e.placeholder,
|
|
505
509
|
disabled: e.disabled,
|
|
506
510
|
onKeyDown: w,
|
|
507
|
-
onChange:
|
|
511
|
+
onChange: m,
|
|
508
512
|
autoComplete: "off",
|
|
509
|
-
rightSection: e.rightSection
|
|
510
|
-
|
|
511
|
-
|
|
513
|
+
rightSection: e.rightSection,
|
|
514
|
+
"aria-activedescendant": b
|
|
515
|
+
}
|
|
512
516
|
) }),
|
|
513
|
-
|
|
517
|
+
l.length > 0 && /* @__PURE__ */ c(
|
|
514
518
|
t.SuggestionMenu.Root,
|
|
515
519
|
{
|
|
516
520
|
className: "bn-combobox-items",
|
|
517
521
|
id: "ai-suggestion-menu",
|
|
518
|
-
children:
|
|
522
|
+
children: l.map((g, v) => /* @__PURE__ */ c(
|
|
519
523
|
t.SuggestionMenu.Item,
|
|
520
524
|
{
|
|
521
|
-
className:
|
|
525
|
+
className: se(
|
|
522
526
|
"bn-suggestion-menu-item",
|
|
523
|
-
|
|
527
|
+
g.size === "small" ? "bn-suggestion-menu-item-small" : ""
|
|
524
528
|
),
|
|
525
|
-
id: `bn-suggestion-menu-item-${
|
|
526
|
-
isSelected:
|
|
527
|
-
onClick:
|
|
528
|
-
item:
|
|
529
|
+
id: `bn-suggestion-menu-item-${v}`,
|
|
530
|
+
isSelected: v === d,
|
|
531
|
+
onClick: g.onItemClick,
|
|
532
|
+
item: g
|
|
529
533
|
},
|
|
530
|
-
|
|
534
|
+
g.title
|
|
531
535
|
))
|
|
532
536
|
}
|
|
533
537
|
)
|
|
534
538
|
] });
|
|
535
539
|
};
|
|
536
|
-
function
|
|
537
|
-
const t =
|
|
540
|
+
function Ne(e) {
|
|
541
|
+
const t = _(e), o = e.getExtension(C);
|
|
538
542
|
return o ? [
|
|
539
543
|
{
|
|
540
544
|
key: "continue_writing",
|
|
541
545
|
title: t.ai_default_commands.continue_writing.title,
|
|
542
546
|
aliases: t.ai_default_commands.continue_writing.aliases,
|
|
543
|
-
icon: /* @__PURE__ */ c(
|
|
547
|
+
icon: /* @__PURE__ */ c(G, { size: 18 }),
|
|
544
548
|
onItemClick: async () => {
|
|
545
549
|
await o.invokeAI({
|
|
546
550
|
userPrompt: "Continue writing at the current cursor position related to the previous text. Add multiple blocks if needed. If the document looks like a template / draft, follow the template. Be extensive if needed.",
|
|
547
551
|
// By default, LLM will be able to add / update / delete blocks. For "continue writing", we only want to allow adding new blocks.
|
|
548
|
-
streamToolsProvider:
|
|
552
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
549
553
|
defaultStreamTools: {
|
|
550
554
|
add: !0,
|
|
551
555
|
delete: !1,
|
|
@@ -560,12 +564,12 @@ function De(e) {
|
|
|
560
564
|
key: "summarize",
|
|
561
565
|
title: t.ai_default_commands.summarize.title,
|
|
562
566
|
aliases: t.ai_default_commands.summarize.aliases,
|
|
563
|
-
icon: /* @__PURE__ */ c(
|
|
567
|
+
icon: /* @__PURE__ */ c(Re, { size: 18 }),
|
|
564
568
|
onItemClick: async () => {
|
|
565
569
|
await o.invokeAI({
|
|
566
570
|
userPrompt: "Summarize",
|
|
567
571
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
568
|
-
streamToolsProvider:
|
|
572
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
569
573
|
defaultStreamTools: {
|
|
570
574
|
add: !0,
|
|
571
575
|
delete: !1,
|
|
@@ -580,12 +584,12 @@ function De(e) {
|
|
|
580
584
|
key: "action_items",
|
|
581
585
|
title: t.ai_default_commands.add_action_items.title,
|
|
582
586
|
aliases: t.ai_default_commands.add_action_items.aliases,
|
|
583
|
-
icon: /* @__PURE__ */ c(
|
|
587
|
+
icon: /* @__PURE__ */ c(ze, { size: 18 }),
|
|
584
588
|
onItemClick: async () => {
|
|
585
589
|
await o.invokeAI({
|
|
586
590
|
userPrompt: "Add action items",
|
|
587
591
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
588
|
-
streamToolsProvider:
|
|
592
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
589
593
|
defaultStreamTools: {
|
|
590
594
|
add: !0,
|
|
591
595
|
delete: !1,
|
|
@@ -600,7 +604,7 @@ function De(e) {
|
|
|
600
604
|
key: "write_anything",
|
|
601
605
|
title: t.ai_default_commands.write_anything.title,
|
|
602
606
|
aliases: t.ai_default_commands.write_anything.aliases,
|
|
603
|
-
icon: /* @__PURE__ */ c(
|
|
607
|
+
icon: /* @__PURE__ */ c(G, { size: 18 }),
|
|
604
608
|
onItemClick: (n) => {
|
|
605
609
|
n(t.ai_default_commands.write_anything.prompt_placeholder);
|
|
606
610
|
},
|
|
@@ -608,8 +612,8 @@ function De(e) {
|
|
|
608
612
|
}
|
|
609
613
|
] : [];
|
|
610
614
|
}
|
|
611
|
-
function
|
|
612
|
-
const t =
|
|
615
|
+
function Fe(e) {
|
|
616
|
+
const t = _(e), o = e.getExtension(C);
|
|
613
617
|
return o ? [
|
|
614
618
|
{
|
|
615
619
|
key: "improve_writing",
|
|
@@ -621,7 +625,7 @@ function Ne(e) {
|
|
|
621
625
|
useSelection: !0,
|
|
622
626
|
userPrompt: "Improve writing",
|
|
623
627
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
624
|
-
streamToolsProvider:
|
|
628
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
625
629
|
defaultStreamTools: {
|
|
626
630
|
add: !1,
|
|
627
631
|
delete: !1,
|
|
@@ -636,13 +640,13 @@ function Ne(e) {
|
|
|
636
640
|
key: "fix_spelling",
|
|
637
641
|
title: t.ai_default_commands.fix_spelling.title,
|
|
638
642
|
aliases: t.ai_default_commands.fix_spelling.aliases,
|
|
639
|
-
icon: /* @__PURE__ */ c(
|
|
643
|
+
icon: /* @__PURE__ */ c(De, { size: 18 }),
|
|
640
644
|
onItemClick: async () => {
|
|
641
645
|
await o.invokeAI({
|
|
642
646
|
useSelection: !0,
|
|
643
647
|
userPrompt: "Fix spelling",
|
|
644
648
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
645
|
-
streamToolsProvider:
|
|
649
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
646
650
|
defaultStreamTools: {
|
|
647
651
|
add: !1,
|
|
648
652
|
delete: !1,
|
|
@@ -667,13 +671,13 @@ function Ne(e) {
|
|
|
667
671
|
key: "simplify",
|
|
668
672
|
title: t.ai_default_commands.simplify.title,
|
|
669
673
|
aliases: t.ai_default_commands.simplify.aliases,
|
|
670
|
-
icon: /* @__PURE__ */ c(
|
|
674
|
+
icon: /* @__PURE__ */ c(Be, { size: 18 }),
|
|
671
675
|
onItemClick: async () => {
|
|
672
676
|
await o.invokeAI({
|
|
673
677
|
useSelection: !0,
|
|
674
678
|
userPrompt: "Simplify",
|
|
675
679
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
676
|
-
streamToolsProvider:
|
|
680
|
+
streamToolsProvider: I.html.getStreamToolsProvider({
|
|
677
681
|
defaultStreamTools: {
|
|
678
682
|
add: !1,
|
|
679
683
|
delete: !1,
|
|
@@ -686,14 +690,14 @@ function Ne(e) {
|
|
|
686
690
|
}
|
|
687
691
|
] : [];
|
|
688
692
|
}
|
|
689
|
-
function
|
|
690
|
-
const t =
|
|
693
|
+
function Ue(e) {
|
|
694
|
+
const t = _(e), o = e.getExtension(C);
|
|
691
695
|
return o ? [
|
|
692
696
|
{
|
|
693
697
|
key: "accept",
|
|
694
698
|
title: t.ai_menu.actions.accept.title,
|
|
695
699
|
aliases: t.ai_menu.actions.accept.aliases,
|
|
696
|
-
icon: /* @__PURE__ */ c(
|
|
700
|
+
icon: /* @__PURE__ */ c(je, { size: 18 }),
|
|
697
701
|
onItemClick: () => {
|
|
698
702
|
o.acceptChanges();
|
|
699
703
|
},
|
|
@@ -703,7 +707,7 @@ function Fe(e) {
|
|
|
703
707
|
key: "revert",
|
|
704
708
|
title: t.ai_menu.actions.revert.title,
|
|
705
709
|
aliases: t.ai_menu.actions.revert.aliases,
|
|
706
|
-
icon: /* @__PURE__ */ c(
|
|
710
|
+
icon: /* @__PURE__ */ c(te, { size: 18 }),
|
|
707
711
|
onItemClick: () => {
|
|
708
712
|
o.rejectChanges();
|
|
709
713
|
},
|
|
@@ -711,8 +715,8 @@ function Fe(e) {
|
|
|
711
715
|
}
|
|
712
716
|
] : [];
|
|
713
717
|
}
|
|
714
|
-
function
|
|
715
|
-
const t =
|
|
718
|
+
function Ke(e) {
|
|
719
|
+
const t = _(e), o = e.getExtension(C);
|
|
716
720
|
return o ? [
|
|
717
721
|
{
|
|
718
722
|
key: "retry",
|
|
@@ -728,7 +732,7 @@ function Ue(e) {
|
|
|
728
732
|
key: "cancel",
|
|
729
733
|
title: t.ai_menu.actions.cancel.title,
|
|
730
734
|
aliases: t.ai_menu.actions.cancel.aliases,
|
|
731
|
-
icon: /* @__PURE__ */ c(
|
|
735
|
+
icon: /* @__PURE__ */ c(te, { size: 18 }),
|
|
732
736
|
onItemClick: () => {
|
|
733
737
|
o.rejectChanges();
|
|
734
738
|
},
|
|
@@ -736,36 +740,36 @@ function Ue(e) {
|
|
|
736
740
|
}
|
|
737
741
|
] : [];
|
|
738
742
|
}
|
|
739
|
-
function
|
|
740
|
-
return t === "user-input" ? e.getSelection() ?
|
|
743
|
+
function We(e, t) {
|
|
744
|
+
return t === "user-input" ? e.getSelection() ? Fe(e) : Ne(e) : t === "user-reviewing" ? Ue(e) : t === "error" ? Ke(e) : [];
|
|
741
745
|
}
|
|
742
|
-
const
|
|
743
|
-
const t =
|
|
746
|
+
const Ge = (e) => {
|
|
747
|
+
const t = R(), [o, n] = Q(""), i = ne(), u = z(), p = P(C), r = J(C, {
|
|
744
748
|
selector: (f) => f.aiMenuState !== "closed" ? f.aiMenuState.status : "closed"
|
|
745
|
-
}), { items: a } = e,
|
|
749
|
+
}), { items: a } = e, s = M(() => {
|
|
746
750
|
let f = [];
|
|
747
|
-
return a ? f = a(t, r) : f =
|
|
748
|
-
...
|
|
751
|
+
return a ? f = a(t, r) : f = We(t, r), f.map((S) => ({
|
|
752
|
+
...S,
|
|
749
753
|
onItemClick: () => {
|
|
750
|
-
|
|
754
|
+
S.onItemClick(n);
|
|
751
755
|
}
|
|
752
756
|
}));
|
|
753
|
-
}, [a, r, t]),
|
|
757
|
+
}, [a, r, t]), m = L(
|
|
754
758
|
async (f) => {
|
|
755
|
-
await
|
|
759
|
+
await p.invokeAI({
|
|
756
760
|
userPrompt: f,
|
|
757
761
|
useSelection: t.getSelection() !== void 0
|
|
758
762
|
});
|
|
759
763
|
},
|
|
760
|
-
[
|
|
764
|
+
[p, t]
|
|
761
765
|
);
|
|
762
|
-
|
|
766
|
+
B(() => {
|
|
763
767
|
(r === "ai-writing" || r === "user-reviewing" || r === "error") && n("");
|
|
764
768
|
}, [r]);
|
|
765
|
-
const
|
|
769
|
+
const l = M(() => r === "thinking" ? i.ai_menu.status.thinking : r === "ai-writing" ? i.ai_menu.status.editing : r === "error" ? i.ai_menu.status.error : i.ai_menu.input_placeholder, [r, i]), d = M(() => {
|
|
766
770
|
if (r === "thinking" || r === "ai-writing")
|
|
767
771
|
return /* @__PURE__ */ c(
|
|
768
|
-
|
|
772
|
+
u.SuggestionMenu.Loader,
|
|
769
773
|
{
|
|
770
774
|
className: "bn-suggestion-menu-loader bn-combobox-right-section"
|
|
771
775
|
}
|
|
@@ -782,48 +786,48 @@ const We = (e) => {
|
|
|
782
786
|
children: /* @__PURE__ */ c("path", { d: "M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm0-160q17 0 28.5-11.5T520-480v-160q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640v160q0 17 11.5 28.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" })
|
|
783
787
|
}
|
|
784
788
|
) });
|
|
785
|
-
}, [
|
|
789
|
+
}, [u, r]);
|
|
786
790
|
return /* @__PURE__ */ c(
|
|
787
791
|
Ze,
|
|
788
792
|
{
|
|
789
|
-
onManualPromptSubmit: e.onManualPromptSubmit ||
|
|
790
|
-
items:
|
|
793
|
+
onManualPromptSubmit: e.onManualPromptSubmit || m,
|
|
794
|
+
items: s,
|
|
791
795
|
promptText: o,
|
|
792
796
|
onPromptTextChange: n,
|
|
793
|
-
placeholder:
|
|
797
|
+
placeholder: l,
|
|
794
798
|
disabled: r === "thinking" || r === "ai-writing",
|
|
795
|
-
icon: /* @__PURE__ */ c("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ c(
|
|
796
|
-
rightSection:
|
|
799
|
+
icon: /* @__PURE__ */ c("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ c(V, {}) }),
|
|
800
|
+
rightSection: d
|
|
797
801
|
}
|
|
798
802
|
);
|
|
799
|
-
},
|
|
800
|
-
const t =
|
|
803
|
+
}, mt = (e) => {
|
|
804
|
+
const t = R(), o = P(C), n = J(C, {
|
|
801
805
|
editor: t,
|
|
802
806
|
selector: (r) => r.aiMenuState
|
|
803
|
-
}), i = n === "closed" ? void 0 : n.blockId,
|
|
807
|
+
}), i = n === "closed" ? void 0 : n.blockId, u = M(
|
|
804
808
|
() => {
|
|
805
|
-
var r, a,
|
|
809
|
+
var r, a, s, m;
|
|
806
810
|
return {
|
|
807
811
|
...e.floatingUIOptions,
|
|
808
812
|
useFloatingOptions: {
|
|
809
813
|
open: n !== "closed",
|
|
810
814
|
placement: "bottom",
|
|
811
815
|
middleware: [
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
apply({ rects:
|
|
816
|
-
Object.assign(
|
|
817
|
-
width: `${
|
|
816
|
+
Se(10),
|
|
817
|
+
ye(),
|
|
818
|
+
we({
|
|
819
|
+
apply({ rects: l, elements: d }) {
|
|
820
|
+
Object.assign(d.floating.style, {
|
|
821
|
+
width: `${l.reference.width}px`
|
|
818
822
|
});
|
|
819
823
|
}
|
|
820
824
|
})
|
|
821
825
|
],
|
|
822
|
-
onOpenChange: (
|
|
823
|
-
|
|
826
|
+
onOpenChange: (l) => {
|
|
827
|
+
l || n === "closed" || (n.status === "user-input" ? o.closeAIMenu() : (n.status === "user-reviewing" || n.status === "error") && o.rejectChanges());
|
|
824
828
|
},
|
|
825
|
-
whileElementsMounted(
|
|
826
|
-
return
|
|
829
|
+
whileElementsMounted(l, d, f) {
|
|
830
|
+
return ke(l, d, f, {
|
|
827
831
|
animationFrame: !0
|
|
828
832
|
});
|
|
829
833
|
},
|
|
@@ -834,10 +838,10 @@ const We = (e) => {
|
|
|
834
838
|
// We should just be able to set `referencePress: true` instead of
|
|
835
839
|
// using this listener, but this doesn't seem to trigger.
|
|
836
840
|
// (probably because we don't assign the referenceProps to the reference element)
|
|
837
|
-
outsidePress: (
|
|
838
|
-
if (
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
+
outsidePress: (l) => {
|
|
842
|
+
if (l.target instanceof Element) {
|
|
843
|
+
const d = l.target.closest(".bn-block");
|
|
844
|
+
d && d.getAttribute("data-id") === i && o.closeAIMenu();
|
|
841
845
|
}
|
|
842
846
|
return !0;
|
|
843
847
|
},
|
|
@@ -847,19 +851,25 @@ const We = (e) => {
|
|
|
847
851
|
style: {
|
|
848
852
|
zIndex: 100
|
|
849
853
|
},
|
|
850
|
-
...(
|
|
854
|
+
...(s = e.floatingUIOptions) == null ? void 0 : s.elementProps
|
|
855
|
+
},
|
|
856
|
+
// we use the focus manager instead of `autoFocus={true}` to prevent "page-scrolls-to-top-when-opening-the-floating-element"
|
|
857
|
+
// see https://floating-ui.com/docs/floatingfocusmanager#page-scrolls-to-top-when-opening-the-floating-element
|
|
858
|
+
focusManagerProps: {
|
|
859
|
+
disabled: !1,
|
|
860
|
+
...(m = e.floatingUIOptions) == null ? void 0 : m.focusManagerProps
|
|
851
861
|
}
|
|
852
862
|
};
|
|
853
863
|
},
|
|
854
864
|
[o, n, i, e.floatingUIOptions]
|
|
855
|
-
),
|
|
856
|
-
return /* @__PURE__ */ c(
|
|
857
|
-
},
|
|
858
|
-
const e =
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
865
|
+
), p = e.aiMenu || Ge;
|
|
866
|
+
return /* @__PURE__ */ c(ve, { blockId: i, ...u, children: n !== "closed" && /* @__PURE__ */ c(p, {}) });
|
|
867
|
+
}, dt = () => {
|
|
868
|
+
const e = ne(), t = z(), o = R(), n = P(C), i = P(ce), u = () => {
|
|
869
|
+
const p = o.getSelection();
|
|
870
|
+
if (!p)
|
|
861
871
|
throw new Error("No selection");
|
|
862
|
-
const r =
|
|
872
|
+
const r = p.blocks[p.blocks.length - 1].id;
|
|
863
873
|
n.openAIMenuAtBlock(r), i.store.setState(!1);
|
|
864
874
|
};
|
|
865
875
|
return o.isEditable ? /* @__PURE__ */ c(
|
|
@@ -868,15 +878,15 @@ const We = (e) => {
|
|
|
868
878
|
className: "bn-button",
|
|
869
879
|
label: e.formatting_toolbar.ai.tooltip,
|
|
870
880
|
mainTooltip: e.formatting_toolbar.ai.tooltip,
|
|
871
|
-
icon: /* @__PURE__ */ c(
|
|
872
|
-
onClick:
|
|
881
|
+
icon: /* @__PURE__ */ c(V, {}),
|
|
882
|
+
onClick: u
|
|
873
883
|
}
|
|
874
884
|
) : null;
|
|
875
|
-
},
|
|
876
|
-
AI:
|
|
885
|
+
}, $e = {
|
|
886
|
+
AI: V
|
|
877
887
|
};
|
|
878
|
-
function
|
|
879
|
-
const t = e.getExtension(
|
|
888
|
+
function ft(e) {
|
|
889
|
+
const t = e.getExtension(C);
|
|
880
890
|
return t ? [
|
|
881
891
|
{
|
|
882
892
|
key: "ai",
|
|
@@ -885,38 +895,38 @@ function dt(e) {
|
|
|
885
895
|
n.block.content && Array.isArray(n.block.content) && // isarray check not ideal
|
|
886
896
|
n.block.content.length === 0 && n.prevBlock ? t.openAIMenuAtBlock(n.prevBlock.id) : t.openAIMenuAtBlock(n.block.id);
|
|
887
897
|
},
|
|
888
|
-
...
|
|
889
|
-
icon: /* @__PURE__ */ c(
|
|
898
|
+
..._(e).slash_menu.ai,
|
|
899
|
+
icon: /* @__PURE__ */ c($e.AI, {})
|
|
890
900
|
}
|
|
891
901
|
] : [];
|
|
892
902
|
}
|
|
893
903
|
export {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
904
|
+
C as AIExtension,
|
|
905
|
+
Ge as AIMenu,
|
|
906
|
+
mt as AIMenuController,
|
|
907
|
+
dt as AIToolbarButton,
|
|
908
|
+
ht as ClientSideTransport,
|
|
909
|
+
Ct as PROVIDER_OVERRIDES,
|
|
900
910
|
Ze as PromptSuggestionMenu,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
911
|
+
bt as StreamToolExecutor,
|
|
912
|
+
vt as _getApplySuggestionsTr,
|
|
913
|
+
I as aiDocumentFormats,
|
|
914
|
+
ge as buildAIRequest,
|
|
915
|
+
St as createStreamToolsArraySchema,
|
|
916
|
+
yt as fetchViaProxy,
|
|
917
|
+
_ as getAIDictionary,
|
|
918
|
+
ft as getAISlashMenuItems,
|
|
919
|
+
We as getDefaultAIMenuItems,
|
|
920
|
+
wt as getProviderOverrides,
|
|
921
|
+
kt as injectDocumentStateMessages,
|
|
922
|
+
It as makeDocumentStateBuilder,
|
|
923
|
+
_t as objectStreamToOperationsResult,
|
|
924
|
+
xt as promptHelpers,
|
|
925
|
+
pe as sendMessageWithAIRequest,
|
|
926
|
+
Mt as setupToolCallStreaming,
|
|
927
|
+
Lt as streamToolsToToolSet,
|
|
928
|
+
Pt as toolDefinitionsToToolSet,
|
|
919
929
|
Tt as toolSetToToolDefinitions,
|
|
920
|
-
|
|
930
|
+
ne as useAIDictionary
|
|
921
931
|
};
|
|
922
932
|
//# sourceMappingURL=blocknote-xl-ai.js.map
|