payload-richtext-tiptap 0.0.46 → 0.0.47
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/src/fields/TiptapEditor/extensions/AICommand/AIMenuList.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AIMenuList.js +10 -123
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AIMenuList.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.js +26 -33
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +5 -5
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts +4 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js +196 -69
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js +5 -3
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,20 +2,27 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useCompletion } from "ai/react";
|
|
4
4
|
import { ArrowUpCircle, Sparkles } from "lucide-react";
|
|
5
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
6
6
|
import Markdown from "react-markdown";
|
|
7
7
|
import TextareaAutosize from "react-textarea-autosize";
|
|
8
8
|
import { useLocale } from "@payloadcms/ui/providers/Locale";
|
|
9
9
|
import { getPrevText } from "../../../lib/utils/index.js";
|
|
10
10
|
import { isRTL } from "../../../lib/utils/isRtl.js";
|
|
11
11
|
import CrazySpinner from "../../ui/crazy-spinner.js";
|
|
12
|
+
import { DropdownButton } from "../../ui/Dropdown/Dropdown.js";
|
|
13
|
+
import { Icon } from "../../ui/Icon.js";
|
|
12
14
|
import { ScrollArea } from "../../ui/scroll-area.js";
|
|
13
15
|
import { Surface } from "../../ui/Surface.js";
|
|
14
16
|
import { Toolbar } from "../../ui/Toolbar.js";
|
|
15
|
-
|
|
17
|
+
import AISelectorCommands from "../../menus/TextMenu/components/ai-selector-commands.js";
|
|
18
|
+
export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange, userPrompt, items, ...restProps }, ref)=>{
|
|
16
19
|
const [inputValue, setInputValue] = useState(userPrompt ?? "");
|
|
17
20
|
const { code } = useLocale();
|
|
18
21
|
const { view } = editor;
|
|
22
|
+
const scrollContainer = useRef(null);
|
|
23
|
+
const activeItem = useRef(null);
|
|
24
|
+
const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);
|
|
25
|
+
const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
|
|
19
26
|
const editorNode = view.dom;
|
|
20
27
|
const boundigClient = editorNode.getBoundingClientRect();
|
|
21
28
|
const inputRef = useRef(null);
|
|
@@ -90,78 +97,198 @@ export const AICommandPanel = ({ editor, onOpenChange, userPrompt, ...restProps
|
|
|
90
97
|
completion,
|
|
91
98
|
isLoading
|
|
92
99
|
]);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
// Anytime the groups change, i.e. the user types to narrow it down, we want to
|
|
101
|
+
// reset the current selection to the first menu item
|
|
102
|
+
useEffect(()=>{
|
|
103
|
+
setSelectedGroupIndex(0);
|
|
104
|
+
setSelectedCommandIndex(0);
|
|
105
|
+
}, [
|
|
106
|
+
items
|
|
107
|
+
]);
|
|
108
|
+
const selectItem = useCallback((groupIndex, commandIndex)=>{
|
|
109
|
+
const command = items[groupIndex].commands[commandIndex];
|
|
110
|
+
setInputValue(command.action(editor));
|
|
111
|
+
// props.command(command);
|
|
112
|
+
}, [
|
|
113
|
+
items,
|
|
114
|
+
editor
|
|
115
|
+
]);
|
|
116
|
+
useImperativeHandle(ref, ()=>({
|
|
117
|
+
onKeyDown: ({ event })=>{
|
|
118
|
+
if (event.key === "ArrowDown") {
|
|
119
|
+
if (!items.length) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const commands = items[selectedGroupIndex].commands;
|
|
123
|
+
let newCommandIndex = selectedCommandIndex + 1;
|
|
124
|
+
let newGroupIndex = selectedGroupIndex;
|
|
125
|
+
if (commands.length - 1 < newCommandIndex) {
|
|
126
|
+
newCommandIndex = 0;
|
|
127
|
+
newGroupIndex = selectedGroupIndex + 1;
|
|
128
|
+
}
|
|
129
|
+
if (items.length - 1 < newGroupIndex) {
|
|
130
|
+
newGroupIndex = 0;
|
|
131
|
+
}
|
|
132
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
133
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (event.key === "ArrowUp") {
|
|
137
|
+
if (!items.length) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
let newCommandIndex = selectedCommandIndex - 1;
|
|
141
|
+
let newGroupIndex = selectedGroupIndex;
|
|
142
|
+
if (newCommandIndex < 0) {
|
|
143
|
+
newGroupIndex = selectedGroupIndex - 1;
|
|
144
|
+
newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;
|
|
145
|
+
}
|
|
146
|
+
if (newGroupIndex < 0) {
|
|
147
|
+
newGroupIndex = items.length - 1;
|
|
148
|
+
newCommandIndex = items[newGroupIndex].commands.length - 1;
|
|
149
|
+
}
|
|
150
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
151
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (event.key === "Enter") {
|
|
155
|
+
if (!items.length || selectedGroupIndex === -1 || selectedCommandIndex === -1) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}));
|
|
164
|
+
useEffect(()=>{
|
|
165
|
+
if (activeItem.current && scrollContainer.current) {
|
|
166
|
+
const offsetTop = activeItem.current.offsetTop;
|
|
167
|
+
const offsetHeight = activeItem.current.offsetHeight;
|
|
168
|
+
scrollContainer.current.scrollTop = offsetTop - offsetHeight;
|
|
169
|
+
}
|
|
170
|
+
}, [
|
|
171
|
+
selectedCommandIndex,
|
|
172
|
+
selectedGroupIndex
|
|
173
|
+
]);
|
|
174
|
+
const createCommandClickHandler = useCallback((groupIndex, commandIndex)=>{
|
|
175
|
+
return ()=>{
|
|
176
|
+
selectItem(groupIndex, commandIndex);
|
|
177
|
+
};
|
|
178
|
+
}, [
|
|
179
|
+
selectItem
|
|
180
|
+
]);
|
|
181
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ _jsx(Surface, {
|
|
184
|
+
className: `p-2 min-w-[20rem] flex flex-col gap-2 w-full`,
|
|
185
|
+
style: {
|
|
186
|
+
width: boundigClient?.width
|
|
187
|
+
},
|
|
188
|
+
children: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
116
189
|
children: [
|
|
117
|
-
/*#__PURE__*/ _jsx(
|
|
118
|
-
className: "
|
|
190
|
+
hasCompletion && /*#__PURE__*/ _jsx("div", {
|
|
191
|
+
className: "flex w-full",
|
|
192
|
+
children: /*#__PURE__*/ _jsx(ScrollArea, {
|
|
193
|
+
className: "h-72 prose p-2 px-4 prose-sm w-full max-w-none",
|
|
194
|
+
dir: isRTL(completion) ? "rtl" : "ltr",
|
|
195
|
+
children: /*#__PURE__*/ _jsx(Markdown, {
|
|
196
|
+
className: "w-full",
|
|
197
|
+
children: completion
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
}),
|
|
201
|
+
isLoading && /*#__PURE__*/ _jsxs("div", {
|
|
202
|
+
className: "flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500",
|
|
203
|
+
style: {
|
|
204
|
+
width: boundigClient?.width
|
|
205
|
+
},
|
|
206
|
+
children: [
|
|
207
|
+
/*#__PURE__*/ _jsx(Sparkles, {
|
|
208
|
+
className: "mr-2 h-4 w-4 shrink-0 "
|
|
209
|
+
}),
|
|
210
|
+
"AI is thinking",
|
|
211
|
+
/*#__PURE__*/ _jsx("div", {
|
|
212
|
+
className: "ml-2 mt-1",
|
|
213
|
+
children: /*#__PURE__*/ _jsx(CrazySpinner, {})
|
|
214
|
+
})
|
|
215
|
+
]
|
|
119
216
|
}),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
217
|
+
!isLoading && /*#__PURE__*/ _jsx(_Fragment, {
|
|
218
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
219
|
+
className: "flex justify-between items-center ",
|
|
220
|
+
children: [
|
|
221
|
+
/*#__PURE__*/ _jsx(Sparkles, {
|
|
222
|
+
className: "mr-2 h-4 w-4 shrink-0 text-blue-500 "
|
|
223
|
+
}),
|
|
224
|
+
/*#__PURE__*/ _jsx(TextareaAutosize, {
|
|
225
|
+
ref: inputRef,
|
|
226
|
+
style: {
|
|
227
|
+
resize: "none"
|
|
228
|
+
},
|
|
229
|
+
className: "w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 ",
|
|
230
|
+
value: inputValue,
|
|
231
|
+
onChange: (e)=>{
|
|
232
|
+
editor.storage.aiCommand.userPrompt = e.target.value;
|
|
233
|
+
setInputValue(e.target.value);
|
|
234
|
+
},
|
|
235
|
+
placeholder: hasCompletion ? "Tell AI what to do next" : "Ask AI to edit or generate...",
|
|
236
|
+
autoFocus: true,
|
|
237
|
+
// onFocus={() => {
|
|
238
|
+
// addAIHighlight(editor)}}
|
|
239
|
+
onKeyDown: (e)=>{
|
|
240
|
+
if (e.key === "Enter") handleClick();
|
|
241
|
+
}
|
|
242
|
+
}),
|
|
243
|
+
/*#__PURE__*/ _jsx(Toolbar.Button, {
|
|
244
|
+
// size="icon"
|
|
245
|
+
// className="absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150"
|
|
246
|
+
onClick: handleClick,
|
|
247
|
+
children: /*#__PURE__*/ _jsx(ArrowUpCircle, {})
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
})
|
|
124
251
|
})
|
|
125
252
|
]
|
|
126
|
-
}),
|
|
127
|
-
!isLoading && /*#__PURE__*/ _jsx(_Fragment, {
|
|
128
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
129
|
-
className: "flex justify-between items-center ",
|
|
130
|
-
children: [
|
|
131
|
-
/*#__PURE__*/ _jsx(Sparkles, {
|
|
132
|
-
className: "mr-2 h-4 w-4 shrink-0 text-blue-500 "
|
|
133
|
-
}),
|
|
134
|
-
/*#__PURE__*/ _jsx(TextareaAutosize, {
|
|
135
|
-
ref: inputRef,
|
|
136
|
-
style: {
|
|
137
|
-
resize: "none"
|
|
138
|
-
},
|
|
139
|
-
className: "w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 ",
|
|
140
|
-
value: inputValue,
|
|
141
|
-
onChange: (e)=>{
|
|
142
|
-
editor.storage.aiCommand.userPrompt = e.target.value;
|
|
143
|
-
setInputValue(e.target.value);
|
|
144
|
-
},
|
|
145
|
-
placeholder: hasCompletion ? "Tell AI what to do next" : "Ask AI to edit or generate...",
|
|
146
|
-
autoFocus: true,
|
|
147
|
-
// onFocus={() => {
|
|
148
|
-
// addAIHighlight(editor)}}
|
|
149
|
-
onKeyDown: (e)=>{
|
|
150
|
-
if (e.key === "Enter") handleClick();
|
|
151
|
-
}
|
|
152
|
-
}),
|
|
153
|
-
/*#__PURE__*/ _jsx(Toolbar.Button, {
|
|
154
|
-
// size="icon"
|
|
155
|
-
// className="absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150"
|
|
156
|
-
onClick: handleClick,
|
|
157
|
-
children: /*#__PURE__*/ _jsx(ArrowUpCircle, {})
|
|
158
|
-
})
|
|
159
|
-
]
|
|
160
|
-
})
|
|
161
253
|
})
|
|
162
|
-
|
|
163
|
-
|
|
254
|
+
}),
|
|
255
|
+
!isLoading && /*#__PURE__*/ _jsx(Surface, {
|
|
256
|
+
ref: scrollContainer,
|
|
257
|
+
className: "text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2",
|
|
258
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
259
|
+
className: "grid grid-cols-1 gap-0.5",
|
|
260
|
+
children: hasCompletion ? /*#__PURE__*/ _jsx(AISelectorCommands, {
|
|
261
|
+
editor: editor,
|
|
262
|
+
messages: completion,
|
|
263
|
+
onSelect: (value, options)=>{
|
|
264
|
+
console.log("VALUE", value, options);
|
|
265
|
+
complete(value, {
|
|
266
|
+
body: options
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}) : items.map((group, groupIndex)=>/*#__PURE__*/ _jsxs(React.Fragment, {
|
|
270
|
+
children: [
|
|
271
|
+
/*#__PURE__*/ _jsx("div", {
|
|
272
|
+
className: "text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5",
|
|
273
|
+
children: group.title
|
|
274
|
+
}, `${group.title}`),
|
|
275
|
+
group.commands.map((command, commandIndex)=>/*#__PURE__*/ _jsxs(DropdownButton, {
|
|
276
|
+
isActive: selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex,
|
|
277
|
+
onClick: createCommandClickHandler(groupIndex, commandIndex),
|
|
278
|
+
children: [
|
|
279
|
+
/*#__PURE__*/ _jsx(Icon, {
|
|
280
|
+
icon: command.icon,
|
|
281
|
+
className: "mr-1"
|
|
282
|
+
}),
|
|
283
|
+
command.label
|
|
284
|
+
]
|
|
285
|
+
}, `${command.label}`))
|
|
286
|
+
]
|
|
287
|
+
}, `${group.title}-wrapper`))
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
]
|
|
164
291
|
});
|
|
165
|
-
};
|
|
292
|
+
});
|
|
166
293
|
|
|
167
294
|
//# sourceMappingURL=AICommandPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor, EditorContent, useEditor } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\n\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AIDraftSelectorCommands from \"../../menus/TextMenu/components/ai-draft-selector-commands.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AICommandPanel = ({\n editor,\n onOpenChange,\n userPrompt,\n ...restProps\n}: AICommandPanelProps) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n return (\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n {/* {hasCompletion ? (\n <AICompletionCommands\n editor={editor}\n onDiscard={() => {\n editor.chain().unsetHighlight().focus().run();\n onOpenChange(false);\n }}\n completion={completion}\n />\n ) : (\n <AIDraftSelectorCommands\n editor={editor}\n onSelect={(value) => {\n setInputValue(value);\n inputRef.current.focus();\n }}\n />\n )} */}\n </>\n )}\n </>\n </Surface>\n );\n};\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","useCallback","useEffect","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","ScrollArea","Surface","Toolbar","AICommandPanel","editor","onOpenChange","userPrompt","restProps","inputValue","setInputValue","code","view","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","className","style","width","div","dir","ref","resize","value","onChange","target","placeholder","autoFocus","onKeyDown","key","Button","onClick"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAAqBC,aAAa,EAAEC,QAAQ,QAAQ,eAAe;AACnE,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACjE,OAAOC,cAAc,iBAAiB;AACtC,OAAOC,sBAAsB,0BAA0B;AAEvD,SAASC,SAAS,QAAQ,kCAAkC;AAI5D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AAIpD,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,UAAU,QAA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;gCAE7BC,WAAW,CAAC1B;oCACV,IAAIA,EAAE2B,GAAG,KAAK,SAASvB;gCACzB;;0CAEF,KAAC7B,QAAQqD,MAAM;gCACb,cAAc;gCAEd,4GAA4G;gCAC5GC,SAASzB;0CAET,cAAA,KAAC3C;;;;;;;;AA0BjB,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\n\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { DropdownButton } from \"../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../ui/Icon.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n items: Group[];\n};\n\nexport const AICommandPanel = forwardRef(\n (\n {\n editor,\n onOpenChange,\n userPrompt,\n items,\n ...restProps\n }: AICommandPanelProps,\n ref\n ) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n const scrollContainer = useRef<HTMLDivElement>(null);\n const activeItem = useRef<HTMLButtonElement>(null);\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n // Anytime the groups change, i.e. the user types to narrow it down, we want to\n // reset the current selection to the first menu item\n useEffect(() => {\n setSelectedGroupIndex(0);\n setSelectedCommandIndex(0);\n }, [items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = items[groupIndex].commands[commandIndex];\n\n setInputValue(command.action(editor));\n // props.command(command);\n },\n [items, editor]\n );\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!items.length) {\n return false;\n }\n\n const commands = items[selectedGroupIndex].commands;\n\n let newCommandIndex = selectedCommandIndex + 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (commands.length - 1 < newCommandIndex) {\n newCommandIndex = 0;\n newGroupIndex = selectedGroupIndex + 1;\n }\n\n if (items.length - 1 < newGroupIndex) {\n newGroupIndex = 0;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"ArrowUp\") {\n if (!items.length) {\n return false;\n }\n\n let newCommandIndex = selectedCommandIndex - 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (newCommandIndex < 0) {\n newGroupIndex = selectedGroupIndex - 1;\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = items.length - 1;\n newCommandIndex = items[newGroupIndex].commands.length - 1;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"Enter\") {\n if (\n !items.length ||\n selectedGroupIndex === -1 ||\n selectedCommandIndex === -1\n ) {\n return false;\n }\n\n selectItem(selectedGroupIndex, selectedCommandIndex);\n\n return true;\n }\n\n return false;\n },\n }));\n\n useEffect(() => {\n if (activeItem.current && scrollContainer.current) {\n const offsetTop = activeItem.current.offsetTop;\n const offsetHeight = activeItem.current.offsetHeight;\n\n scrollContainer.current.scrollTop = offsetTop - offsetHeight;\n }\n }, [selectedCommandIndex, selectedGroupIndex]);\n\n const createCommandClickHandler = useCallback(\n (groupIndex: number, commandIndex: number) => {\n return () => {\n selectItem(groupIndex, commandIndex);\n };\n },\n [selectItem]\n );\n\n return (\n <>\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n </>\n )}\n </>\n </Surface>\n {!isLoading && (\n <Surface\n ref={scrollContainer}\n className=\"text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2\"\n >\n <div className=\"grid grid-cols-1 gap-0.5\">\n {hasCompletion ? (\n <AISelectorCommands\n editor={editor}\n messages={completion}\n onSelect={(value, options) => {\n console.log(\"VALUE\", value, options);\n complete(value, { body: options });\n }}\n />\n ) : (\n items.map((group, groupIndex: number) => (\n <React.Fragment key={`${group.title}-wrapper`}>\n <div\n className=\"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5\"\n key={`${group.title}`}\n >\n {group.title}\n </div>\n {group.commands.map(\n (command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(\n groupIndex,\n commandIndex\n )}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n )\n )}\n </React.Fragment>\n ))\n )}\n </div>\n </Surface>\n )}\n </>\n );\n }\n);\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","AISelectorCommands","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","code","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","target","placeholder","autoFocus","Button","onClick","messages","onSelect","options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EditorPanel = ({ editor, onOpenChange })=>{
|
|
|
143
143
|
},
|
|
144
144
|
completion: completion
|
|
145
145
|
}) : /*#__PURE__*/ _jsx(AISelectorCommands, {
|
|
146
|
+
messages: completion,
|
|
146
147
|
editor: editor,
|
|
147
|
-
onSelect: (value)=>{
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
onSelect: (value, options)=>{
|
|
149
|
+
complete(value, {
|
|
150
|
+
body: options
|
|
151
|
+
});
|
|
150
152
|
}
|
|
151
153
|
})
|
|
152
154
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport Markdown from \"react-markdown\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nexport type AIEditorPanelProps = {\n editor: Editor;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n const { code } = useLocale();\n const { view } = editor;\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n return (\n <Surface\n className={`p-2 min-w-[20rem] `}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea>\n <div\n className=\"prose p-2 px-4 prose-sm\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown>{completion}</Markdown>\n </div>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\">\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center\">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none\"\n value={inputValue}\n onChange={(e) => {\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowRight />\n </Toolbar.Button>\n </div>\n {hasCompletion ? (\n <AICompletionCommands\n editor={editor}\n onDiscard={() => {\n editor.chain().unsetHighlight().focus().run();\n onOpenChange(false);\n }}\n completion={completion}\n />\n ) : (\n <AISelectorCommands\n editor={editor}\n onSelect={(value) => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport Markdown from \"react-markdown\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nexport type AIEditorPanelProps = {\n editor: Editor;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n const { code } = useLocale();\n const { view } = editor;\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n return (\n <Surface\n className={`p-2 min-w-[20rem] `}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea>\n <div\n className=\"prose p-2 px-4 prose-sm\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown>{completion}</Markdown>\n </div>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\">\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center\">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none\"\n value={inputValue}\n onChange={(e) => {\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowRight />\n </Toolbar.Button>\n </div>\n {hasCompletion ? (\n <AICompletionCommands\n editor={editor}\n onDiscard={() => {\n editor.chain().unsetHighlight().focus().run();\n onOpenChange(false);\n }}\n completion={completion}\n />\n ) : (\n <AISelectorCommands\n messages={completion}\n editor={editor}\n onSelect={(value, options) => {\n complete(value, { body: options });\n }}\n />\n )}\n </>\n )}\n </>\n </Surface>\n );\n};\n"],"names":["useLocale","useCompletion","ArrowRight","Sparkles","useCallback","useRef","useState","TextareaAutosize","Markdown","getPrevText","isRTL","AICompletionCommands","AISelectorCommands","Surface","Toolbar","CrazySpinner","ScrollArea","AIEditorPanel","editor","onOpenChange","inputValue","setInputValue","code","view","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","className","style","width","div","dir","ref","value","onChange","target","placeholder","autoFocus","onKeyDown","key","Button","onClick","onDiscard","chain","unsetHighlight","focus","run","messages","onSelect","options"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,kCAAkC;AAE5D,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,eAAe;AACpD,SAASC,WAAW,EAAaC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACjE,OAAOC,sBAAsB,0BAA0B;AAEvD,OAAOC,cAAc,iBAAiB;AACtC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AACpD,OAAOC,0BAA0B,2DAA2D;AAC5F,OAAOC,wBAAwB,0DAA0D;AACzF,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,UAAU,QAAQ,0BAA0B;AAMrD,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,YAAY,EAAsB;IACxE,MAAM,CAACC,YAAYC,cAAc,GAAGf,SAAS;IAC7C,MAAM,EAAEgB,IAAI,EAAE,GAAGtB;IACjB,MAAM,EAAEuB,IAAI,EAAE,GAAGL;IAEjB,MAAMM,aAAaD,KAAKE,GAAG;IAC3B,MAAMC,gBAAgBF,WAAWG,qBAAqB;IACtD,MAAMC,WAAWvB,OAA4B;IAE7C,uFAAuF;IACvF,oBAAoB;IACpB,2BAA2B;IAC3B,gCAAgC;IAChC,qCAAqC;IACrC,yEAAyE;IACzE,gBAAgB;IAChB,QAAQ;IACR,OAAO;IACP,sBAAsB;IACtB,8BAA8B;IAC9B,OAAO;IACP,MAAM;IAEN,MAAM,EAAEwB,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAG9B,cAAc;QACxD,eAAe;QACf+B,KAAK;QACLC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