@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.
- package/dist/LiveblocksExtension.cjs +7 -3
- package/dist/LiveblocksExtension.cjs.map +1 -1
- package/dist/LiveblocksExtension.js +7 -3
- package/dist/LiveblocksExtension.js.map +1 -1
- package/dist/ai/AiExtension.cjs +8 -0
- package/dist/ai/AiExtension.cjs.map +1 -1
- package/dist/ai/AiExtension.js +8 -0
- package/dist/ai/AiExtension.js.map +1 -1
- package/dist/ai/AiToolbar.cjs +256 -235
- package/dist/ai/AiToolbar.cjs.map +1 -1
- package/dist/ai/AiToolbar.js +256 -235
- package/dist/ai/AiToolbar.js.map +1 -1
- package/dist/comments/AnchoredThreads.cjs +63 -50
- package/dist/comments/AnchoredThreads.cjs.map +1 -1
- package/dist/comments/AnchoredThreads.js +63 -50
- package/dist/comments/AnchoredThreads.js.map +1 -1
- package/dist/comments/CommentsExtension.cjs +3 -0
- package/dist/comments/CommentsExtension.cjs.map +1 -1
- package/dist/comments/CommentsExtension.js +3 -0
- package/dist/comments/CommentsExtension.js.map +1 -1
- package/dist/comments/FloatingComposer.cjs +32 -22
- package/dist/comments/FloatingComposer.cjs.map +1 -1
- package/dist/comments/FloatingComposer.js +32 -22
- package/dist/comments/FloatingComposer.js.map +1 -1
- package/dist/comments/FloatingThreads.cjs +39 -33
- package/dist/comments/FloatingThreads.cjs.map +1 -1
- package/dist/comments/FloatingThreads.js +39 -33
- package/dist/comments/FloatingThreads.js.map +1 -1
- package/dist/context.cjs +1 -4
- package/dist/context.cjs.map +1 -1
- package/dist/context.js +1 -4
- package/dist/context.js.map +1 -1
- package/dist/index.d.cts +135 -4
- package/dist/index.d.ts +135 -4
- package/dist/mentions/GroupMentionNode.cjs +2 -0
- package/dist/mentions/GroupMentionNode.cjs.map +1 -1
- package/dist/mentions/GroupMentionNode.js +2 -0
- package/dist/mentions/GroupMentionNode.js.map +1 -1
- package/dist/mentions/Mention.cjs +35 -42
- package/dist/mentions/Mention.cjs.map +1 -1
- package/dist/mentions/Mention.js +34 -41
- package/dist/mentions/Mention.js.map +1 -1
- package/dist/mentions/MentionExtension.cjs +1 -0
- package/dist/mentions/MentionExtension.cjs.map +1 -1
- package/dist/mentions/MentionExtension.js +1 -0
- package/dist/mentions/MentionExtension.js.map +1 -1
- package/dist/mentions/MentionNode.cjs +2 -0
- package/dist/mentions/MentionNode.cjs.map +1 -1
- package/dist/mentions/MentionNode.js +2 -0
- package/dist/mentions/MentionNode.js.map +1 -1
- package/dist/mentions/MentionsList.cjs +66 -51
- package/dist/mentions/MentionsList.cjs.map +1 -1
- package/dist/mentions/MentionsList.js +66 -51
- package/dist/mentions/MentionsList.js.map +1 -1
- package/dist/toolbar/FloatingToolbar.cjs +43 -28
- package/dist/toolbar/FloatingToolbar.cjs.map +1 -1
- package/dist/toolbar/FloatingToolbar.js +43 -28
- package/dist/toolbar/FloatingToolbar.js.map +1 -1
- package/dist/toolbar/Toolbar.cjs +191 -153
- package/dist/toolbar/Toolbar.cjs.map +1 -1
- package/dist/toolbar/Toolbar.js +191 -153
- package/dist/toolbar/Toolbar.js.map +1 -1
- package/dist/toolbar/shared.cjs +12 -11
- package/dist/toolbar/shared.cjs.map +1 -1
- package/dist/toolbar/shared.js +12 -11
- package/dist/toolbar/shared.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/version-history/HistoryVersionPreview.cjs +30 -42
- package/dist/version-history/HistoryVersionPreview.cjs.map +1 -1
- package/dist/version-history/HistoryVersionPreview.js +30 -42
- package/dist/version-history/HistoryVersionPreview.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +14 -14
- package/src/styles/index.css +3 -2
- package/styles.css +1 -1
- package/styles.css.map +1 -1
package/dist/ai/AiToolbar.js
CHANGED
|
@@ -57,43 +57,43 @@ function flipToolbar() {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
const AiToolbarDropdownSeparator = forwardRef(({ className, ...props }, forwardedRef) => {
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
children: icon
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
339
|
-
|
|
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(
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
children: [
|
|
396
|
-
/* @__PURE__ */ jsx("div", {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
-
|
|
426
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
447
|
-
|
|
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
|
-
|
|
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
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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
|
-
|
|
642
|
-
|
|
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
|
);
|