@liveblocks/react-tiptap 2.18.3 → 2.18.4-uns2

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 (100) hide show
  1. package/dist/{LiveblocksExtension.mjs → LiveblocksExtension.cjs} +41 -38
  2. package/dist/{LiveblocksExtension.mjs.map → LiveblocksExtension.cjs.map} +1 -1
  3. package/dist/LiveblocksExtension.js +37 -40
  4. package/dist/LiveblocksExtension.js.map +1 -1
  5. package/dist/ai/{AiExtension.mjs → AiExtension.cjs} +36 -32
  6. package/dist/ai/AiExtension.cjs.map +1 -0
  7. package/dist/ai/AiExtension.js +31 -35
  8. package/dist/ai/AiExtension.js.map +1 -1
  9. package/dist/ai/{AiToolbar.mjs → AiToolbar.cjs} +145 -142
  10. package/dist/ai/{AiToolbar.mjs.map → AiToolbar.cjs.map} +1 -1
  11. package/dist/ai/AiToolbar.js +141 -144
  12. package/dist/ai/AiToolbar.js.map +1 -1
  13. package/dist/{classnames.mjs → classnames.cjs} +4 -2
  14. package/dist/{classnames.mjs.map → classnames.cjs.map} +1 -1
  15. package/dist/classnames.js +1 -3
  16. package/dist/classnames.js.map +1 -1
  17. package/dist/comments/{AnchoredThreads.mjs → AnchoredThreads.cjs} +38 -36
  18. package/dist/comments/{AnchoredThreads.mjs.map → AnchoredThreads.cjs.map} +1 -1
  19. package/dist/comments/AnchoredThreads.js +35 -37
  20. package/dist/comments/AnchoredThreads.js.map +1 -1
  21. package/dist/comments/{CommentsExtension.mjs → CommentsExtension.cjs} +34 -32
  22. package/dist/comments/{CommentsExtension.mjs.map → CommentsExtension.cjs.map} +1 -1
  23. package/dist/comments/CommentsExtension.js +31 -33
  24. package/dist/comments/CommentsExtension.js.map +1 -1
  25. package/dist/comments/{FloatingComposer.mjs → FloatingComposer.cjs} +34 -31
  26. package/dist/comments/{FloatingComposer.mjs.map → FloatingComposer.cjs.map} +1 -1
  27. package/dist/comments/FloatingComposer.js +30 -33
  28. package/dist/comments/FloatingComposer.js.map +1 -1
  29. package/dist/comments/{FloatingThreads.mjs → FloatingThreads.cjs} +39 -36
  30. package/dist/comments/{FloatingThreads.mjs.map → FloatingThreads.cjs.map} +1 -1
  31. package/dist/comments/FloatingThreads.js +35 -38
  32. package/dist/comments/FloatingThreads.js.map +1 -1
  33. package/dist/context.cjs +24 -0
  34. package/dist/{context.mjs.map → context.cjs.map} +1 -1
  35. package/dist/context.js +8 -11
  36. package/dist/context.js.map +1 -1
  37. package/dist/index.cjs +29 -0
  38. package/dist/{index.mjs.map → index.cjs.map} +1 -1
  39. package/dist/index.js +13 -27
  40. package/dist/index.js.map +1 -1
  41. package/dist/mentions/{Avatar.mjs → Avatar.cjs} +16 -14
  42. package/dist/mentions/Avatar.cjs.map +1 -0
  43. package/dist/mentions/Avatar.js +13 -15
  44. package/dist/mentions/Avatar.js.map +1 -1
  45. package/dist/mentions/Mention.cjs +31 -0
  46. package/dist/mentions/Mention.cjs.map +1 -0
  47. package/dist/mentions/Mention.js +25 -25
  48. package/dist/mentions/Mention.js.map +1 -1
  49. package/dist/mentions/{MentionExtension.mjs → MentionExtension.cjs} +35 -33
  50. package/dist/mentions/{MentionExtension.mjs.map → MentionExtension.cjs.map} +1 -1
  51. package/dist/mentions/MentionExtension.js +32 -34
  52. package/dist/mentions/MentionExtension.js.map +1 -1
  53. package/dist/mentions/{MentionNode.mjs → MentionNode.cjs} +12 -10
  54. package/dist/mentions/{MentionNode.mjs.map → MentionNode.cjs.map} +1 -1
  55. package/dist/mentions/MentionNode.js +9 -11
  56. package/dist/mentions/MentionNode.js.map +1 -1
  57. package/dist/mentions/{MentionsList.mjs → MentionsList.cjs} +39 -35
  58. package/dist/mentions/{MentionsList.mjs.map → MentionsList.cjs.map} +1 -1
  59. package/dist/mentions/MentionsList.js +34 -38
  60. package/dist/mentions/MentionsList.js.map +1 -1
  61. package/dist/toolbar/{FloatingToolbar.mjs → FloatingToolbar.cjs} +67 -64
  62. package/dist/toolbar/{FloatingToolbar.mjs.map → FloatingToolbar.cjs.map} +1 -1
  63. package/dist/toolbar/FloatingToolbar.js +63 -66
  64. package/dist/toolbar/FloatingToolbar.js.map +1 -1
  65. package/dist/toolbar/{Toolbar.mjs → Toolbar.cjs} +116 -91
  66. package/dist/toolbar/{Toolbar.mjs.map → Toolbar.cjs.map} +1 -1
  67. package/dist/toolbar/Toolbar.js +90 -115
  68. package/dist/toolbar/Toolbar.js.map +1 -1
  69. package/dist/toolbar/shared.cjs +36 -0
  70. package/dist/toolbar/{shared.mjs.map → shared.cjs.map} +1 -1
  71. package/dist/toolbar/shared.js +12 -15
  72. package/dist/toolbar/shared.js.map +1 -1
  73. package/dist/types.cjs +39 -0
  74. package/dist/{types.mjs.map → types.cjs.map} +1 -1
  75. package/dist/types.js +8 -19
  76. package/dist/types.js.map +1 -1
  77. package/dist/{utils.mjs → utils.cjs} +23 -14
  78. package/dist/{utils.mjs.map → utils.cjs.map} +1 -1
  79. package/dist/utils.js +13 -22
  80. package/dist/utils.js.map +1 -1
  81. package/dist/version-history/{HistoryVersionPreview.mjs → HistoryVersionPreview.cjs} +36 -34
  82. package/dist/version-history/{HistoryVersionPreview.mjs.map → HistoryVersionPreview.cjs.map} +1 -1
  83. package/dist/version-history/HistoryVersionPreview.js +33 -35
  84. package/dist/version-history/HistoryVersionPreview.js.map +1 -1
  85. package/dist/version.cjs +10 -0
  86. package/dist/{version.mjs.map → version.cjs.map} +1 -1
  87. package/dist/version.js +3 -7
  88. package/dist/version.js.map +1 -1
  89. package/package.json +18 -17
  90. package/styles.css.d.cts +1 -0
  91. package/dist/ai/AiExtension.mjs.map +0 -1
  92. package/dist/context.mjs +0 -21
  93. package/dist/index.mjs +0 -15
  94. package/dist/mentions/Avatar.mjs.map +0 -1
  95. package/dist/mentions/Mention.mjs +0 -27
  96. package/dist/mentions/Mention.mjs.map +0 -1
  97. package/dist/toolbar/shared.mjs +0 -33
  98. package/dist/types.mjs +0 -28
  99. package/dist/version.mjs +0 -6
  100. /package/dist/{index.d.mts → index.d.cts} +0 -0
@@ -1,22 +1,20 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var reactDom = require('@floating-ui/react-dom');
5
- var _private$1 = require('@liveblocks/react/_private');
6
- var _private = require('@liveblocks/react-ui/_private');
7
- var react$1 = require('@tiptap/react');
8
- var cmdk = require('cmdk');
9
- var react = require('react');
10
- var reactDom$1 = require('react-dom');
11
- var classnames = require('../classnames.js');
12
- var context = require('../context.js');
13
- var utils = require('../utils.js');
14
- var AiExtension = require('./AiExtension.js');
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { hide, offset, shift, limitShift, autoUpdate, useFloating } from '@floating-ui/react-dom';
3
+ import { useLayoutEffect } from '@liveblocks/react/_private';
4
+ import { CheckIcon, UndoIcon, CrossIcon, ArrowCornerDownRightIcon, SparklesIcon, ShortcutTooltip, Button, SendIcon, WarningIcon, EditIcon, ShortenIcon, LengthenIcon, SparklesTextIcon, QuestionMarkIcon, useRefs, TooltipProvider } from '@liveblocks/react-ui/_private';
5
+ import { useEditorState } from '@tiptap/react';
6
+ import { Command, useCommandState } from 'cmdk';
7
+ import { createContext, useContext, forwardRef, useCallback, useRef, useMemo, useEffect, useState } from 'react';
8
+ import { createPortal } from 'react-dom';
9
+ import { classNames } from '../classnames.js';
10
+ import { useCurrentEditor, EditorProvider } from '../context.js';
11
+ import { getDomRangeFromSelection } from '../utils.js';
12
+ import { isContextualPromptDiffResponse, DEFAULT_STATE } from './AiExtension.js';
15
13
 
16
14
  const AI_TOOLBAR_COLLISION_PADDING = 10;
17
- const AiToolbarContext = react.createContext(null);
15
+ const AiToolbarContext = createContext(null);
18
16
  function useAiToolbarContext() {
19
- const context = react.useContext(AiToolbarContext);
17
+ const context = useContext(AiToolbarContext);
20
18
  if (!context) {
21
19
  throw new Error("useAiToolbarContext must be used within an AiToolbar");
22
20
  }
@@ -59,48 +57,48 @@ function flipToolbar() {
59
57
  }
60
58
  };
61
59
  }
62
- const AiToolbarDropdownSeparator = react.forwardRef(({ className, ...props }, forwardedRef) => {
63
- return /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Separator, {
64
- className: classnames.classNames("lb-dropdown-separator", className),
60
+ const AiToolbarDropdownSeparator = forwardRef(({ className, ...props }, forwardedRef) => {
61
+ return /* @__PURE__ */ jsx(Command.Separator, {
62
+ className: classNames("lb-dropdown-separator", className),
65
63
  ...props,
66
64
  ref: forwardedRef
67
65
  });
68
66
  });
69
- const AiToolbarSuggestionsSeparator = react.forwardRef((props, forwardedRef) => {
70
- return /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownSeparator, {
67
+ const AiToolbarSuggestionsSeparator = forwardRef((props, forwardedRef) => {
68
+ return /* @__PURE__ */ jsx(AiToolbarDropdownSeparator, {
71
69
  ref: forwardedRef,
72
70
  ...props
73
71
  });
74
72
  });
75
- const AiToolbarDropdownItem = react.forwardRef(({ children, onSelect, icon, className, ...props }, forwardedRef) => {
76
- return /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.Item, {
77
- className: classnames.classNames("lb-dropdown-item", className),
73
+ const AiToolbarDropdownItem = forwardRef(({ children, onSelect, icon, className, ...props }, forwardedRef) => {
74
+ return /* @__PURE__ */ jsxs(Command.Item, {
75
+ className: classNames("lb-dropdown-item", className),
78
76
  onSelect,
79
77
  ...props,
80
78
  ref: forwardedRef,
81
79
  children: [
82
- icon ? /* @__PURE__ */ jsxRuntime.jsx("span", {
80
+ icon ? /* @__PURE__ */ jsx("span", {
83
81
  className: "lb-icon-container",
84
82
  children: icon
85
83
  }) : null,
86
- children ? /* @__PURE__ */ jsxRuntime.jsx("span", {
84
+ children ? /* @__PURE__ */ jsx("span", {
87
85
  className: "lb-dropdown-item-label",
88
86
  children
89
87
  }) : null
90
88
  ]
91
89
  });
92
90
  });
93
- const AiToolbarSuggestionsLabel = react.forwardRef(({ children, className, ...props }, forwardedRef) => {
94
- return /* @__PURE__ */ jsxRuntime.jsx("span", {
91
+ const AiToolbarSuggestionsLabel = forwardRef(({ children, className, ...props }, forwardedRef) => {
92
+ return /* @__PURE__ */ jsx("span", {
95
93
  ref: forwardedRef,
96
- className: classnames.classNames("lb-dropdown-label", className),
94
+ className: classNames("lb-dropdown-label", className),
97
95
  ...props,
98
96
  children
99
97
  });
100
98
  });
101
- const AiToolbarSuggestion = react.forwardRef(({ prompt: manualPrompt, ...props }, forwardedRef) => {
102
- const editor = context.useCurrentEditor("Suggestion", "AiToolbar");
103
- const handleSelect = react.useCallback(
99
+ const AiToolbarSuggestion = forwardRef(({ prompt: manualPrompt, ...props }, forwardedRef) => {
100
+ const editor = useCurrentEditor("Suggestion", "AiToolbar");
101
+ const handleSelect = useCallback(
104
102
  (prompt) => {
105
103
  editor.commands.$startAiToolbarThinking(
106
104
  manualPrompt ?? prompt
@@ -108,51 +106,51 @@ const AiToolbarSuggestion = react.forwardRef(({ prompt: manualPrompt, ...props }
108
106
  },
109
107
  [editor, manualPrompt]
110
108
  );
111
- return /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
109
+ return /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
112
110
  ...props,
113
111
  onSelect: handleSelect,
114
112
  ref: forwardedRef
115
113
  });
116
114
  });
117
115
  function AiToolbarReviewingSuggestions() {
118
- const editor = context.useCurrentEditor("ReviewingSuggestions", "AiToolbar");
116
+ const editor = useCurrentEditor("ReviewingSuggestions", "AiToolbar");
119
117
  const { state } = useAiToolbarContext();
120
118
  const { response } = state;
121
- if (AiExtension.isContextualPromptDiffResponse(response)) {
122
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
119
+ if (isContextualPromptDiffResponse(response)) {
120
+ return /* @__PURE__ */ jsxs(Fragment, {
123
121
  children: [
124
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
125
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.CheckIcon, {}),
122
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
123
+ icon: /* @__PURE__ */ jsx(CheckIcon, {}),
126
124
  onSelect: editor.commands.$acceptAiToolbarResponse,
127
125
  children: "Accept"
128
126
  }),
129
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
130
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.UndoIcon, {}),
127
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
128
+ icon: /* @__PURE__ */ jsx(UndoIcon, {}),
131
129
  onSelect: editor.commands.$startAiToolbarThinking,
132
130
  children: "Try again"
133
131
  }),
134
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
135
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.CrossIcon, {}),
132
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
133
+ icon: /* @__PURE__ */ jsx(CrossIcon, {}),
136
134
  onSelect: editor.commands.$closeAiToolbar,
137
135
  children: "Discard"
138
136
  })
139
137
  ]
140
138
  });
141
139
  } else {
142
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
140
+ return /* @__PURE__ */ jsxs(Fragment, {
143
141
  children: [
144
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
145
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.ArrowCornerDownRightIcon, {}),
142
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
143
+ icon: /* @__PURE__ */ jsx(ArrowCornerDownRightIcon, {}),
146
144
  onSelect: editor.commands.$acceptAiToolbarResponse,
147
145
  children: "Insert below"
148
146
  }),
149
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
150
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.UndoIcon, {}),
147
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
148
+ icon: /* @__PURE__ */ jsx(UndoIcon, {}),
151
149
  onSelect: editor.commands.$startAiToolbarThinking,
152
150
  children: "Try again"
153
151
  }),
154
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarDropdownItem, {
155
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.CrossIcon, {}),
152
+ /* @__PURE__ */ jsx(AiToolbarDropdownItem, {
153
+ icon: /* @__PURE__ */ jsx(CrossIcon, {}),
156
154
  onSelect: editor.commands.$closeAiToolbar,
157
155
  children: "Discard"
158
156
  })
@@ -161,16 +159,16 @@ function AiToolbarReviewingSuggestions() {
161
159
  }
162
160
  }
163
161
  function AiToolbarCustomPromptContent() {
164
- const editor = context.useCurrentEditor("CustomPromptContent", "AiToolbar");
162
+ const editor = useCurrentEditor("CustomPromptContent", "AiToolbar");
165
163
  const aiName = editor.storage.liveblocksAi.name;
166
- const textAreaRef = react.useRef(null);
164
+ const textAreaRef = useRef(null);
167
165
  const { state, dropdownRef, isDropdownHidden } = useAiToolbarContext();
168
166
  const { customPrompt } = state;
169
- const isCustomPromptEmpty = react.useMemo(
167
+ const isCustomPromptEmpty = useMemo(
170
168
  () => customPrompt.trim() === "",
171
169
  [customPrompt]
172
170
  );
173
- _private$1.useLayoutEffect(
171
+ useLayoutEffect(
174
172
  () => {
175
173
  setTimeout(() => {
176
174
  const textArea = textAreaRef.current;
@@ -209,7 +207,7 @@ function AiToolbarCustomPromptContent() {
209
207
  }
210
208
  }
211
209
  };
212
- const handleCustomPromptChange = react.useCallback(
210
+ const handleCustomPromptChange = useCallback(
213
211
  (customPrompt2) => {
214
212
  editor.commands._updateAiToolbarCustomPrompt(
215
213
  customPrompt2
@@ -217,7 +215,7 @@ function AiToolbarCustomPromptContent() {
217
215
  },
218
216
  [editor]
219
217
  );
220
- const handleSendClick = react.useCallback(() => {
218
+ const handleSendClick = useCallback(() => {
221
219
  if (isCustomPromptEmpty) {
222
220
  return;
223
221
  }
@@ -226,21 +224,21 @@ function AiToolbarCustomPromptContent() {
226
224
  state.phase === "reviewing"
227
225
  );
228
226
  }, [editor, customPrompt, isCustomPromptEmpty, state.phase]);
229
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
227
+ return /* @__PURE__ */ jsxs("div", {
230
228
  className: "lb-tiptap-ai-toolbar-content",
231
229
  children: [
232
- /* @__PURE__ */ jsxRuntime.jsx("span", {
230
+ /* @__PURE__ */ jsx("span", {
233
231
  className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container",
234
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.SparklesIcon, {})
232
+ children: /* @__PURE__ */ jsx(SparklesIcon, {})
235
233
  }),
236
- /* @__PURE__ */ jsxRuntime.jsx("div", {
234
+ /* @__PURE__ */ jsx("div", {
237
235
  className: "lb-tiptap-ai-toolbar-custom-prompt-container",
238
236
  "data-value": customPrompt,
239
- children: /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Input, {
237
+ children: /* @__PURE__ */ jsx(Command.Input, {
240
238
  value: customPrompt,
241
239
  onValueChange: handleCustomPromptChange,
242
240
  asChild: true,
243
- children: /* @__PURE__ */ jsxRuntime.jsx("textarea", {
241
+ children: /* @__PURE__ */ jsx("textarea", {
244
242
  ref: textAreaRef,
245
243
  className: "lb-tiptap-ai-toolbar-custom-prompt",
246
244
  placeholder: `Ask ${aiName} anything\u2026`,
@@ -250,16 +248,16 @@ function AiToolbarCustomPromptContent() {
250
248
  })
251
249
  })
252
250
  }),
253
- /* @__PURE__ */ jsxRuntime.jsx("div", {
251
+ /* @__PURE__ */ jsx("div", {
254
252
  className: "lb-tiptap-ai-toolbar-actions",
255
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.ShortcutTooltip, {
253
+ children: /* @__PURE__ */ jsx(ShortcutTooltip, {
256
254
  content: `Ask ${aiName}`,
257
255
  shortcut: "Enter",
258
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.Button, {
256
+ children: /* @__PURE__ */ jsx(Button, {
259
257
  className: "lb-tiptap-ai-toolbar-action",
260
258
  variant: "primary",
261
259
  "aria-label": `Ask ${aiName}`,
262
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.SendIcon, {}),
260
+ icon: /* @__PURE__ */ jsx(SendIcon, {}),
263
261
  disabled: isCustomPromptEmpty,
264
262
  onClick: handleSendClick
265
263
  })
@@ -271,15 +269,15 @@ function AiToolbarCustomPromptContent() {
271
269
  function AiToolbarAsking() {
272
270
  const { state } = useAiToolbarContext();
273
271
  const { error } = state;
274
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
272
+ return /* @__PURE__ */ jsxs(Fragment, {
275
273
  children: [
276
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarCustomPromptContent, {}),
277
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
274
+ /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {}),
275
+ error ? /* @__PURE__ */ jsxs("div", {
278
276
  className: "lb-tiptap-ai-toolbar-error",
279
277
  children: [
280
- /* @__PURE__ */ jsxRuntime.jsx("span", {
278
+ /* @__PURE__ */ jsx("span", {
281
279
  className: "lb-icon-container",
282
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.WarningIcon, {})
280
+ children: /* @__PURE__ */ jsx(WarningIcon, {})
283
281
  }),
284
282
  "There was a problem with your request."
285
283
  ]
@@ -288,43 +286,43 @@ function AiToolbarAsking() {
288
286
  });
289
287
  }
290
288
  function AiToolbarThinking() {
291
- const editor = context.useCurrentEditor("AiToolbarThinking", "AiToolbar");
292
- const contentRef = react.useRef(null);
289
+ const editor = useCurrentEditor("AiToolbarThinking", "AiToolbar");
290
+ const contentRef = useRef(null);
293
291
  const aiName = editor.storage.liveblocksAi.name;
294
- const handleCancel = react.useCallback(() => {
292
+ const handleCancel = useCallback(() => {
295
293
  editor.commands.$cancelAiToolbarThinking();
296
294
  }, [editor]);
297
- _private$1.useLayoutEffect(() => {
295
+ useLayoutEffect(() => {
298
296
  contentRef.current?.focus();
299
297
  window.getSelection()?.removeAllRanges();
300
298
  }, []);
301
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
302
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
299
+ return /* @__PURE__ */ jsx(Fragment, {
300
+ children: /* @__PURE__ */ jsxs("div", {
303
301
  className: "lb-tiptap-ai-toolbar-content",
304
302
  tabIndex: 0,
305
303
  ref: contentRef,
306
304
  children: [
307
- /* @__PURE__ */ jsxRuntime.jsx("span", {
305
+ /* @__PURE__ */ jsx("span", {
308
306
  className: "lb-icon-container lb-tiptap-ai-toolbar-icon-container",
309
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.SparklesIcon, {})
307
+ children: /* @__PURE__ */ jsx(SparklesIcon, {})
310
308
  }),
311
- /* @__PURE__ */ jsxRuntime.jsxs("div", {
309
+ /* @__PURE__ */ jsxs("div", {
312
310
  className: "lb-tiptap-ai-toolbar-thinking",
313
311
  children: [
314
312
  aiName,
315
313
  " is thinking\u2026"
316
314
  ]
317
315
  }),
318
- /* @__PURE__ */ jsxRuntime.jsx("div", {
316
+ /* @__PURE__ */ jsx("div", {
319
317
  className: "lb-tiptap-ai-toolbar-actions",
320
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.ShortcutTooltip, {
318
+ children: /* @__PURE__ */ jsx(ShortcutTooltip, {
321
319
  content: "Cancel",
322
320
  shortcut: "Escape",
323
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.Button, {
321
+ children: /* @__PURE__ */ jsx(Button, {
324
322
  className: "lb-tiptap-ai-toolbar-action",
325
323
  variant: "secondary",
326
324
  "aria-label": "Cancel",
327
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.UndoIcon, {}),
325
+ icon: /* @__PURE__ */ jsx(UndoIcon, {}),
328
326
  onClick: handleCancel
329
327
  })
330
328
  })
@@ -336,16 +334,16 @@ function AiToolbarThinking() {
336
334
  function AiToolbarReviewing() {
337
335
  const { state } = useAiToolbarContext();
338
336
  const { response } = state;
339
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
337
+ return /* @__PURE__ */ jsxs(Fragment, {
340
338
  children: [
341
- response.type === "other" ? /* @__PURE__ */ jsxRuntime.jsx("div", {
339
+ response.type === "other" ? /* @__PURE__ */ jsx("div", {
342
340
  className: "lb-tiptap-ai-toolbar-response-container",
343
- children: /* @__PURE__ */ jsxRuntime.jsx("div", {
341
+ children: /* @__PURE__ */ jsx("div", {
344
342
  className: "lb-tiptap-ai-toolbar-response",
345
343
  children: response.text
346
344
  })
347
345
  }) : null,
348
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarCustomPromptContent, {})
346
+ /* @__PURE__ */ jsx(AiToolbarCustomPromptContent, {})
349
347
  ]
350
348
  });
351
349
  }
@@ -355,17 +353,17 @@ function AiToolbarContainer({
355
353
  dropdownRef,
356
354
  children
357
355
  }) {
358
- const editor = context.useCurrentEditor("AiToolbarContainer", "AiToolbar");
356
+ const editor = useCurrentEditor("AiToolbarContainer", "AiToolbar");
359
357
  const customPrompt = state.customPrompt;
360
- const isCustomPromptMultiline = react.useMemo(
358
+ const isCustomPromptMultiline = useMemo(
361
359
  () => customPrompt?.includes("\n"),
362
360
  [customPrompt]
363
361
  );
364
- const hasDropdownItems = cmdk.useCommandState(
362
+ const hasDropdownItems = useCommandState(
365
363
  (state2) => state2.filtered.count > 0
366
364
  );
367
365
  const isDropdownHidden = isCustomPromptMultiline || !hasDropdownItems;
368
- react.useEffect(() => {
366
+ useEffect(() => {
369
367
  if (!editor) {
370
368
  return;
371
369
  }
@@ -385,7 +383,7 @@ function AiToolbarContainer({
385
383
  document.removeEventListener("keydown", handleKeyDown);
386
384
  };
387
385
  }, [editor, state.phase]);
388
- return /* @__PURE__ */ jsxRuntime.jsxs(AiToolbarContext.Provider, {
386
+ return /* @__PURE__ */ jsxs(AiToolbarContext.Provider, {
389
387
  value: {
390
388
  state,
391
389
  toolbarRef,
@@ -393,74 +391,74 @@ function AiToolbarContainer({
393
391
  isDropdownHidden
394
392
  },
395
393
  children: [
396
- /* @__PURE__ */ jsxRuntime.jsxs("div", {
394
+ /* @__PURE__ */ jsxs("div", {
397
395
  className: "lb-tiptap-ai-toolbar-container",
398
396
  children: [
399
- /* @__PURE__ */ jsxRuntime.jsx("div", {
397
+ /* @__PURE__ */ jsx("div", {
400
398
  className: "lb-elevation lb-tiptap-ai-toolbar",
401
- children: state.phase === "asking" ? /* @__PURE__ */ jsxRuntime.jsx(AiToolbarAsking, {}) : state.phase === "thinking" ? /* @__PURE__ */ jsxRuntime.jsx(AiToolbarThinking, {}) : state.phase === "reviewing" ? /* @__PURE__ */ jsxRuntime.jsx(AiToolbarReviewing, {}) : null
399
+ children: state.phase === "asking" ? /* @__PURE__ */ jsx(AiToolbarAsking, {}) : state.phase === "thinking" ? /* @__PURE__ */ jsx(AiToolbarThinking, {}) : state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewing, {}) : null
402
400
  }),
403
- /* @__PURE__ */ jsxRuntime.jsxs("div", {
401
+ /* @__PURE__ */ jsxs("div", {
404
402
  className: "lb-tiptap-ai-toolbar-halo",
405
403
  "data-active": state.phase === "thinking" ? "" : void 0,
406
404
  "aria-hidden": true,
407
405
  children: [
408
- /* @__PURE__ */ jsxRuntime.jsx("div", {
406
+ /* @__PURE__ */ jsx("div", {
409
407
  className: "lb-tiptap-ai-toolbar-halo-horizontal"
410
408
  }),
411
- /* @__PURE__ */ jsxRuntime.jsx("div", {
409
+ /* @__PURE__ */ jsx("div", {
412
410
  className: "lb-tiptap-ai-toolbar-halo-vertical"
413
411
  })
414
412
  ]
415
413
  })
416
414
  ]
417
415
  }),
418
- state.phase === "asking" || state.phase === "reviewing" ? /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.List, {
416
+ state.phase === "asking" || state.phase === "reviewing" ? /* @__PURE__ */ jsx(Command.List, {
419
417
  className: "lb-elevation lb-dropdown lb-tiptap-ai-toolbar-dropdown",
420
418
  "data-hidden": isDropdownHidden ? "" : void 0,
421
419
  ref: dropdownRef,
422
- children: state.phase === "reviewing" ? /* @__PURE__ */ jsxRuntime.jsx(AiToolbarReviewingSuggestions, {}) : children
420
+ children: state.phase === "reviewing" ? /* @__PURE__ */ jsx(AiToolbarReviewingSuggestions, {}) : children
423
421
  }) : null
424
422
  ]
425
423
  });
426
424
  }
427
- const defaultSuggestions = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
425
+ const defaultSuggestions = /* @__PURE__ */ jsxs(Fragment, {
428
426
  children: [
429
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
430
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.EditIcon, {}),
427
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
428
+ icon: /* @__PURE__ */ jsx(EditIcon, {}),
431
429
  prompt: "Improve the quality of the text",
432
430
  children: "Improve writing"
433
431
  }),
434
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
435
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.CheckIcon, {}),
432
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
433
+ icon: /* @__PURE__ */ jsx(CheckIcon, {}),
436
434
  prompt: "Fix spelling & grammar errors in the text",
437
435
  children: "Fix mistakes"
438
436
  }),
439
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
440
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.ShortenIcon, {}),
437
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
438
+ icon: /* @__PURE__ */ jsx(ShortenIcon, {}),
441
439
  prompt: "Shorten the text, simplifying it",
442
440
  children: "Simplify"
443
441
  }),
444
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
445
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.LengthenIcon, {}),
442
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
443
+ icon: /* @__PURE__ */ jsx(LengthenIcon, {}),
446
444
  prompt: "Lengthen the text, going into more detail",
447
445
  children: "Add more detail"
448
446
  }),
449
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestionsSeparator, {}),
450
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
451
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.SparklesTextIcon, {}),
447
+ /* @__PURE__ */ jsx(AiToolbarSuggestionsSeparator, {}),
448
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
449
+ icon: /* @__PURE__ */ jsx(SparklesTextIcon, {}),
452
450
  prompt: "Continue writing from the text's end",
453
451
  children: "Continue writing"
454
452
  }),
455
- /* @__PURE__ */ jsxRuntime.jsx(AiToolbarSuggestion, {
456
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.QuestionMarkIcon, {}),
453
+ /* @__PURE__ */ jsx(AiToolbarSuggestion, {
454
+ icon: /* @__PURE__ */ jsx(QuestionMarkIcon, {}),
457
455
  prompt: "Explain what the text is about",
458
456
  children: "Explain"
459
457
  })
460
458
  ]
461
459
  });
462
460
  const AiToolbar = Object.assign(
463
- react.forwardRef(
461
+ forwardRef(
464
462
  ({
465
463
  offset: sideOffset = 6,
466
464
  editor,
@@ -468,14 +466,14 @@ const AiToolbar = Object.assign(
468
466
  suggestions: Suggestions = defaultSuggestions,
469
467
  ...props
470
468
  }, forwardedRef) => {
471
- const state = react$1.useEditorState({
469
+ const state = useEditorState({
472
470
  editor,
473
471
  selector: (ctx) => {
474
472
  return ctx.editor?.storage.liveblocksAi?.state;
475
473
  }
476
- }) ?? AiExtension.DEFAULT_STATE;
474
+ }) ?? DEFAULT_STATE;
477
475
  const selection = editor?.state.selection;
478
- const floatingOptions = react.useMemo(() => {
476
+ const floatingOptions = useMemo(() => {
479
477
  const detectOverflowOptions = {
480
478
  padding: AI_TOOLBAR_COLLISION_PADDING
481
479
  };
@@ -484,18 +482,18 @@ const AiToolbar = Object.assign(
484
482
  placement: "bottom",
485
483
  middleware: [
486
484
  tiptapFloating(editor),
487
- reactDom.hide(detectOverflowOptions),
488
- reactDom.offset(sideOffset),
489
- reactDom.shift({
485
+ hide(detectOverflowOptions),
486
+ offset(sideOffset),
487
+ shift({
490
488
  ...detectOverflowOptions,
491
489
  mainAxis: false,
492
490
  crossAxis: true,
493
- limiter: reactDom.limitShift()
491
+ limiter: limitShift()
494
492
  }),
495
493
  flipToolbar()
496
494
  ],
497
495
  whileElementsMounted: (...args) => {
498
- return reactDom.autoUpdate(...args, {
496
+ return autoUpdate(...args, {
499
497
  animationFrame: true
500
498
  });
501
499
  }
@@ -508,20 +506,20 @@ const AiToolbar = Object.assign(
508
506
  x,
509
507
  y,
510
508
  isPositioned
511
- } = reactDom.useFloating({
509
+ } = useFloating({
512
510
  ...floatingOptions,
513
511
  open: isOpen
514
512
  });
515
- const toolbarRef = react.useRef(null);
516
- const mergedRefs = _private.useRefs(forwardedRef, toolbarRef, setFloating);
517
- const dropdownRef = react.useRef(null);
518
- const [selectedDropdownValue, setSelectedDropdownValue] = react.useState("");
519
- react.useEffect(() => {
513
+ const toolbarRef = useRef(null);
514
+ const mergedRefs = useRefs(forwardedRef, toolbarRef, setFloating);
515
+ const dropdownRef = useRef(null);
516
+ const [selectedDropdownValue, setSelectedDropdownValue] = useState("");
517
+ useEffect(() => {
520
518
  if (state.phase === "closed") {
521
519
  setSelectedDropdownValue("");
522
520
  }
523
521
  }, [state.phase]);
524
- react.useEffect(() => {
522
+ useEffect(() => {
525
523
  if (state.phase === "closed") {
526
524
  setSelectedDropdownValue("");
527
525
  return;
@@ -537,7 +535,7 @@ const AiToolbar = Object.assign(
537
535
  firstDropdownItem?.dataset.value ?? ""
538
536
  );
539
537
  }, [state.phase, dropdownRef, setSelectedDropdownValue]);
540
- react.useEffect(() => {
538
+ useEffect(() => {
541
539
  if (!editor) {
542
540
  return;
543
541
  }
@@ -545,13 +543,13 @@ const AiToolbar = Object.assign(
545
543
  editor.commands.$closeAiToolbar();
546
544
  }
547
545
  }, [state.phase, editor, selection]);
548
- _private$1.useLayoutEffect(() => {
546
+ useLayoutEffect(() => {
549
547
  if (!editor || !isOpen) {
550
548
  return;
551
549
  }
552
550
  setReference(null);
553
551
  setTimeout(() => {
554
- if (state.phase === "reviewing" && AiExtension.isContextualPromptDiffResponse(state.response)) {
552
+ if (state.phase === "reviewing" && isContextualPromptDiffResponse(state.response)) {
555
553
  const changes = editor.view.dom.querySelectorAll(
556
554
  "ychange[data-liveblocks]"
557
555
  );
@@ -578,7 +576,7 @@ const AiToolbar = Object.assign(
578
576
  }
579
577
  });
580
578
  } else if (selection) {
581
- const domRange = utils.getDomRangeFromSelection(editor, selection);
579
+ const domRange = getDomRangeFromSelection(editor, selection);
582
580
  setReference(domRange);
583
581
  } else {
584
582
  setReference(null);
@@ -592,7 +590,7 @@ const AiToolbar = Object.assign(
592
590
  state.phase,
593
591
  state.response
594
592
  ]);
595
- react.useEffect(() => {
593
+ useEffect(() => {
596
594
  if (!editor || !isOpen) {
597
595
  return;
598
596
  }
@@ -614,15 +612,15 @@ const AiToolbar = Object.assign(
614
612
  if (!editor || !isOpen) {
615
613
  return null;
616
614
  }
617
- return reactDom$1.createPortal(
618
- /* @__PURE__ */ jsxRuntime.jsx(_private.TooltipProvider, {
619
- children: /* @__PURE__ */ jsxRuntime.jsx(context.EditorProvider, {
615
+ return createPortal(
616
+ /* @__PURE__ */ jsx(TooltipProvider, {
617
+ children: /* @__PURE__ */ jsx(EditorProvider, {
620
618
  editor,
621
- children: /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command, {
619
+ children: /* @__PURE__ */ jsx(Command, {
622
620
  role: "toolbar",
623
621
  label: "AI toolbar",
624
622
  "aria-orientation": "horizontal",
625
- className: classnames.classNames(
623
+ className: classNames(
626
624
  "lb-root lb-portal lb-tiptap-ai-toolbar-portal",
627
625
  className
628
626
  ),
@@ -636,11 +634,11 @@ const AiToolbar = Object.assign(
636
634
  value: selectedDropdownValue,
637
635
  onValueChange: setSelectedDropdownValue,
638
636
  ...props,
639
- children: /* @__PURE__ */ jsxRuntime.jsx(AiToolbarContainer, {
637
+ children: /* @__PURE__ */ jsx(AiToolbarContainer, {
640
638
  state,
641
639
  dropdownRef,
642
640
  toolbarRef,
643
- children: typeof Suggestions === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Suggestions, {
641
+ children: typeof Suggestions === "function" ? /* @__PURE__ */ jsx(Suggestions, {
644
642
  children: defaultSuggestions
645
643
  }) : Suggestions
646
644
  })
@@ -658,6 +656,5 @@ const AiToolbar = Object.assign(
658
656
  }
659
657
  );
660
658
 
661
- exports.AI_TOOLBAR_COLLISION_PADDING = AI_TOOLBAR_COLLISION_PADDING;
662
- exports.AiToolbar = AiToolbar;
659
+ export { AI_TOOLBAR_COLLISION_PADDING, AiToolbar };
663
660
  //# sourceMappingURL=AiToolbar.js.map