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