@blocknote/xl-ai 0.46.2 → 0.47.1

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.
@@ -1,22 +1,22 @@
1
- import { Chat as ne } from "@ai-sdk/react";
2
- import { createExtension as oe, createStore as H, getNodeById as re, UnreachableCaseError as ie, mergeCSSClasses as ae } from "@blocknote/core";
3
- import { ForkYDocExtension as L, ShowSelectionExtension as T, filterSuggestionItems as se, FormattingToolbarExtension as le } from "@blocknote/core/extensions";
4
- import { suggestChanges as ce, revertSuggestions as R, applySuggestions as ue } from "@handlewithcare/prosemirror-suggest-changes";
5
- import { Slice as j, Fragment as q } from "prosemirror-model";
6
- import { Plugin as W, PluginKey as G } from "prosemirror-state";
7
- import { fixTablesKey as me } from "prosemirror-tables";
8
- import { DecorationSet as Z, Decoration as D } from "prosemirror-view";
9
- import { defaultSelectionBuilder as de } from "y-prosemirror";
10
- import { b as fe, s as ge, c as y, a as S } from "./client-De9NkxJ-.js";
11
- import { C as pt, P as ht, S as Ct, g as bt, d as vt, f as St, h as yt, j as wt, m as kt, o as It, p as _t, i as xt, e as Mt, k as Lt, t as Tt } from "./client-De9NkxJ-.js";
12
- import { jsxs as pe, jsx as c } from "react/jsx-runtime";
13
- import { useBlockNoteContext as he, useComponentsContext as P, useSuggestionMenuKeyboardHandler as Ce, useBlockNoteEditor as E, useExtension as _, useExtensionState as $, BlockPopover as be } from "@blocknote/react";
14
- import v, { useState as Y, useCallback as I, useMemo as k, useEffect as J } from "react";
15
- import { offset as ve, flip as Se, size as ye, autoUpdate as we } from "@floating-ui/react";
16
- const N = new G("blocknote-agent-cursor");
17
- function ke(e) {
18
- return new W({
19
- key: N,
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 } = N.getState(t), i = [];
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
- D.widget(n.head, () => Ie(e), {
40
+ N.widget(n.head, () => _e(e), {
41
41
  key: "agent-cursor",
42
42
  side: 10
43
43
  })
44
44
  );
45
- const d = Math.min(n.anchor, n.head), g = Math.max(n.anchor, n.head);
45
+ const u = Math.min(n.anchor, n.head), p = Math.max(n.anchor, n.head);
46
46
  return i.push(
47
- D.inline(d, g, de(e), {
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 Ie = (e) => {
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
- }, _e = new G("blocknote-ai-plugin"), b = oe(
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, d = !1;
72
- const g = ce();
73
- return g.props.decorations = void 0, {
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 && (d = !1), a = !0;
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 W({
101
- key: _e,
100
+ new $({
101
+ key: xe,
102
102
  filterTransaction: (r) => {
103
- var l;
103
+ var s;
104
104
  const a = n.state.aiMenuState;
105
- return !(a !== "closed" && a.status === "ai-writing" && (l = r.getMeta(me)) != null && l.fixTables);
105
+ return !(a !== "closed" && a.status === "ai-writing" && (s = r.getMeta(de)) != null && s.fixTables);
106
106
  }
107
107
  }),
108
- g,
109
- ke(
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 l, s;
118
- (l = e.getExtension(T)) == null || l.showSelection(!0, "aiMenu"), e.isEditable = !1, n.setState({
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 = (s = e.domElement) == null ? void 0 : s.querySelector(
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(T)) == null || r.showSelection(!1, "aiMenu"), e.isEditable = !0, e.focus();
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((l, s) => R(l, (m) => {
145
- s == null || s(m.setMeta("addToHistory", !1));
146
- })), e.exec((l, s) => {
147
- const m = l.tr;
148
- m.replace(
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
- m.doc.content.size,
151
- new j(q.from(r), 0, 0)
150
+ l.doc.content.size,
151
+ new D(q.from(r), 0, 0)
152
152
  );
153
- const p = l.apply(m);
154
- return ue(p, (f) => {
155
- s == null || s(
156
- m.replace(
153
+ const d = s.apply(l);
154
+ return me(d, (f) => {
155
+ m == null || m(
156
+ l.replace(
157
157
  0,
158
- m.doc.content.size,
159
- new j(q.from(f.doc), 0, 0)
158
+ l.doc.content.size,
159
+ new D(q.from(f.doc), 0, 0)
160
160
  )
161
161
  );
162
162
  });
163
- }), (a = e.getExtension(L)) == null || a.merge({ keepChanges: !0 }), this.closeAIMenu();
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, l) => R(a, (s) => {
171
- l == null || l(s.setMeta("addToHistory", !1));
172
- })), (r = e.getExtension(L)) == null || r.merge({ keepChanges: !1 }), this.closeAIMenu();
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 l = i.chat;
185
- i.abortController.abort(r), await l.stop();
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 l;
214
+ var s;
215
215
  const a = n.state.aiMenuState;
216
216
  if (a !== "closed")
217
- if (r === "ai-writing" && ((l = e.getExtension(T)) == null || l.showSelection(!1, "aiMenu")), typeof r == "object") {
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 ie(r.status);
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, l, s, m;
246
- this.setAIResponseStatus("thinking"), (a = e.getExtension(L)) == null || a.fork();
245
+ var a, s, m, l;
246
+ this.setAIResponseStatus("thinking"), (a = e.getExtension(A)) == null || a.fork();
247
247
  try {
248
- const p = new AbortController();
249
- i ? (i.previousRequestOptions = r, i.abortController = p) : i = {
248
+ const d = new AbortController();
249
+ i ? (i.previousRequestOptions = r, i.abortController = d) : i = {
250
250
  previousRequestOptions: r,
251
- chat: ((l = r.chatProvider) == null ? void 0 : l.call(r)) || ((m = (s = this.options.state).chatProvider) == null ? void 0 : m.call(s)) || new ne({
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: p
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 u = await fe({
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: (O) => {
269
- const B = n.state.aiMenuState, z = B === "closed" ? void 0 : B;
270
- if (!z || z.status !== "ai-writing")
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 V = re(
273
- O,
272
+ const v = ie(
273
+ k,
274
274
  e.prosemirrorState.doc
275
275
  );
276
- V && (n.setState({
276
+ v && (n.setState({
277
277
  aiMenuState: {
278
- blockId: O,
278
+ blockId: k,
279
279
  status: "ai-writing"
280
280
  }
281
- }), d && e.prosemirrorView.domAtPos(
282
- V.posBeforeNode + 1
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
- d = !0, this.setAIResponseStatus("ai-writing"), u.emptyCursorBlockToDelete && u.editor.getBlock(u.emptyCursorBlockToDelete) && u.editor.removeBlocks([
289
- u.emptyCursorBlockToDelete
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
- }), C = await ge(
292
+ }), w = await pe(
293
293
  f,
294
- u,
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
- C.ok && f.status !== "error" || p.signal.aborted ? this.setAIResponseStatus("user-reviewing") : (console.warn("Error calling LLM", {
308
- result: C,
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: C.ok ? f.error : C.error
313
+ error: w.ok ? f.error : w.error
314
314
  }));
315
- } catch (p) {
315
+ } catch (d) {
316
316
  this.setAIResponseStatus({
317
317
  status: "error",
318
- error: p
318
+ error: d
319
319
  }), console.error(
320
320
  "Unexpected error calling LLM",
321
- p,
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 Q = {
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
- }, F = v.createContext && /* @__PURE__ */ v.createContext(Q), xe = ["attr", "size", "title"];
336
- function Me(e, t) {
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 = Le(e, t), n, i;
338
+ var o = Pe(e, t), n, i;
339
339
  if (Object.getOwnPropertySymbols) {
340
- var d = Object.getOwnPropertySymbols(e);
341
- for (i = 0; i < d.length; i++)
342
- n = d[i], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[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 Le(e, t) {
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 x() {
357
- return x = Object.assign ? Object.assign.bind() : function(e) {
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
- }, x.apply(this, arguments);
364
+ }, T.apply(this, arguments);
365
365
  }
366
- function U(e, t) {
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 M(e) {
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 ? U(Object(o), !0).forEach(function(n) {
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)) : U(Object(o)).forEach(function(n) {
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 = Pe(t), t in e ? Object.defineProperty(e, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = o, e;
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 Pe(e) {
391
- var t = Ee(e, "string");
390
+ function Ee(e) {
391
+ var t = Ae(e, "string");
392
392
  return typeof t == "symbol" ? t : t + "";
393
393
  }
394
- function Ee(e, t) {
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 X(e) {
405
- return e && e.map((t, o) => /* @__PURE__ */ v.createElement(t.tag, M({
404
+ function ee(e) {
405
+ return e && e.map((t, o) => /* @__PURE__ */ y.createElement(t.tag, E({
406
406
  key: o
407
- }, t.attr), X(t.child)));
407
+ }, t.attr), ee(t.child)));
408
408
  }
409
409
  function h(e) {
410
- return (t) => /* @__PURE__ */ v.createElement(Ae, x({
411
- attr: M({}, e.attr)
412
- }, t), X(e.child));
410
+ return (t) => /* @__PURE__ */ y.createElement(Oe, T({
411
+ attr: E({}, e.attr)
412
+ }, t), ee(e.child));
413
413
  }
414
- function Ae(e) {
414
+ function Oe(e) {
415
415
  var t = (o) => {
416
416
  var {
417
417
  attr: n,
418
418
  size: i,
419
- title: d
420
- } = e, g = Me(e, xe), r = i || o.size || "1em", a;
421
- return o.className && (a = o.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ v.createElement("svg", x({
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, g, {
425
+ }, o.attr, n, p, {
426
426
  className: a,
427
- style: M(M({
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
- }), d && /* @__PURE__ */ v.createElement("title", null, d), e.children);
433
+ }), u && /* @__PURE__ */ y.createElement("title", null, u), e.children);
434
434
  };
435
- return F !== void 0 ? /* @__PURE__ */ v.createElement(F.Consumer, null, (o) => t(o)) : t(Q);
435
+ return K !== void 0 ? /* @__PURE__ */ y.createElement(K.Consumer, null, (o) => t(o)) : t(X);
436
436
  }
437
- function ee(e) {
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 K(e) {
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 Oe(e) {
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 Be(e) {
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 ze(e) {
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 Re(e) {
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 je(e) {
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 A(e) {
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 te() {
471
- const e = he();
472
- return y(e.editor);
470
+ function ne() {
471
+ const e = Ce();
472
+ return _(e.editor);
473
473
  }
474
474
  const Ze = (e) => {
475
- const t = P(), { onManualPromptSubmit: o, promptText: n, onPromptTextChange: i } = e, [d, g] = Y(""), r = n || d, a = I(
476
- async (u) => {
477
- u.key === "Enter" && !u.nativeEvent.isComposing && o(r);
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
- [r, o]
480
- ), l = I(
481
- (u) => {
482
- const C = u.currentTarget.value;
483
- i && i(C), n === void 0 && g(C);
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, g, n]
486
- ), s = k(() => se(e.items, r), [r, e.items]), { selectedIndex: m, setSelectedIndex: p, handler: f } = Ce(s, (u) => u.onItemClick()), w = I(
487
- (u) => {
488
- u.key === "Enter" && !u.nativeEvent.isComposing ? s.length > 0 ? f(u) : a(u) : f(u);
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
- [a, f, s.length]
490
+ [s, S, l.length]
491
491
  );
492
- return J(() => {
493
- p(0);
494
- }, [r, p]), /* @__PURE__ */ pe("div", { className: "bn-combobox", children: [
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: r || "",
503
- autoFocus: !0,
507
+ value: a || "",
504
508
  placeholder: e.placeholder,
505
509
  disabled: e.disabled,
506
510
  onKeyDown: w,
507
- onChange: l,
511
+ onChange: m,
508
512
  autoComplete: "off",
509
- rightSection: e.rightSection
510
- },
511
- "input-" + e.disabled
513
+ rightSection: e.rightSection,
514
+ "aria-activedescendant": b
515
+ }
512
516
  ) }),
513
- s.length > 0 && /* @__PURE__ */ c(
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: s.map((u, C) => /* @__PURE__ */ c(
522
+ children: l.map((g, v) => /* @__PURE__ */ c(
519
523
  t.SuggestionMenu.Item,
520
524
  {
521
- className: ae(
525
+ className: se(
522
526
  "bn-suggestion-menu-item",
523
- u.size === "small" ? "bn-suggestion-menu-item-small" : ""
527
+ g.size === "small" ? "bn-suggestion-menu-item-small" : ""
524
528
  ),
525
- id: `bn-suggestion-menu-item-${C}`,
526
- isSelected: C === m,
527
- onClick: u.onItemClick,
528
- item: u
529
+ id: `bn-suggestion-menu-item-${v}`,
530
+ isSelected: v === d,
531
+ onClick: g.onItemClick,
532
+ item: g
529
533
  },
530
- u.title
534
+ g.title
531
535
  ))
532
536
  }
533
537
  )
534
538
  ] });
535
539
  };
536
- function De(e) {
537
- const t = y(e), o = e.getExtension(b);
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(K, { size: 18 }),
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: S.html.getStreamToolsProvider({
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(ze, { size: 18 }),
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: S.html.getStreamToolsProvider({
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(Be, { size: 18 }),
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: S.html.getStreamToolsProvider({
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(K, { size: 18 }),
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 Ne(e) {
612
- const t = y(e), o = e.getExtension(b);
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: S.html.getStreamToolsProvider({
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(je, { size: 18 }),
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: S.html.getStreamToolsProvider({
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(Oe, { size: 18 }),
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: S.html.getStreamToolsProvider({
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 Fe(e) {
690
- const t = y(e), o = e.getExtension(b);
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(Re, { size: 18 }),
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(ee, { size: 18 }),
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 Ue(e) {
715
- const t = y(e), o = e.getExtension(b);
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(ee, { size: 18 }),
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 Ke(e, t) {
740
- return t === "user-input" ? e.getSelection() ? Ne(e) : De(e) : t === "user-reviewing" ? Fe(e) : t === "error" ? Ue(e) : [];
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 We = (e) => {
743
- const t = E(), [o, n] = Y(""), i = te(), d = P(), g = _(b), r = $(b, {
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, l = k(() => {
749
+ }), { items: a } = e, s = M(() => {
746
750
  let f = [];
747
- return a ? f = a(t, r) : f = Ke(t, r), f.map((w) => ({
748
- ...w,
751
+ return a ? f = a(t, r) : f = We(t, r), f.map((S) => ({
752
+ ...S,
749
753
  onItemClick: () => {
750
- w.onItemClick(n);
754
+ S.onItemClick(n);
751
755
  }
752
756
  }));
753
- }, [a, r, t]), s = I(
757
+ }, [a, r, t]), m = L(
754
758
  async (f) => {
755
- await g.invokeAI({
759
+ await p.invokeAI({
756
760
  userPrompt: f,
757
761
  useSelection: t.getSelection() !== void 0
758
762
  });
759
763
  },
760
- [g, t]
764
+ [p, t]
761
765
  );
762
- J(() => {
766
+ B(() => {
763
767
  (r === "ai-writing" || r === "user-reviewing" || r === "error") && n("");
764
768
  }, [r]);
765
- const m = k(() => 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]), p = k(() => {
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
- d.SuggestionMenu.Loader,
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
- }, [d, r]);
789
+ }, [u, r]);
786
790
  return /* @__PURE__ */ c(
787
791
  Ze,
788
792
  {
789
- onManualPromptSubmit: e.onManualPromptSubmit || s,
790
- items: l,
793
+ onManualPromptSubmit: e.onManualPromptSubmit || m,
794
+ items: s,
791
795
  promptText: o,
792
796
  onPromptTextChange: n,
793
- placeholder: m,
797
+ placeholder: l,
794
798
  disabled: r === "thinking" || r === "ai-writing",
795
- icon: /* @__PURE__ */ c("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ c(A, {}) }),
796
- rightSection: p
799
+ icon: /* @__PURE__ */ c("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ c(V, {}) }),
800
+ rightSection: d
797
801
  }
798
802
  );
799
- }, ut = (e) => {
800
- const t = E(), o = _(b), n = $(b, {
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, d = k(
807
+ }), i = n === "closed" ? void 0 : n.blockId, u = M(
804
808
  () => {
805
- var r, a, l;
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
- ve(10),
813
- Se(),
814
- ye({
815
- apply({ rects: s, elements: m }) {
816
- Object.assign(m.floating.style, {
817
- width: `${s.reference.width}px`
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: (s) => {
823
- s || n === "closed" || (n.status === "user-input" ? o.closeAIMenu() : (n.status === "user-reviewing" || n.status === "error") && o.rejectChanges());
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(s, m, p) {
826
- return we(s, m, p, {
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: (s) => {
838
- if (s.target instanceof Element) {
839
- const m = s.target.closest(".bn-block");
840
- m && m.getAttribute("data-id") === i && o.closeAIMenu();
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,28 @@ const We = (e) => {
847
851
  style: {
848
852
  zIndex: 100
849
853
  },
850
- ...(l = e.floatingUIOptions) == null ? void 0 : l.elementProps
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
+ // needed for https://github.com/floating-ui/floating-ui/pull/3202
861
+ // (related: https://github.com/mui/base-ui/issues/3950)
862
+ getInsideElements: () => t.domElement ? [t.domElement] : [],
863
+ ...(m = e.floatingUIOptions) == null ? void 0 : m.focusManagerProps
851
864
  }
852
865
  };
853
866
  },
854
- [o, n, i, e.floatingUIOptions]
855
- ), g = e.aiMenu || We;
856
- return /* @__PURE__ */ c(be, { blockId: i, ...d, children: n !== "closed" && /* @__PURE__ */ c(g, {}) });
857
- }, mt = () => {
858
- const e = te(), t = P(), o = E(), n = _(b), i = _(le), d = () => {
859
- const g = o.getSelection();
860
- if (!g)
867
+ [o, n, i, e.floatingUIOptions, t.domElement]
868
+ ), p = e.aiMenu || Ge;
869
+ return /* @__PURE__ */ c(ve, { blockId: i, ...u, children: n !== "closed" && /* @__PURE__ */ c(p, {}) });
870
+ }, dt = () => {
871
+ const e = ne(), t = z(), o = R(), n = P(C), i = P(ce), u = () => {
872
+ const p = o.getSelection();
873
+ if (!p)
861
874
  throw new Error("No selection");
862
- const r = g.blocks[g.blocks.length - 1].id;
875
+ const r = p.blocks[p.blocks.length - 1].id;
863
876
  n.openAIMenuAtBlock(r), i.store.setState(!1);
864
877
  };
865
878
  return o.isEditable ? /* @__PURE__ */ c(
@@ -868,15 +881,15 @@ const We = (e) => {
868
881
  className: "bn-button",
869
882
  label: e.formatting_toolbar.ai.tooltip,
870
883
  mainTooltip: e.formatting_toolbar.ai.tooltip,
871
- icon: /* @__PURE__ */ c(A, {}),
872
- onClick: d
884
+ icon: /* @__PURE__ */ c(V, {}),
885
+ onClick: u
873
886
  }
874
887
  ) : null;
875
- }, Ge = {
876
- AI: A
888
+ }, $e = {
889
+ AI: V
877
890
  };
878
- function dt(e) {
879
- const t = e.getExtension(b);
891
+ function ft(e) {
892
+ const t = e.getExtension(C);
880
893
  return t ? [
881
894
  {
882
895
  key: "ai",
@@ -885,38 +898,38 @@ function dt(e) {
885
898
  n.block.content && Array.isArray(n.block.content) && // isarray check not ideal
886
899
  n.block.content.length === 0 && n.prevBlock ? t.openAIMenuAtBlock(n.prevBlock.id) : t.openAIMenuAtBlock(n.block.id);
887
900
  },
888
- ...y(e).slash_menu.ai,
889
- icon: /* @__PURE__ */ c(Ge.AI, {})
901
+ ..._(e).slash_menu.ai,
902
+ icon: /* @__PURE__ */ c($e.AI, {})
890
903
  }
891
904
  ] : [];
892
905
  }
893
906
  export {
894
- b as AIExtension,
895
- We as AIMenu,
896
- ut as AIMenuController,
897
- mt as AIToolbarButton,
898
- pt as ClientSideTransport,
899
- ht as PROVIDER_OVERRIDES,
907
+ C as AIExtension,
908
+ Ge as AIMenu,
909
+ mt as AIMenuController,
910
+ dt as AIToolbarButton,
911
+ ht as ClientSideTransport,
912
+ Ct as PROVIDER_OVERRIDES,
900
913
  Ze as PromptSuggestionMenu,
901
- Ct as StreamToolExecutor,
902
- bt as _getApplySuggestionsTr,
903
- S as aiDocumentFormats,
904
- fe as buildAIRequest,
905
- vt as createStreamToolsArraySchema,
906
- St as fetchViaProxy,
907
- y as getAIDictionary,
908
- dt as getAISlashMenuItems,
909
- Ke as getDefaultAIMenuItems,
910
- yt as getProviderOverrides,
911
- wt as injectDocumentStateMessages,
912
- kt as makeDocumentStateBuilder,
913
- It as objectStreamToOperationsResult,
914
- _t as promptHelpers,
915
- ge as sendMessageWithAIRequest,
916
- xt as setupToolCallStreaming,
917
- Mt as streamToolsToToolSet,
918
- Lt as toolDefinitionsToToolSet,
914
+ bt as StreamToolExecutor,
915
+ vt as _getApplySuggestionsTr,
916
+ I as aiDocumentFormats,
917
+ ge as buildAIRequest,
918
+ St as createStreamToolsArraySchema,
919
+ yt as fetchViaProxy,
920
+ _ as getAIDictionary,
921
+ ft as getAISlashMenuItems,
922
+ We as getDefaultAIMenuItems,
923
+ wt as getProviderOverrides,
924
+ kt as injectDocumentStateMessages,
925
+ It as makeDocumentStateBuilder,
926
+ _t as objectStreamToOperationsResult,
927
+ xt as promptHelpers,
928
+ pe as sendMessageWithAIRequest,
929
+ Mt as setupToolCallStreaming,
930
+ Lt as streamToolsToToolSet,
931
+ Pt as toolDefinitionsToToolSet,
919
932
  Tt as toolSetToToolDefinitions,
920
- te as useAIDictionary
933
+ ne as useAIDictionary
921
934
  };
922
935
  //# sourceMappingURL=blocknote-xl-ai.js.map