@collabchron/notiq 1.1.11 → 1.2.0

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 (152) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
  3. package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
  4. package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
  5. package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
  6. package/dist/{ExcalidrawComponent-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
  7. package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
  8. package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
  9. package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
  10. package/dist/{StoryBuilderComponent-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-MW6MAUY3.mjs → chunk-6NK5DONB.mjs} +1 -1
  14. package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
  15. package/dist/chunk-BCGD2YXP.mjs +574 -0
  16. package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
  17. package/dist/{chunk-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-YTLUQJE2.mjs → chunk-D4UBNSUW.mjs} +1 -1
  19. package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
  20. package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
  21. package/dist/{chunk-GYYLZ3MQ.mjs → chunk-IKYVBTCJ.mjs} +43 -20
  22. package/dist/chunk-IXRA5D53.mjs +10447 -0
  23. package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
  24. package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
  25. package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
  26. package/dist/{chunk-XZXGYNTY.mjs → chunk-OO42URWA.mjs} +27 -6
  27. package/dist/chunk-PBVRSNGU.mjs +129 -0
  28. package/dist/chunk-QCS57TIF.mjs +1794 -0
  29. package/dist/chunk-RNEIJRUS.mjs +60 -0
  30. package/dist/chunk-TJPTGECP.mjs +1556 -0
  31. package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
  32. package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
  33. package/dist/chunk-X4NI7EQS.mjs +282 -0
  34. package/dist/chunk-XAJ4GACN.mjs +746 -0
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/Core.d.ts +15 -2
  37. package/dist/components/editor/index.d.ts +16 -5
  38. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  39. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  40. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  41. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  42. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  43. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  44. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  45. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  46. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  47. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  48. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  49. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  50. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  51. package/dist/components/editor/utils/url.d.ts +16 -4
  52. package/dist/components/providers/AIContext.d.ts +8 -0
  53. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  54. package/dist/core/extension.d.ts +3 -1
  55. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  56. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  57. package/dist/core/index.d.ts +2 -1
  58. package/dist/core/react/NotiqContent.d.ts +4 -1
  59. package/dist/core/react/NotiqEditor.d.ts +8 -8
  60. package/dist/core/react/index.d.ts +1 -0
  61. package/dist/core/react/node-renderers.d.ts +73 -0
  62. package/dist/core/types.d.ts +1 -0
  63. package/dist/core.js +18136 -9084
  64. package/dist/core.mjs +58 -44
  65. package/dist/hooks/instructions-messages.d.ts +13 -4
  66. package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
  67. package/dist/index.js +15180 -12858
  68. package/dist/index.mjs +121 -1641
  69. package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
  70. package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
  71. package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
  72. package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
  73. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  74. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  75. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  76. package/dist/react.js +17933 -9531
  77. package/dist/react.mjs +41 -34
  78. package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
  79. package/dist/styles/notiq.css +1 -1
  80. package/package.json +2 -2
  81. package/src/styles/notiq.css +20 -0
  82. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  83. package/dist/CodeActionMenuPlugin-MRKY67ED.mjs +0 -14
  84. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  85. package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
  86. package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
  87. package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
  88. package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
  89. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  90. package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
  91. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  92. package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
  93. package/dist/SlashCommand-2TNOOUBM.mjs +0 -39
  94. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  95. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  96. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  97. package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
  98. package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
  99. package/dist/background-color-OZJCBYCT.mjs +0 -425
  100. package/dist/block-format-MTSIXWID.mjs +0 -14
  101. package/dist/chunk-2KESP7OU.mjs +0 -809
  102. package/dist/chunk-3AHNLIME.mjs +0 -1701
  103. package/dist/chunk-3IILA3IP.mjs +0 -28
  104. package/dist/chunk-4DVIYZVB.mjs +0 -193
  105. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  106. package/dist/chunk-4UMUPCDK.mjs +0 -68
  107. package/dist/chunk-6D6QLRYR.mjs +0 -238
  108. package/dist/chunk-6SRMKQSD.mjs +0 -682
  109. package/dist/chunk-ACV47ZKE.mjs +0 -201
  110. package/dist/chunk-AYNKORDO.mjs +0 -6
  111. package/dist/chunk-BGV62GC2.mjs +0 -26
  112. package/dist/chunk-D3IOUQFR.mjs +0 -441
  113. package/dist/chunk-EEBA6OAH.mjs +0 -59
  114. package/dist/chunk-EIZMKFHF.mjs +0 -32
  115. package/dist/chunk-EVPWKNE4.mjs +0 -27
  116. package/dist/chunk-FMJ7DGWP.mjs +0 -144
  117. package/dist/chunk-FYLRS4BG.mjs +0 -88
  118. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  119. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  120. package/dist/chunk-IU2N42JJ.mjs +0 -1763
  121. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  122. package/dist/chunk-K5OAFEVY.mjs +0 -191
  123. package/dist/chunk-KDA7ZYMJ.mjs +0 -431
  124. package/dist/chunk-KXRLARGI.mjs +0 -26
  125. package/dist/chunk-LAUAYRPC.mjs +0 -944
  126. package/dist/chunk-LLCP7NVE.mjs +0 -449
  127. package/dist/chunk-LU2XWLOE.mjs +0 -219
  128. package/dist/chunk-MPTE332I.mjs +0 -787
  129. package/dist/chunk-MTQZWJHR.mjs +0 -111
  130. package/dist/chunk-OXWTZV3U.mjs +0 -174
  131. package/dist/chunk-PD5K4AGP.mjs +0 -64
  132. package/dist/chunk-PFH63ZU4.mjs +0 -33
  133. package/dist/chunk-PHRVYPVM.mjs +0 -808
  134. package/dist/chunk-R7WFRENU.mjs +0 -262
  135. package/dist/chunk-RAVYEEIC.mjs +0 -36
  136. package/dist/chunk-RJQTA6HG.mjs +0 -358
  137. package/dist/chunk-SAOJHVPE.mjs +0 -153
  138. package/dist/chunk-VGAX6YEY.mjs +0 -399
  139. package/dist/chunk-W6GAJXUS.mjs +0 -334
  140. package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
  141. package/dist/chunk-XYT6XM5S.mjs +0 -496
  142. package/dist/chunk-YDDBQZ77.mjs +0 -409
  143. package/dist/chunk-YE7M2VKR.mjs +0 -132
  144. package/dist/chunk-Z6JAFF55.mjs +0 -555
  145. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  146. package/dist/color-23323E3B.mjs +0 -13
  147. package/dist/font-IJKFR4BM.mjs +0 -12
  148. package/dist/font-size-GTL6UVQL.mjs +0 -15
  149. package/dist/insert-node-MA3FXEYN.mjs +0 -245
  150. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  151. package/dist/text-align-CSDLJUDA.mjs +0 -121
  152. package/dist/text-format-6L5N3CHZ.mjs +0 -15
@@ -1,536 +0,0 @@
1
- import {
2
- Button
3
- } from "./chunk-OE5JRLCN.mjs";
4
- import {
5
- __spreadValues,
6
- init_react_shim
7
- } from "./chunk-WYCFGRFJ.mjs";
8
-
9
- // src/components/editor/plugins/AICommandBarPlugin/index.tsx
10
- init_react_shim();
11
- import { useState, useEffect, useRef, useCallback } from "react";
12
- import { createPortal } from "react-dom";
13
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
14
- import {
15
- $getSelection,
16
- $isRangeSelection,
17
- $createParagraphNode,
18
- $createTextNode,
19
- COMMAND_PRIORITY_CRITICAL,
20
- createCommand,
21
- KEY_DOWN_COMMAND
22
- } from "lexical";
23
- import {
24
- Sparkles,
25
- Loader2,
26
- Check,
27
- X,
28
- RotateCcw,
29
- CornerDownLeft,
30
- ChevronDown,
31
- Wand2,
32
- Languages,
33
- ArrowDownToLine
34
- } from "lucide-react";
35
-
36
- // src/components/editor/utils/diffUtils.ts
37
- init_react_shim();
38
- function tokenize(text) {
39
- return text.match(/\S+|\s+/g) || [];
40
- }
41
- function computeWordDiff(original, updated) {
42
- const origTokens = tokenize(original);
43
- const upTokens = tokenize(updated);
44
- const n = origTokens.length;
45
- const m = upTokens.length;
46
- if (n === 0 && m === 0) return [];
47
- if (n === 0) return [{ type: "added", text: updated }];
48
- if (m === 0) return [{ type: "removed", text: original }];
49
- if (n > 1500 || m > 1500) {
50
- return [
51
- { type: "removed", text: original },
52
- { type: "added", text: updated }
53
- ];
54
- }
55
- const dp = Array.from(
56
- { length: n + 1 },
57
- () => new Array(m + 1).fill(0)
58
- );
59
- for (let i2 = 1; i2 <= n; i2++) {
60
- for (let j2 = 1; j2 <= m; j2++) {
61
- if (origTokens[i2 - 1] === upTokens[j2 - 1]) {
62
- dp[i2][j2] = dp[i2 - 1][j2 - 1] + 1;
63
- } else {
64
- dp[i2][j2] = Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
65
- }
66
- }
67
- }
68
- const parts = [];
69
- let i = n;
70
- let j = m;
71
- while (i > 0 || j > 0) {
72
- if (i > 0 && j > 0 && origTokens[i - 1] === upTokens[j - 1]) {
73
- parts.unshift({ type: "unchanged", text: origTokens[i - 1] });
74
- i--;
75
- j--;
76
- } else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
77
- parts.unshift({ type: "added", text: upTokens[j - 1] });
78
- j--;
79
- } else if (i > 0 && (j === 0 || dp[i][j - 1] < dp[i - 1][j])) {
80
- parts.unshift({ type: "removed", text: origTokens[i - 1] });
81
- i--;
82
- }
83
- }
84
- const merged = [];
85
- for (const part of parts) {
86
- if (merged.length > 0 && merged[merged.length - 1].type === part.type) {
87
- merged[merged.length - 1].text += part.text;
88
- } else {
89
- merged.push(__spreadValues({}, part));
90
- }
91
- }
92
- return merged;
93
- }
94
-
95
- // src/components/editor/plugins/AICommandBarPlugin/index.tsx
96
- import { jsx, jsxs } from "react/jsx-runtime";
97
- var OPEN_AI_COMMAND_BAR_COMMAND = createCommand("OPEN_AI_COMMAND_BAR_COMMAND");
98
- var QUICK_ACTIONS = [
99
- { id: "ImproveWriting", label: "Improve Writing", icon: Wand2 },
100
- { id: "FixSpellingGrammar", label: "Fix Grammar & Spelling", icon: Check },
101
- { id: "MakeShort", label: "Make Shorter", icon: Sparkles },
102
- { id: "MakeLong", label: "Make Longer", icon: Sparkles },
103
- { id: "SimplifyLanguage", label: "Simplify", icon: Sparkles }
104
- ];
105
- var TONES = ["Professional", "Casual", "Direct", "Academic", "Friendly"];
106
- var LANGUAGES = ["Spanish", "French", "German", "Japanese", "Chinese", "Arabic"];
107
- function AICommandBarPlugin() {
108
- const [editor] = useLexicalComposerContext();
109
- const [isOpen, setIsOpen] = useState(false);
110
- const [coords, setCoords] = useState(null);
111
- const [prompt, setPrompt] = useState("");
112
- const [selectedText, setSelectedText] = useState("");
113
- const [streamedText, setStreamedText] = useState("");
114
- const [isGenerating, setIsGenerating] = useState(false);
115
- const [activeAction, setActiveAction] = useState(null);
116
- const [showToneMenu, setShowToneMenu] = useState(false);
117
- const [showLangMenu, setShowLangMenu] = useState(false);
118
- const containerRef = useRef(null);
119
- const inputRef = useRef(null);
120
- const abortControllerRef = useRef(null);
121
- const openBar = useCallback(
122
- (payload) => {
123
- let targetText = "";
124
- editor.getEditorState().read(() => {
125
- const selection = $getSelection();
126
- if ($isRangeSelection(selection)) {
127
- targetText = selection.getTextContent();
128
- }
129
- });
130
- const domSelection = window.getSelection();
131
- let top = 120;
132
- let left = window.innerWidth / 2 - 280;
133
- if (domSelection && domSelection.rangeCount > 0) {
134
- const rect = domSelection.getRangeAt(0).getBoundingClientRect();
135
- if (rect.width > 0 || rect.height > 0) {
136
- left = Math.max(20, Math.min(window.innerWidth - 580, rect.left + rect.width / 2 - 280));
137
- top = rect.bottom + 12;
138
- if (top + 280 > window.innerHeight) {
139
- top = Math.max(20, rect.top - 280);
140
- }
141
- }
142
- }
143
- setCoords({ top, left });
144
- setSelectedText(targetText);
145
- setPrompt((payload == null ? void 0 : payload.initialPrompt) || "");
146
- setStreamedText("");
147
- setIsGenerating(false);
148
- setActiveAction((payload == null ? void 0 : payload.action) || null);
149
- setIsOpen(true);
150
- setTimeout(() => {
151
- var _a;
152
- (_a = inputRef.current) == null ? void 0 : _a.focus();
153
- }, 50);
154
- if (payload == null ? void 0 : payload.action) {
155
- runAction(payload.action, targetText, payload.initialPrompt);
156
- }
157
- },
158
- [editor]
159
- );
160
- const closeBar = useCallback(() => {
161
- if (abortControllerRef.current) {
162
- abortControllerRef.current.abort();
163
- abortControllerRef.current = null;
164
- }
165
- setIsOpen(false);
166
- setCoords(null);
167
- setPrompt("");
168
- setSelectedText("");
169
- setStreamedText("");
170
- setIsGenerating(false);
171
- setActiveAction(null);
172
- setShowToneMenu(false);
173
- setShowLangMenu(false);
174
- }, []);
175
- const runAction = async (action, contextText, customQuestion) => {
176
- setIsGenerating(true);
177
- setStreamedText("");
178
- setActiveAction(action);
179
- if (abortControllerRef.current) {
180
- abortControllerRef.current.abort();
181
- }
182
- const controller = new AbortController();
183
- abortControllerRef.current = controller;
184
- try {
185
- const response = await fetch("/api/ai", {
186
- method: "POST",
187
- headers: { "Content-Type": "application/json" },
188
- body: JSON.stringify({
189
- action,
190
- context: contextText || "",
191
- userQuestion: customQuestion || prompt
192
- }),
193
- signal: controller.signal
194
- });
195
- if (!response.ok || !response.body) {
196
- throw new Error("Failed to contact AI service");
197
- }
198
- const reader = response.body.getReader();
199
- const decoder = new TextDecoder();
200
- let accumulated = "";
201
- while (true) {
202
- const { value, done } = await reader.read();
203
- if (done) break;
204
- const chunk = decoder.decode(value, { stream: true });
205
- accumulated += chunk;
206
- setStreamedText(accumulated);
207
- }
208
- } catch (err) {
209
- if (err.name !== "AbortError") {
210
- console.error("[Notiq AI Command Bar Error]:", err);
211
- setStreamedText("An error occurred while generating response.");
212
- }
213
- } finally {
214
- setIsGenerating(false);
215
- abortControllerRef.current = null;
216
- }
217
- };
218
- const handleAccept = () => {
219
- if (!streamedText) return;
220
- editor.update(
221
- () => {
222
- const selection = $getSelection();
223
- if ($isRangeSelection(selection)) {
224
- selection.insertRawText(streamedText);
225
- } else {
226
- const root = editor.getRootElement();
227
- if (root) {
228
- const p = $createParagraphNode();
229
- p.append($createTextNode(streamedText));
230
- selection == null ? void 0 : selection.insertNodes([p]);
231
- }
232
- }
233
- },
234
- { discrete: true }
235
- );
236
- closeBar();
237
- };
238
- const handleInsertBelow = () => {
239
- if (!streamedText) return;
240
- editor.update(
241
- () => {
242
- const selection = $getSelection();
243
- if ($isRangeSelection(selection)) {
244
- const anchor = selection.anchor.getNode();
245
- const topElement = anchor.getKey() === "root" ? anchor : anchor.getTopLevelElementOrThrow();
246
- const p = $createParagraphNode();
247
- p.append($createTextNode(streamedText));
248
- topElement.insertAfter(p);
249
- p.select();
250
- }
251
- },
252
- { discrete: true }
253
- );
254
- closeBar();
255
- };
256
- useEffect(() => {
257
- return editor.registerCommand(
258
- KEY_DOWN_COMMAND,
259
- (event) => {
260
- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
261
- event.preventDefault();
262
- if (isOpen) {
263
- closeBar();
264
- } else {
265
- openBar();
266
- }
267
- return true;
268
- }
269
- if (event.key === "Escape" && isOpen) {
270
- event.preventDefault();
271
- closeBar();
272
- return true;
273
- }
274
- return false;
275
- },
276
- COMMAND_PRIORITY_CRITICAL
277
- );
278
- }, [editor, isOpen, openBar, closeBar]);
279
- useEffect(() => {
280
- return editor.registerCommand(
281
- OPEN_AI_COMMAND_BAR_COMMAND,
282
- (payload) => {
283
- openBar(payload || void 0);
284
- return true;
285
- },
286
- COMMAND_PRIORITY_CRITICAL
287
- );
288
- }, [editor, openBar]);
289
- if (!isOpen || !coords) return null;
290
- const diffParts = selectedText && streamedText ? computeWordDiff(selectedText, streamedText) : [];
291
- return createPortal(
292
- /* @__PURE__ */ jsxs(
293
- "div",
294
- {
295
- ref: containerRef,
296
- style: {
297
- position: "fixed",
298
- top: `${coords.top}px`,
299
- left: `${coords.left}px`,
300
- zIndex: 60
301
- },
302
- className: "w-[560px] max-w-[calc(100vw-32px)] rounded-xl border border-border/80 bg-popover/95 text-popover-foreground shadow-2xl backdrop-blur-xl animate-in fade-in-0 zoom-in-95 duration-150 overflow-hidden",
303
- onMouseDown: (e) => e.stopPropagation(),
304
- children: [
305
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 border-b border-border/60 bg-muted/20", children: [
306
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10 text-primary shrink-0", children: /* @__PURE__ */ jsx(Sparkles, { className: "w-4 h-4" }) }),
307
- /* @__PURE__ */ jsx(
308
- "input",
309
- {
310
- ref: inputRef,
311
- type: "text",
312
- value: prompt,
313
- onChange: (e) => setPrompt(e.target.value),
314
- onKeyDown: (e) => {
315
- if (e.key === "Enter" && !e.shiftKey) {
316
- e.preventDefault();
317
- if (prompt.trim()) {
318
- runAction("default", selectedText, prompt);
319
- }
320
- } else if (e.key === "Escape") {
321
- closeBar();
322
- }
323
- },
324
- placeholder: selectedText ? `Ask AI to edit selection ("${selectedText.slice(0, 24)}...")...` : "Ask AI to write, generate, or continue...",
325
- className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"
326
- }
327
- ),
328
- isGenerating ? /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", disabled: true, className: "h-8 px-2 text-xs", children: [
329
- /* @__PURE__ */ jsx(Loader2, { className: "w-3.5 h-3.5 animate-spin mr-1.5" }),
330
- "Generating..."
331
- ] }) : /* @__PURE__ */ jsxs(
332
- Button,
333
- {
334
- size: "sm",
335
- variant: "default",
336
- disabled: !prompt.trim() && !activeAction,
337
- onClick: () => runAction("default", selectedText, prompt),
338
- className: "h-8 px-3 text-xs font-medium",
339
- children: [
340
- /* @__PURE__ */ jsx("span", { children: "Submit" }),
341
- /* @__PURE__ */ jsx(CornerDownLeft, { className: "w-3 h-3 ml-1.5 opacity-60" })
342
- ]
343
- }
344
- ),
345
- /* @__PURE__ */ jsx(
346
- Button,
347
- {
348
- size: "sm",
349
- variant: "ghost",
350
- onClick: closeBar,
351
- className: "h-8 w-8 p-0 text-muted-foreground hover:text-foreground",
352
- children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
353
- }
354
- )
355
- ] }),
356
- streamedText && /* @__PURE__ */ jsxs("div", { className: "p-4 border-b border-border/60 max-h-[300px] overflow-y-auto space-y-3 bg-background/50", children: [
357
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
358
- /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: selectedText ? "Diff Preview (Original vs. AI)" : "AI Output" }),
359
- isGenerating && /* @__PURE__ */ jsxs("span", { className: "text-xs text-primary flex items-center gap-1 font-medium", children: [
360
- /* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin" }),
361
- "Streaming response..."
362
- ] })
363
- ] }),
364
- selectedText ? /* @__PURE__ */ jsx("div", { className: "text-sm leading-relaxed p-3 rounded-lg border border-border/50 bg-muted/30 font-sans", children: diffParts.map((part, index) => {
365
- if (part.type === "removed") {
366
- return /* @__PURE__ */ jsx(
367
- "span",
368
- {
369
- className: "bg-red-500/15 text-red-600 dark:text-red-400 line-through rounded px-1 py-0.5 mx-0.5",
370
- children: part.text
371
- },
372
- index
373
- );
374
- }
375
- if (part.type === "added") {
376
- return /* @__PURE__ */ jsx(
377
- "span",
378
- {
379
- className: "bg-emerald-500/15 text-emerald-600 dark:text-emerald-400 font-medium rounded px-1 py-0.5 mx-0.5",
380
- children: part.text
381
- },
382
- index
383
- );
384
- }
385
- return /* @__PURE__ */ jsx("span", { children: part.text }, index);
386
- }) }) : /* @__PURE__ */ jsx("div", { className: "text-sm leading-relaxed p-3 rounded-lg border border-border/50 bg-muted/30 font-sans whitespace-pre-wrap", children: streamedText }),
387
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1", children: [
388
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
389
- /* @__PURE__ */ jsxs(
390
- Button,
391
- {
392
- size: "sm",
393
- variant: "default",
394
- onClick: handleAccept,
395
- className: "h-8 bg-emerald-600 hover:bg-emerald-700 text-white font-medium text-xs px-3",
396
- children: [
397
- /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 mr-1" }),
398
- /* @__PURE__ */ jsx("span", { children: "Replace Selection" }),
399
- /* @__PURE__ */ jsx("kbd", { className: "ml-1.5 px-1 py-0.2 bg-emerald-700/60 rounded text-[10px]", children: "\u21B5" })
400
- ]
401
- }
402
- ),
403
- /* @__PURE__ */ jsxs(
404
- Button,
405
- {
406
- size: "sm",
407
- variant: "outline",
408
- onClick: handleInsertBelow,
409
- className: "h-8 text-xs font-medium px-3",
410
- children: [
411
- /* @__PURE__ */ jsx(ArrowDownToLine, { className: "w-3.5 h-3.5 mr-1.5" }),
412
- "Insert Below"
413
- ]
414
- }
415
- )
416
- ] }),
417
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
418
- /* @__PURE__ */ jsxs(
419
- Button,
420
- {
421
- size: "sm",
422
- variant: "ghost",
423
- onClick: () => runAction(activeAction || "default", selectedText, prompt),
424
- className: "h-8 text-xs text-muted-foreground hover:text-foreground",
425
- children: [
426
- /* @__PURE__ */ jsx(RotateCcw, { className: "w-3.5 h-3.5 mr-1" }),
427
- "Retry"
428
- ]
429
- }
430
- ),
431
- /* @__PURE__ */ jsx(
432
- Button,
433
- {
434
- size: "sm",
435
- variant: "ghost",
436
- onClick: closeBar,
437
- className: "h-8 text-xs text-muted-foreground hover:text-destructive",
438
- children: "Discard"
439
- }
440
- )
441
- ] })
442
- ] })
443
- ] }),
444
- /* @__PURE__ */ jsx("div", { className: "p-3 bg-muted/10 space-y-2", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
445
- QUICK_ACTIONS.map((action) => {
446
- const Icon = action.icon;
447
- return /* @__PURE__ */ jsxs(
448
- "button",
449
- {
450
- onClick: () => runAction(action.id, selectedText),
451
- className: "flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border/60 bg-background/80 hover:bg-muted text-muted-foreground hover:text-foreground transition-all",
452
- children: [
453
- /* @__PURE__ */ jsx(Icon, { className: "w-3.5 h-3.5 text-primary" }),
454
- /* @__PURE__ */ jsx("span", { children: action.label })
455
- ]
456
- },
457
- action.id
458
- );
459
- }),
460
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
461
- /* @__PURE__ */ jsxs(
462
- "button",
463
- {
464
- onClick: () => {
465
- setShowToneMenu(!showToneMenu);
466
- setShowLangMenu(false);
467
- },
468
- className: "flex items-center gap-1 px-2.5 py-1 text-xs rounded-md border border-border/60 bg-background/80 hover:bg-muted text-muted-foreground hover:text-foreground transition-all",
469
- children: [
470
- /* @__PURE__ */ jsx("span", { children: "Change Tone" }),
471
- /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3 opacity-60" })
472
- ]
473
- }
474
- ),
475
- showToneMenu && /* @__PURE__ */ jsx("div", { className: "absolute left-0 bottom-full mb-1 w-36 rounded-lg border border-border bg-popover shadow-xl py-1 z-50 animate-in fade-in-0 zoom-in-95", children: TONES.map((tone) => /* @__PURE__ */ jsx(
476
- "button",
477
- {
478
- onClick: () => {
479
- setShowToneMenu(false);
480
- runAction(
481
- "default",
482
- selectedText,
483
- `Rewrite the text in a ${tone.toLowerCase()} tone.`
484
- );
485
- },
486
- className: "w-full text-left px-3 py-1.5 text-xs text-popover-foreground hover:bg-muted transition-colors",
487
- children: tone
488
- },
489
- tone
490
- )) })
491
- ] }),
492
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
493
- /* @__PURE__ */ jsxs(
494
- "button",
495
- {
496
- onClick: () => {
497
- setShowLangMenu(!showLangMenu);
498
- setShowToneMenu(false);
499
- },
500
- className: "flex items-center gap-1 px-2.5 py-1 text-xs rounded-md border border-border/60 bg-background/80 hover:bg-muted text-muted-foreground hover:text-foreground transition-all",
501
- children: [
502
- /* @__PURE__ */ jsx(Languages, { className: "w-3 h-3 text-primary" }),
503
- /* @__PURE__ */ jsx("span", { children: "Translate" }),
504
- /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3 opacity-60" })
505
- ]
506
- }
507
- ),
508
- showLangMenu && /* @__PURE__ */ jsx("div", { className: "absolute left-0 bottom-full mb-1 w-36 rounded-lg border border-border bg-popover shadow-xl py-1 z-50 animate-in fade-in-0 zoom-in-95", children: LANGUAGES.map((lang) => /* @__PURE__ */ jsx(
509
- "button",
510
- {
511
- onClick: () => {
512
- setShowLangMenu(false);
513
- runAction(
514
- "default",
515
- selectedText,
516
- `Translate the text accurately into ${lang}.`
517
- );
518
- },
519
- className: "w-full text-left px-3 py-1.5 text-xs text-popover-foreground hover:bg-muted transition-colors",
520
- children: lang
521
- },
522
- lang
523
- )) })
524
- ] })
525
- ] }) })
526
- ]
527
- }
528
- ),
529
- document.body
530
- );
531
- }
532
-
533
- export {
534
- OPEN_AI_COMMAND_BAR_COMMAND,
535
- AICommandBarPlugin
536
- };