@liveblocks/react-tiptap 3.9.1 → 3.9.2-tiptap2

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.
Files changed (82) hide show
  1. package/dist/LiveblocksExtension.cjs +7 -3
  2. package/dist/LiveblocksExtension.cjs.map +1 -1
  3. package/dist/LiveblocksExtension.js +7 -3
  4. package/dist/LiveblocksExtension.js.map +1 -1
  5. package/dist/ai/AiExtension.cjs +8 -0
  6. package/dist/ai/AiExtension.cjs.map +1 -1
  7. package/dist/ai/AiExtension.js +8 -0
  8. package/dist/ai/AiExtension.js.map +1 -1
  9. package/dist/ai/AiToolbar.cjs +256 -235
  10. package/dist/ai/AiToolbar.cjs.map +1 -1
  11. package/dist/ai/AiToolbar.js +256 -235
  12. package/dist/ai/AiToolbar.js.map +1 -1
  13. package/dist/comments/AnchoredThreads.cjs +63 -50
  14. package/dist/comments/AnchoredThreads.cjs.map +1 -1
  15. package/dist/comments/AnchoredThreads.js +63 -50
  16. package/dist/comments/AnchoredThreads.js.map +1 -1
  17. package/dist/comments/CommentsExtension.cjs +3 -0
  18. package/dist/comments/CommentsExtension.cjs.map +1 -1
  19. package/dist/comments/CommentsExtension.js +3 -0
  20. package/dist/comments/CommentsExtension.js.map +1 -1
  21. package/dist/comments/FloatingComposer.cjs +32 -22
  22. package/dist/comments/FloatingComposer.cjs.map +1 -1
  23. package/dist/comments/FloatingComposer.js +32 -22
  24. package/dist/comments/FloatingComposer.js.map +1 -1
  25. package/dist/comments/FloatingThreads.cjs +39 -33
  26. package/dist/comments/FloatingThreads.cjs.map +1 -1
  27. package/dist/comments/FloatingThreads.js +39 -33
  28. package/dist/comments/FloatingThreads.js.map +1 -1
  29. package/dist/context.cjs +1 -4
  30. package/dist/context.cjs.map +1 -1
  31. package/dist/context.js +1 -4
  32. package/dist/context.js.map +1 -1
  33. package/dist/index.d.cts +135 -4
  34. package/dist/index.d.ts +135 -4
  35. package/dist/mentions/GroupMentionNode.cjs +2 -0
  36. package/dist/mentions/GroupMentionNode.cjs.map +1 -1
  37. package/dist/mentions/GroupMentionNode.js +2 -0
  38. package/dist/mentions/GroupMentionNode.js.map +1 -1
  39. package/dist/mentions/Mention.cjs +35 -42
  40. package/dist/mentions/Mention.cjs.map +1 -1
  41. package/dist/mentions/Mention.js +34 -41
  42. package/dist/mentions/Mention.js.map +1 -1
  43. package/dist/mentions/MentionExtension.cjs +1 -0
  44. package/dist/mentions/MentionExtension.cjs.map +1 -1
  45. package/dist/mentions/MentionExtension.js +1 -0
  46. package/dist/mentions/MentionExtension.js.map +1 -1
  47. package/dist/mentions/MentionNode.cjs +2 -0
  48. package/dist/mentions/MentionNode.cjs.map +1 -1
  49. package/dist/mentions/MentionNode.js +2 -0
  50. package/dist/mentions/MentionNode.js.map +1 -1
  51. package/dist/mentions/MentionsList.cjs +66 -51
  52. package/dist/mentions/MentionsList.cjs.map +1 -1
  53. package/dist/mentions/MentionsList.js +66 -51
  54. package/dist/mentions/MentionsList.js.map +1 -1
  55. package/dist/toolbar/FloatingToolbar.cjs +43 -28
  56. package/dist/toolbar/FloatingToolbar.cjs.map +1 -1
  57. package/dist/toolbar/FloatingToolbar.js +43 -28
  58. package/dist/toolbar/FloatingToolbar.js.map +1 -1
  59. package/dist/toolbar/Toolbar.cjs +191 -153
  60. package/dist/toolbar/Toolbar.cjs.map +1 -1
  61. package/dist/toolbar/Toolbar.js +191 -153
  62. package/dist/toolbar/Toolbar.js.map +1 -1
  63. package/dist/toolbar/shared.cjs +12 -11
  64. package/dist/toolbar/shared.cjs.map +1 -1
  65. package/dist/toolbar/shared.js +12 -11
  66. package/dist/toolbar/shared.js.map +1 -1
  67. package/dist/types.cjs.map +1 -1
  68. package/dist/types.js.map +1 -1
  69. package/dist/utils.cjs.map +1 -1
  70. package/dist/utils.js.map +1 -1
  71. package/dist/version-history/HistoryVersionPreview.cjs +30 -42
  72. package/dist/version-history/HistoryVersionPreview.cjs.map +1 -1
  73. package/dist/version-history/HistoryVersionPreview.js +30 -42
  74. package/dist/version-history/HistoryVersionPreview.js.map +1 -1
  75. package/dist/version.cjs +1 -1
  76. package/dist/version.cjs.map +1 -1
  77. package/dist/version.js +1 -1
  78. package/dist/version.js.map +1 -1
  79. package/package.json +14 -14
  80. package/src/styles/index.css +3 -2
  81. package/styles.css +1 -1
  82. package/styles.css.map +1 -1
@@ -57,43 +57,43 @@ function flipToolbar() {
57
57
  };
58
58
  }
59
59
  const AiToolbarDropdownSeparator = forwardRef(({ className, ...props }, forwardedRef) => {
60
- return /* @__PURE__ */ jsx(Command.Separator, {
61
- className: cn("lb-dropdown-separator", className),
62
- ...props,
63
- ref: forwardedRef
64
- });
60
+ return /* @__PURE__ */ jsx(
61
+ Command.Separator,
62
+ {
63
+ className: cn("lb-dropdown-separator", className),
64
+ ...props,
65
+ ref: forwardedRef
66
+ }
67
+ );
65
68
  });
66
69
  const AiToolbarSuggestionsSeparator = forwardRef((props, forwardedRef) => {
67
- return /* @__PURE__ */ jsx(AiToolbarDropdownSeparator, {
68
- ref: forwardedRef,
69
- ...props
70
- });
70
+ return /* @__PURE__ */ jsx(AiToolbarDropdownSeparator, { ref: forwardedRef, ...props });
71
71
  });
72
72
  const AiToolbarDropdownItem = forwardRef(({ children, onSelect, icon, className, ...props }, forwardedRef) => {
73
- return /* @__PURE__ */ jsxs(Command.Item, {
74
- className: cn("lb-dropdown-item", className),
75
- onSelect,
76
- ...props,
77
- ref: forwardedRef,
78
- children: [
79
- icon ? /* @__PURE__ */ jsx("span", {
80
- className: "lb-icon-container",
81
- children: icon
82
- }) : null,
83
- children ? /* @__PURE__ */ jsx("span", {
84
- className: "lb-dropdown-item-label",
85
- children
86
- }) : null
87
- ]
88
- });
73
+ return /* @__PURE__ */ jsxs(
74
+ Command.Item,
75
+ {
76
+ className: cn("lb-dropdown-item", className),
77
+ onSelect,
78
+ ...props,
79
+ ref: forwardedRef,
80
+ children: [
81
+ icon ? /* @__PURE__ */ jsx("span", { className: "lb-icon-container", children: icon }) : null,
82
+ children ? /* @__PURE__ */ jsx("span", { className: "lb-dropdown-item-label", children }) : null
83
+ ]
84
+ }
85
+ );
89
86
  });
90
87
  const AiToolbarSuggestionsLabel = forwardRef(({ children, className, ...props }, forwardedRef) => {
91
- return /* @__PURE__ */ jsx("span", {
92
- ref: forwardedRef,
93
- className: cn("lb-dropdown-label", className),
94
- ...props,
95
- children
96
- });
88
+ return /* @__PURE__ */ jsx(
89
+ "span",
90
+ {
91
+ ref: forwardedRef,
92
+ className: cn("lb-dropdown-label", className),
93
+ ...props,
94
+ children
95
+ }
96
+ );
97
97
  });
98
98
  const AiToolbarSuggestion = forwardRef(({ prompt: manualPrompt, ...props }, forwardedRef) => {
99
99
  const editor = useCurrentEditor("Suggestion", "AiToolbar");
@@ -105,56 +105,73 @@ const AiToolbarSuggestion = forwardRef(({ prompt: manualPrompt, ...props }, forw
105
105
  },
106
106
  [editor, manualPrompt]
107
107
  );
108
- return /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
109
- ...props,
110
- onSelect: handleSelect,
111
- ref: forwardedRef
112
- });
108
+ return /* @__PURE__ */ jsx(
109
+ AiToolbarDropdownItem,
110
+ {
111
+ ...props,
112
+ onSelect: handleSelect,
113
+ ref: forwardedRef
114
+ }
115
+ );
113
116
  });
114
117
  function AiToolbarReviewingSuggestions() {
115
118
  const editor = useCurrentEditor("ReviewingSuggestions", "AiToolbar");
116
119
  const { state } = useAiToolbarContext();
117
120
  const { response } = state;
118
121
  if (isContextualPromptDiffResponse(response)) {
119
- return /* @__PURE__ */ jsxs(Fragment, {
120
- children: [
121
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
122
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
123
+ /* @__PURE__ */ jsx(
124
+ AiToolbarDropdownItem,
125
+ {
122
126
  icon: /* @__PURE__ */ jsx(CheckIcon, {}),
123
127
  onSelect: editor.commands.$acceptAiToolbarResponse,
124
128
  children: "Accept"
125
- }),
126
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsx(
132
+ AiToolbarDropdownItem,
133
+ {
127
134
  icon: /* @__PURE__ */ jsx(UndoIcon, {}),
128
135
  onSelect: editor.commands.$startAiToolbarThinking,
129
136
  children: "Try again"
130
- }),
131
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx(
140
+ AiToolbarDropdownItem,
141
+ {
132
142
  icon: /* @__PURE__ */ jsx(CrossIcon, {}),
133
143
  onSelect: editor.commands.$closeAiToolbar,
134
144
  children: "Discard"
135
- })
136
- ]
137
- });
145
+ }
146
+ )
147
+ ] });
138
148
  } else {
139
- return /* @__PURE__ */ jsxs(Fragment, {
140
- children: [
141
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
149
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
150
+ /* @__PURE__ */ jsx(
151
+ AiToolbarDropdownItem,
152
+ {
142
153
  icon: /* @__PURE__ */ jsx(ArrowCornerDownRightIcon, {}),
143
154
  onSelect: editor.commands.$acceptAiToolbarResponse,
144
155
  children: "Insert below"
145
- }),
146
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
156
+ }
157
+ ),
158
+ /* @__PURE__ */ jsx(
159
+ AiToolbarDropdownItem,
160
+ {
147
161
  icon: /* @__PURE__ */ jsx(UndoIcon, {}),
148
162
  onSelect: editor.commands.$startAiToolbarThinking,
149
163
  children: "Try again"
150
- }),
151
- /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsx(
167
+ AiToolbarDropdownItem,
168
+ {
152
169
  icon: /* @__PURE__ */ jsx(CrossIcon, {}),
153
170
  onSelect: editor.commands.$closeAiToolbar,
154
171
  children: "Discard"
155
- })
156
- ]
157
- });
172
+ }
173
+ )
174
+ ] });
158
175
  }
159
176
  }
160
177
  function AiToolbarCustomPromptContent() {
@@ -182,6 +199,7 @@ function AiToolbarCustomPromptContent() {
182
199
  });
183
200
  },
184
201
  []
202
+ // eslint-disable-line react-hooks/exhaustive-deps
185
203
  );
186
204
  const handlePromptKeyDown = (event) => {
187
205
  if (event.key === "Enter") {
@@ -223,66 +241,57 @@ function AiToolbarCustomPromptContent() {
223
241
  state.phase === "reviewing"
224
242
  );
225
243
  }, [editor, customPrompt, isCustomPromptEmpty, state.phase]);
226
- return /* @__PURE__ */ jsxs("div", {
227
- className: "lb-tiptap-ai-toolbar-content",
228
- children: [
229
- /* @__PURE__ */ jsx("span", {
230
- className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container",
231
- children: /* @__PURE__ */ jsx(SparklesIcon, {})
232
- }),
233
- /* @__PURE__ */ jsx("div", {
244
+ return /* @__PURE__ */ jsxs("div", { className: "lb-tiptap-ai-toolbar-content", children: [
245
+ /* @__PURE__ */ jsx("span", { className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container", children: /* @__PURE__ */ jsx(SparklesIcon, {}) }),
246
+ /* @__PURE__ */ jsx(
247
+ "div",
248
+ {
234
249
  className: "lb-tiptap-ai-toolbar-custom-prompt-container",
235
250
  "data-value": customPrompt,
236
- children: /* @__PURE__ */ jsx(Command.Input, {
237
- value: customPrompt,
238
- onValueChange: handleCustomPromptChange,
239
- asChild: true,
240
- children: /* @__PURE__ */ jsx("textarea", {
241
- ref: textAreaRef,
242
- className: "lb-tiptap-ai-toolbar-custom-prompt",
243
- placeholder: `Ask ${aiName} anything\u2026`,
244
- onKeyDown: handlePromptKeyDown,
245
- rows: 1,
246
- autoFocus: true
247
- })
248
- })
249
- }),
250
- /* @__PURE__ */ jsx("div", {
251
- className: "lb-tiptap-ai-toolbar-actions",
252
- children: /* @__PURE__ */ jsx(ShortcutTooltip, {
253
- content: `Ask ${aiName}`,
254
- shortcut: "Enter",
255
- children: /* @__PURE__ */ jsx(Button, {
256
- className: "lb-tiptap-ai-toolbar-action",
257
- variant: "primary",
258
- "aria-label": `Ask ${aiName}`,
259
- icon: /* @__PURE__ */ jsx(SendIcon, {}),
260
- disabled: isCustomPromptEmpty,
261
- onClick: handleSendClick
262
- })
263
- })
264
- })
265
- ]
266
- });
251
+ children: /* @__PURE__ */ jsx(
252
+ Command.Input,
253
+ {
254
+ value: customPrompt,
255
+ onValueChange: handleCustomPromptChange,
256
+ asChild: true,
257
+ children: /* @__PURE__ */ jsx(
258
+ "textarea",
259
+ {
260
+ ref: textAreaRef,
261
+ className: "lb-tiptap-ai-toolbar-custom-prompt",
262
+ placeholder: `Ask ${aiName} anything\u2026`,
263
+ onKeyDown: handlePromptKeyDown,
264
+ rows: 1,
265
+ autoFocus: true
266
+ }
267
+ )
268
+ }
269
+ )
270
+ }
271
+ ),
272
+ /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-actions", children: /* @__PURE__ */ jsx(ShortcutTooltip, { content: `Ask ${aiName}`, shortcut: "Enter", children: /* @__PURE__ */ jsx(
273
+ Button,
274
+ {
275
+ className: "lb-tiptap-ai-toolbar-action",
276
+ variant: "primary",
277
+ "aria-label": `Ask ${aiName}`,
278
+ icon: /* @__PURE__ */ jsx(SendIcon, {}),
279
+ disabled: isCustomPromptEmpty,
280
+ onClick: handleSendClick
281
+ }
282
+ ) }) })
283
+ ] });
267
284
  }
268
285
  function AiToolbarAsking() {
269
286
  const { state } = useAiToolbarContext();
270
287
  const { error } = state;
271
- return /* @__PURE__ */ jsxs(Fragment, {
272
- children: [
273
- /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {}),
274
- error ? /* @__PURE__ */ jsxs("div", {
275
- className: "lb-tiptap-ai-toolbar-error",
276
- children: [
277
- /* @__PURE__ */ jsx("span", {
278
- className: "lb-icon-container",
279
- children: /* @__PURE__ */ jsx(WarningIcon, {})
280
- }),
281
- "There was a problem with your request."
282
- ]
283
- }) : null
284
- ]
285
- });
288
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
289
+ /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {}),
290
+ error ? /* @__PURE__ */ jsxs("div", { className: "lb-tiptap-ai-toolbar-error", children: [
291
+ /* @__PURE__ */ jsx("span", { className: "lb-icon-container", children: /* @__PURE__ */ jsx(WarningIcon, {}) }),
292
+ "There was a problem with your request."
293
+ ] }) : null
294
+ ] });
286
295
  }
287
296
  function AiToolbarThinking() {
288
297
  const editor = useCurrentEditor("AiToolbarThinking", "AiToolbar");
@@ -295,56 +304,39 @@ function AiToolbarThinking() {
295
304
  contentRef.current?.focus();
296
305
  window.getSelection()?.removeAllRanges();
297
306
  }, []);
298
- return /* @__PURE__ */ jsx(Fragment, {
299
- children: /* @__PURE__ */ jsxs("div", {
307
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
308
+ "div",
309
+ {
300
310
  className: "lb-tiptap-ai-toolbar-content",
301
311
  tabIndex: 0,
302
312
  ref: contentRef,
303
313
  children: [
304
- /* @__PURE__ */ jsx("span", {
305
- className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container",
306
- children: /* @__PURE__ */ jsx(SparklesIcon, {})
307
- }),
308
- /* @__PURE__ */ jsxs("div", {
309
- className: "lb-tiptap-ai-toolbar-thinking",
310
- children: [
311
- aiName,
312
- " is thinking\u2026"
313
- ]
314
- }),
315
- /* @__PURE__ */ jsx("div", {
316
- className: "lb-tiptap-ai-toolbar-actions",
317
- children: /* @__PURE__ */ jsx(ShortcutTooltip, {
318
- content: "Abort response",
319
- shortcut: "Escape",
320
- children: /* @__PURE__ */ jsx(Button, {
321
- className: "lb-tiptap-ai-toolbar-action",
322
- variant: "secondary",
323
- "aria-label": "Abort response",
324
- icon: /* @__PURE__ */ jsx(StopIcon, {}),
325
- onClick: handleAbort
326
- })
327
- })
328
- })
314
+ /* @__PURE__ */ jsx("span", { className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container", children: /* @__PURE__ */ jsx(SparklesIcon, {}) }),
315
+ /* @__PURE__ */ jsxs("div", { className: "lb-tiptap-ai-toolbar-thinking", children: [
316
+ aiName,
317
+ " is thinking\u2026"
318
+ ] }),
319
+ /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-actions", children: /* @__PURE__ */ jsx(ShortcutTooltip, { content: "Abort response", shortcut: "Escape", children: /* @__PURE__ */ jsx(
320
+ Button,
321
+ {
322
+ className: "lb-tiptap-ai-toolbar-action",
323
+ variant: "secondary",
324
+ "aria-label": "Abort response",
325
+ icon: /* @__PURE__ */ jsx(StopIcon, {}),
326
+ onClick: handleAbort
327
+ }
328
+ ) }) })
329
329
  ]
330
- })
331
- });
330
+ }
331
+ ) });
332
332
  }
333
333
  function AiToolbarReviewing() {
334
334
  const { state } = useAiToolbarContext();
335
335
  const { response } = state;
336
- return /* @__PURE__ */ jsxs(Fragment, {
337
- children: [
338
- response.type === "other" ? /* @__PURE__ */ jsx("div", {
339
- className: "lb-tiptap-ai-toolbar-response-container",
340
- children: /* @__PURE__ */ jsx("div", {
341
- className: "lb-tiptap-ai-toolbar-response",
342
- children: response.text
343
- })
344
- }) : null,
345
- /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {})
346
- ]
347
- });
336
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
337
+ response.type === "other" ? /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-response-container", children: /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-response", children: response.text }) }) : null,
338
+ /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {})
339
+ ] });
348
340
  }
349
341
  function AiToolbarContainer({
350
342
  state,
@@ -382,80 +374,95 @@ function AiToolbarContainer({
382
374
  document.removeEventListener("keydown", handleKeyDown);
383
375
  };
384
376
  }, [editor, state.phase]);
385
- return /* @__PURE__ */ jsxs(AiToolbarContext.Provider, {
386
- value: {
387
- state,
388
- toolbarRef,
389
- dropdownRef,
390
- isDropdownHidden
391
- },
392
- children: [
393
- /* @__PURE__ */ jsxs("div", {
394
- className: "lb-tiptap-ai-toolbar-container",
395
- children: [
396
- /* @__PURE__ */ jsx("div", {
397
- className: "lb-elevation lb-tiptap-ai-toolbar",
398
- children: state.phase === "asking" ? /* @__PURE__ */ jsx(AiToolbarAsking, {}) : state.phase === "thinking" ? /* @__PURE__ */ jsx(AiToolbarThinking, {}) : state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewing, {}) : null
399
- }),
400
- /* @__PURE__ */ jsxs("div", {
401
- className: "lb-tiptap-ai-toolbar-halo",
402
- "data-active": state.phase === "thinking" ? "" : void 0,
403
- "aria-hidden": true,
404
- children: [
405
- /* @__PURE__ */ jsx("div", {
406
- className: "lb-tiptap-ai-toolbar-halo-horizontal"
407
- }),
408
- /* @__PURE__ */ jsx("div", {
409
- className: "lb-tiptap-ai-toolbar-halo-vertical"
410
- })
411
- ]
412
- })
413
- ]
414
- }),
415
- state.phase === "asking" || state.phase === "reviewing" ? /* @__PURE__ */ jsx(Command.List, {
416
- className: "lb-elevation lb-dropdown lb-tiptap-ai-toolbar-dropdown",
417
- "data-hidden": isDropdownHidden ? "" : void 0,
418
- ref: dropdownRef,
419
- children: state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewingSuggestions, {}) : children
420
- }) : null
421
- ]
422
- });
377
+ return /* @__PURE__ */ jsxs(
378
+ AiToolbarContext.Provider,
379
+ {
380
+ value: {
381
+ state,
382
+ toolbarRef,
383
+ dropdownRef,
384
+ isDropdownHidden
385
+ },
386
+ children: [
387
+ /* @__PURE__ */ jsxs("div", { className: "lb-tiptap-ai-toolbar-container", children: [
388
+ /* @__PURE__ */ jsx("div", { className: "lb-elevation lb-tiptap-ai-toolbar", children: state.phase === "asking" ? /* @__PURE__ */ jsx(AiToolbarAsking, {}) : state.phase === "thinking" ? /* @__PURE__ */ jsx(AiToolbarThinking, {}) : state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewing, {}) : null }),
389
+ /* @__PURE__ */ jsxs(
390
+ "div",
391
+ {
392
+ className: "lb-tiptap-ai-toolbar-halo",
393
+ "data-active": state.phase === "thinking" ? "" : void 0,
394
+ "aria-hidden": true,
395
+ children: [
396
+ /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-halo-horizontal" }),
397
+ /* @__PURE__ */ jsx("div", { className: "lb-tiptap-ai-toolbar-halo-vertical" })
398
+ ]
399
+ }
400
+ )
401
+ ] }),
402
+ state.phase === "asking" || state.phase === "reviewing" ? /* @__PURE__ */ jsx(
403
+ Command.List,
404
+ {
405
+ className: "lb-elevation lb-dropdown lb-tiptap-ai-toolbar-dropdown",
406
+ "data-hidden": isDropdownHidden ? "" : void 0,
407
+ ref: dropdownRef,
408
+ children: state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewingSuggestions, {}) : children
409
+ }
410
+ ) : null
411
+ ]
412
+ }
413
+ );
423
414
  }
424
- const defaultSuggestions = /* @__PURE__ */ jsxs(Fragment, {
425
- children: [
426
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
415
+ const defaultSuggestions = /* @__PURE__ */ jsxs(Fragment, { children: [
416
+ /* @__PURE__ */ jsx(
417
+ AiToolbarSuggestion,
418
+ {
427
419
  icon: /* @__PURE__ */ jsx(EditIcon, {}),
428
420
  prompt: "Improve the quality of the text",
429
421
  children: "Improve writing"
430
- }),
431
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
422
+ }
423
+ ),
424
+ /* @__PURE__ */ jsx(
425
+ AiToolbarSuggestion,
426
+ {
432
427
  icon: /* @__PURE__ */ jsx(CheckIcon, {}),
433
428
  prompt: "Fix spelling & grammar errors in the text",
434
429
  children: "Fix mistakes"
435
- }),
436
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
430
+ }
431
+ ),
432
+ /* @__PURE__ */ jsx(
433
+ AiToolbarSuggestion,
434
+ {
437
435
  icon: /* @__PURE__ */ jsx(ShortenIcon, {}),
438
436
  prompt: "Shorten the text, simplifying it",
439
437
  children: "Simplify"
440
- }),
441
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsx(
441
+ AiToolbarSuggestion,
442
+ {
442
443
  icon: /* @__PURE__ */ jsx(LengthenIcon, {}),
443
444
  prompt: "Lengthen the text, going into more detail",
444
445
  children: "Add more detail"
445
- }),
446
- /* @__PURE__ */ jsx(AiToolbarSuggestionsSeparator, {}),
447
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
446
+ }
447
+ ),
448
+ /* @__PURE__ */ jsx(AiToolbarSuggestionsSeparator, {}),
449
+ /* @__PURE__ */ jsx(
450
+ AiToolbarSuggestion,
451
+ {
448
452
  icon: /* @__PURE__ */ jsx(SparklesTextIcon, {}),
449
453
  prompt: "Continue writing from the text's end",
450
454
  children: "Continue writing"
451
- }),
452
- /* @__PURE__ */ jsx(AiToolbarSuggestion, {
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx(
458
+ AiToolbarSuggestion,
459
+ {
453
460
  icon: /* @__PURE__ */ jsx(QuestionMarkIcon, {}),
454
461
  prompt: "Explain what the text is about",
455
462
  children: "Explain"
456
- })
457
- ]
458
- });
463
+ }
464
+ )
465
+ ] });
459
466
  const AiToolbar = Object.assign(
460
467
  forwardRef(
461
468
  ({
@@ -612,45 +619,59 @@ const AiToolbar = Object.assign(
612
619
  return null;
613
620
  }
614
621
  return createPortal(
615
- /* @__PURE__ */ jsx(TooltipProvider, {
616
- children: /* @__PURE__ */ jsx(EditorProvider, {
617
- editor,
618
- children: /* @__PURE__ */ jsx(Command, {
619
- role: "toolbar",
620
- label: "AI toolbar",
621
- "aria-orientation": "horizontal",
622
- className: cn(
623
- "lb-root lb-portal lb-tiptap-ai-toolbar-portal",
624
- className
625
- ),
626
- ref: mergedRefs,
627
- style: {
628
- position: strategy,
629
- top: 0,
630
- left: 0,
631
- transform: isPositioned ? `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)` : "translate3d(0, -200%, 0)"
632
- },
633
- value: selectedDropdownValue,
634
- onValueChange: setSelectedDropdownValue,
635
- ...props,
636
- children: /* @__PURE__ */ jsx(AiToolbarContainer, {
622
+ /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(EditorProvider, { editor, children: /* @__PURE__ */ jsx(
623
+ Command,
624
+ {
625
+ role: "toolbar",
626
+ label: "AI toolbar",
627
+ "aria-orientation": "horizontal",
628
+ className: cn(
629
+ "lb-root lb-portal lb-tiptap-ai-toolbar-portal",
630
+ className
631
+ ),
632
+ ref: mergedRefs,
633
+ style: {
634
+ position: strategy,
635
+ top: 0,
636
+ left: 0,
637
+ transform: isPositioned ? `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)` : "translate3d(0, -200%, 0)"
638
+ },
639
+ value: selectedDropdownValue,
640
+ onValueChange: setSelectedDropdownValue,
641
+ ...props,
642
+ children: /* @__PURE__ */ jsx(
643
+ AiToolbarContainer,
644
+ {
637
645
  state,
638
646
  dropdownRef,
639
647
  toolbarRef,
640
- children: typeof Suggestions === "function" ? /* @__PURE__ */ jsx(Suggestions, {
641
- children: defaultSuggestions
642
- }) : Suggestions
643
- })
644
- })
645
- })
646
- }),
648
+ children: typeof Suggestions === "function" ? /* @__PURE__ */ jsx(Suggestions, { children: defaultSuggestions }) : Suggestions
649
+ }
650
+ )
651
+ }
652
+ ) }) }),
647
653
  document.body
648
654
  );
649
655
  }
650
656
  ),
651
657
  {
658
+ /**
659
+ * @beta
660
+ *
661
+ * A prompt suggestion displayed in the AI toolbar.
662
+ */
652
663
  Suggestion: AiToolbarSuggestion,
664
+ /**
665
+ * @beta
666
+ *
667
+ * A label to describe a group of prompt suggestions displayed in the AI toolbar.
668
+ */
653
669
  SuggestionsLabel: AiToolbarSuggestionsLabel,
670
+ /**
671
+ * @beta
672
+ *
673
+ * A separator between groups of prompt suggestions displayed in the AI toolbar.
674
+ */
654
675
  SuggestionsSeparator: AiToolbarSuggestionsSeparator
655
676
  }
656
677
  );