@liveblocks/react-tiptap 2.18.2 → 2.18.4-uns1

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