@collabchron/notiq 1.1.12 → 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 (146) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-RHRYHSVN.mjs → AIDialog-HJW6PQPR.mjs} +11 -12
  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-BMSYIPP6.mjs → ExcalidrawComponent-POMYXDSG.mjs} +33 -6
  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-JN4ZPZOW.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +8 -9
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-FO7M3X2B.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-ZYJ7KABY.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-T2UBAZ66.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-ELBTVBTS.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-QNIY45SF.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-5D4JF3ZZ.mjs → chunk-XAJ4GACN.mjs} +171 -49
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/index.d.ts +1 -1
  37. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  38. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  39. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  40. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  41. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  42. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  43. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  44. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  45. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  46. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  47. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  48. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  49. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  50. package/dist/components/editor/utils/url.d.ts +16 -4
  51. package/dist/components/providers/AIContext.d.ts +8 -0
  52. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  53. package/dist/core/extension.d.ts +3 -1
  54. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  55. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  56. package/dist/core/react/NotiqContent.d.ts +4 -1
  57. package/dist/core/react/index.d.ts +1 -0
  58. package/dist/core/react/node-renderers.d.ts +73 -0
  59. package/dist/core.js +15429 -13116
  60. package/dist/core.mjs +47 -39
  61. package/dist/hooks/instructions-messages.d.ts +13 -4
  62. package/dist/{image-QPB2CVXP.mjs → image-AL6PHM2A.mjs} +17 -12
  63. package/dist/index.js +15526 -13194
  64. package/dist/index.mjs +64 -60
  65. package/dist/{insert-audio-I3PD6JFS.mjs → insert-audio-CRWR7EO5.mjs} +4 -6
  66. package/dist/{insert-file-PHR7XL4V.mjs → insert-file-I73AZW3L.mjs} +4 -6
  67. package/dist/{insert-gif-R5ZO4JHC.mjs → insert-gif-KWRC3ACT.mjs} +1 -1
  68. package/dist/{insert-image-PLBZELHK.mjs → insert-image-XIY6BGW5.mjs} +4 -3
  69. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  70. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  71. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  72. package/dist/react.js +14747 -12554
  73. package/dist/react.mjs +40 -38
  74. package/dist/{stepper-KNITDVLG.mjs → stepper-ILF7YXTO.mjs} +63 -73
  75. package/dist/styles/notiq.css +1 -1
  76. package/package.json +2 -2
  77. package/src/styles/notiq.css +20 -0
  78. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  79. package/dist/CodeActionMenuPlugin-FGH6HZLL.mjs +0 -14
  80. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  81. package/dist/CollaboratorsBar-AMPIAUOY.mjs +0 -20
  82. package/dist/CommentsPlugin-SDJJTUGK.mjs +0 -19
  83. package/dist/ExcalidrawPlugin-QLPGJPSX.mjs +0 -14
  84. package/dist/ExportPlugin-MJHYKQZJ.mjs +0 -43
  85. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  86. package/dist/FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs +0 -45
  87. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  88. package/dist/MobileToolbar-KV5DX4ED.mjs +0 -982
  89. package/dist/SlashCommand-SPR7G5EI.mjs +0 -39
  90. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  91. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  92. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  93. package/dist/ToolbarPlugin-F52PVNXU.mjs +0 -823
  94. package/dist/VersionHistoryPlugin-YWGCREKA.mjs +0 -371
  95. package/dist/background-color-RW5JYLMG.mjs +0 -425
  96. package/dist/block-format-TODFREE2.mjs +0 -14
  97. package/dist/chunk-22ZIL6NH.mjs +0 -88
  98. package/dist/chunk-2LNT36RL.mjs +0 -555
  99. package/dist/chunk-37LC44W3.mjs +0 -2677
  100. package/dist/chunk-3IILA3IP.mjs +0 -28
  101. package/dist/chunk-4DVIYZVB.mjs +0 -193
  102. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  103. package/dist/chunk-4UMUPCDK.mjs +0 -68
  104. package/dist/chunk-6D6QLRYR.mjs +0 -238
  105. package/dist/chunk-6FQFPPLG.mjs +0 -785
  106. package/dist/chunk-ACV47ZKE.mjs +0 -201
  107. package/dist/chunk-BGV62GC2.mjs +0 -26
  108. package/dist/chunk-C4JWLBYN.mjs +0 -132
  109. package/dist/chunk-CLRSETYQ.mjs +0 -431
  110. package/dist/chunk-D3IOUQFR.mjs +0 -441
  111. package/dist/chunk-EEBA6OAH.mjs +0 -59
  112. package/dist/chunk-EIZMKFHF.mjs +0 -32
  113. package/dist/chunk-ENH2IOHI.mjs +0 -1828
  114. package/dist/chunk-EVPWKNE4.mjs +0 -27
  115. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  116. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  117. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  118. package/dist/chunk-K5OAFEVY.mjs +0 -191
  119. package/dist/chunk-KXRLARGI.mjs +0 -26
  120. package/dist/chunk-LBGM4VVZ.mjs +0 -409
  121. package/dist/chunk-LLGVCM7M.mjs +0 -809
  122. package/dist/chunk-LU2XWLOE.mjs +0 -219
  123. package/dist/chunk-LVRJM45C.mjs +0 -171
  124. package/dist/chunk-MSAO3YFB.mjs +0 -144
  125. package/dist/chunk-N3KDPSRI.mjs +0 -496
  126. package/dist/chunk-OXWTZV3U.mjs +0 -174
  127. package/dist/chunk-PD5K4AGP.mjs +0 -64
  128. package/dist/chunk-PFH63ZU4.mjs +0 -33
  129. package/dist/chunk-R7WFRENU.mjs +0 -262
  130. package/dist/chunk-RAVYEEIC.mjs +0 -36
  131. package/dist/chunk-RJQTA6HG.mjs +0 -358
  132. package/dist/chunk-SAOJHVPE.mjs +0 -153
  133. package/dist/chunk-SYUCM5G5.mjs +0 -111
  134. package/dist/chunk-VGAX6YEY.mjs +0 -399
  135. package/dist/chunk-VNDDDXGH.mjs +0 -682
  136. package/dist/chunk-WUVIQCX7.mjs +0 -944
  137. package/dist/chunk-XNJNT6PC.mjs +0 -1701
  138. package/dist/chunk-XYLTLGY5.mjs +0 -775
  139. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  140. package/dist/color-S55XFDYQ.mjs +0 -13
  141. package/dist/font-IJKFR4BM.mjs +0 -12
  142. package/dist/font-size-3HMJHKO2.mjs +0 -15
  143. package/dist/insert-node-DGCZBGKG.mjs +0 -243
  144. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  145. package/dist/text-align-TEB4S52S.mjs +0 -121
  146. package/dist/text-format-T3IY7FBI.mjs +0 -15
@@ -1,360 +0,0 @@
1
- "use client";
2
- import {
3
- cn
4
- } from "./chunk-JHXDLYEV.mjs";
5
- import {
6
- init_react_shim
7
- } from "./chunk-WYCFGRFJ.mjs";
8
-
9
- // src/components/editor/plugins/InlineCopilotPlugin/index.tsx
10
- init_react_shim();
11
- import { useEffect, useState, useRef, useCallback } from "react";
12
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
13
- import {
14
- $getSelection,
15
- $isRangeSelection,
16
- COMMAND_PRIORITY_CRITICAL,
17
- KEY_DOWN_COMMAND,
18
- SELECTION_CHANGE_COMMAND
19
- } from "lexical";
20
- import { Sparkles, Loader2 } from "lucide-react";
21
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
22
- function computeCopilotPositioning({
23
- caretRect,
24
- rootRect,
25
- paddingLeft,
26
- paddingRight,
27
- windowWidth,
28
- suggestionText,
29
- rightObstacleLeft
30
- }) {
31
- const editorContentRight = rootRect.right - paddingRight;
32
- const windowSafeRight = windowWidth - 64;
33
- const effectiveObstacleRight = rightObstacleLeft && rightObstacleLeft > 0 ? rightObstacleLeft - 16 : windowSafeRight;
34
- const maxRight = Math.min(editorContentRight, windowSafeRight, effectiveObstacleRight);
35
- const availableWidthOnLine = maxRight - caretRect.right;
36
- const estimatedSuggestionWidth = suggestionText.length * 8.2 + 105;
37
- const shouldWrapToNextLine = availableWidthOnLine < 240 || estimatedSuggestionWidth > availableWidthOnLine;
38
- if (shouldWrapToNextLine) {
39
- const nextLineStartX = rootRect.left + paddingLeft;
40
- const nextLineMaxWidth = Math.max(160, maxRight - nextLineStartX - 8);
41
- return {
42
- x: nextLineStartX,
43
- y: caretRect.bottom + 3,
44
- height: caretRect.height || 22,
45
- maxWidth: nextLineMaxWidth,
46
- isNextLine: true
47
- };
48
- } else {
49
- return {
50
- x: caretRect.right,
51
- y: caretRect.top,
52
- height: caretRect.height || 22,
53
- maxWidth: Math.max(80, availableWidthOnLine - 8),
54
- isNextLine: false
55
- };
56
- }
57
- }
58
- function InlineCopilotPlugin({
59
- enabledDefault = true
60
- }) {
61
- const [editor] = useLexicalComposerContext();
62
- const [isEnabled, setIsEnabled] = useState(() => {
63
- if (typeof window !== "undefined") {
64
- const saved = localStorage.getItem("notiq_copilot_enabled");
65
- if (saved !== null) return saved === "true";
66
- }
67
- return enabledDefault;
68
- });
69
- const [suggestion, setSuggestion] = useState(null);
70
- const [isLoading, setIsLoading] = useState(false);
71
- const [caretCoords, setCaretCoords] = useState(null);
72
- const debounceTimerRef = useRef(null);
73
- const abortControllerRef = useRef(null);
74
- const activePromptRef = useRef("");
75
- const isEnabledRef = useRef(isEnabled);
76
- isEnabledRef.current = isEnabled;
77
- const clearSuggestion = useCallback(() => {
78
- if (abortControllerRef.current) {
79
- abortControllerRef.current.abort();
80
- abortControllerRef.current = null;
81
- }
82
- setSuggestion(null);
83
- setIsLoading(false);
84
- setCaretCoords(null);
85
- }, []);
86
- const toggleEnabled = () => {
87
- setIsEnabled((prev) => {
88
- const next = !prev;
89
- if (typeof window !== "undefined") {
90
- localStorage.setItem("notiq_copilot_enabled", String(next));
91
- }
92
- if (!next) clearSuggestion();
93
- return next;
94
- });
95
- };
96
- const getRightObstacleLeft = useCallback(() => {
97
- if (typeof window === "undefined") return void 0;
98
- let obstacleLeft = window.innerWidth - 64;
99
- const fixedElements = document.querySelectorAll(
100
- '[data-comments-sidebar="true"], [data-version-drawer="true"], .fixed.right-4, aside'
101
- );
102
- fixedElements.forEach((el) => {
103
- const rect = el.getBoundingClientRect();
104
- if (rect.width > 0 && rect.left > 0 && rect.left < obstacleLeft) {
105
- obstacleLeft = rect.left;
106
- }
107
- });
108
- return obstacleLeft;
109
- }, []);
110
- const calculateCurrentCaretCoords = useCallback(
111
- (cleanText) => {
112
- if (typeof window === "undefined") return null;
113
- const domSelection = window.getSelection();
114
- if (!domSelection || domSelection.rangeCount === 0) return null;
115
- const range = domSelection.getRangeAt(0);
116
- const caretRect = range.getBoundingClientRect();
117
- if (!caretRect || caretRect.top <= 0) return null;
118
- const rootElement = editor.getRootElement();
119
- if (!rootElement) return null;
120
- const rootRect = rootElement.getBoundingClientRect();
121
- const style = window.getComputedStyle(rootElement);
122
- const paddingLeft = parseFloat(style.paddingLeft) || 16;
123
- const paddingRight = parseFloat(style.paddingRight) || 16;
124
- const rightObstacle = getRightObstacleLeft();
125
- return computeCopilotPositioning({
126
- caretRect: {
127
- right: caretRect.right,
128
- top: caretRect.top,
129
- bottom: caretRect.bottom,
130
- height: caretRect.height
131
- },
132
- rootRect: {
133
- left: rootRect.left,
134
- right: rootRect.right,
135
- width: rootRect.width
136
- },
137
- paddingLeft,
138
- paddingRight,
139
- windowWidth: window.innerWidth,
140
- suggestionText: cleanText,
141
- rightObstacleLeft: rightObstacle
142
- });
143
- },
144
- [editor, getRightObstacleLeft]
145
- );
146
- const fetchCompletion = useCallback(
147
- async (textBeforeCursor) => {
148
- if (!isEnabledRef.current || !textBeforeCursor || textBeforeCursor.length < 12) {
149
- return;
150
- }
151
- if (abortControllerRef.current) {
152
- abortControllerRef.current.abort();
153
- }
154
- const controller = new AbortController();
155
- abortControllerRef.current = controller;
156
- setIsLoading(true);
157
- activePromptRef.current = textBeforeCursor;
158
- try {
159
- const savedProvider = typeof window !== "undefined" ? localStorage.getItem("notiq_ai_provider") : void 0;
160
- const savedKey = typeof window !== "undefined" ? localStorage.getItem("notiq_ai_api_key") : void 0;
161
- const res = await fetch("/api/ai", {
162
- method: "POST",
163
- headers: { "Content-Type": "application/json" },
164
- signal: controller.signal,
165
- body: JSON.stringify({
166
- action: "autoComplete",
167
- prompt: textBeforeCursor.slice(-150),
168
- modelProvider: savedProvider && savedProvider !== "auto" ? savedProvider : void 0,
169
- apiKey: savedKey || void 0
170
- })
171
- });
172
- if (!res.ok) {
173
- setIsLoading(false);
174
- return;
175
- }
176
- const completionText = await res.text();
177
- if (controller.signal.aborted) return;
178
- let clean = completionText.trim();
179
- clean = clean.replace(/^["'`]+|["'`]+$/g, "");
180
- if (clean && clean.length > 3) {
181
- if (!textBeforeCursor.endsWith(" ") && !clean.startsWith(" ") && !clean.startsWith(",") && !clean.startsWith(".")) {
182
- clean = " " + clean;
183
- }
184
- editor.getEditorState().read(() => {
185
- const selection = $getSelection();
186
- if ($isRangeSelection(selection) && selection.isCollapsed()) {
187
- const coords = calculateCurrentCaretCoords(clean);
188
- if (coords) {
189
- setSuggestion(clean);
190
- setCaretCoords(coords);
191
- return;
192
- }
193
- }
194
- clearSuggestion();
195
- });
196
- } else {
197
- clearSuggestion();
198
- }
199
- } catch (e) {
200
- if (!controller.signal.aborted) {
201
- clearSuggestion();
202
- }
203
- } finally {
204
- if (!controller.signal.aborted) {
205
- setIsLoading(false);
206
- }
207
- }
208
- },
209
- [clearSuggestion, calculateCurrentCaretCoords, editor]
210
- );
211
- useEffect(() => {
212
- return editor.registerUpdateListener(({ editorState, dirtyElements, dirtyLeaves }) => {
213
- if (!isEnabledRef.current) return;
214
- if (dirtyElements.size > 0 || dirtyLeaves.size > 0) {
215
- clearSuggestion();
216
- }
217
- if (debounceTimerRef.current) {
218
- clearTimeout(debounceTimerRef.current);
219
- }
220
- debounceTimerRef.current = setTimeout(() => {
221
- if (!isEnabledRef.current) return;
222
- editorState.read(() => {
223
- const selection = $getSelection();
224
- if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
225
- clearSuggestion();
226
- return;
227
- }
228
- const node = selection.anchor.getNode();
229
- const offset = selection.anchor.offset;
230
- const textContent = node.getTextContent();
231
- const textBeforeCursor = textContent.slice(0, offset).trim();
232
- if (textBeforeCursor.length < 12 || !/\s/.test(textBeforeCursor)) {
233
- clearSuggestion();
234
- return;
235
- }
236
- fetchCompletion(textBeforeCursor);
237
- });
238
- }, 750);
239
- });
240
- }, [editor, clearSuggestion, fetchCompletion]);
241
- useEffect(() => {
242
- if (!suggestion) return;
243
- const handleReposition = () => {
244
- editor.getEditorState().read(() => {
245
- const selection = $getSelection();
246
- if ($isRangeSelection(selection) && selection.isCollapsed()) {
247
- const coords = calculateCurrentCaretCoords(suggestion);
248
- if (coords) {
249
- setCaretCoords(coords);
250
- return;
251
- }
252
- }
253
- clearSuggestion();
254
- });
255
- };
256
- window.addEventListener("scroll", handleReposition, { passive: true });
257
- window.addEventListener("resize", handleReposition, { passive: true });
258
- return () => {
259
- window.removeEventListener("scroll", handleReposition);
260
- window.removeEventListener("resize", handleReposition);
261
- };
262
- }, [suggestion, editor, clearSuggestion, calculateCurrentCaretCoords]);
263
- useEffect(() => {
264
- return editor.registerCommand(
265
- KEY_DOWN_COMMAND,
266
- (event) => {
267
- if (event.altKey && event.key.toLowerCase() === "c") {
268
- event.preventDefault();
269
- toggleEnabled();
270
- return true;
271
- }
272
- if (event.key === "Tab" && suggestion) {
273
- event.preventDefault();
274
- event.stopPropagation();
275
- const textToInsert = suggestion;
276
- clearSuggestion();
277
- editor.update(() => {
278
- const selection = $getSelection();
279
- if ($isRangeSelection(selection)) {
280
- selection.insertText(textToInsert);
281
- }
282
- });
283
- return true;
284
- }
285
- if (event.key === "Escape" && suggestion) {
286
- event.preventDefault();
287
- clearSuggestion();
288
- return true;
289
- }
290
- if (suggestion && event.key !== "Shift" && event.key !== "Control" && event.key !== "Alt") {
291
- clearSuggestion();
292
- }
293
- return false;
294
- },
295
- COMMAND_PRIORITY_CRITICAL
296
- );
297
- }, [editor, suggestion, clearSuggestion]);
298
- useEffect(() => {
299
- return editor.registerCommand(
300
- SELECTION_CHANGE_COMMAND,
301
- () => {
302
- if (suggestion) {
303
- clearSuggestion();
304
- }
305
- return false;
306
- },
307
- COMMAND_PRIORITY_CRITICAL
308
- );
309
- }, [editor, suggestion, clearSuggestion]);
310
- return /* @__PURE__ */ jsxs(Fragment, { children: [
311
- suggestion && caretCoords && isEnabled && /* @__PURE__ */ jsxs(
312
- "div",
313
- {
314
- style: {
315
- position: "fixed",
316
- left: `${caretCoords.x}px`,
317
- top: `${caretCoords.y}px`,
318
- maxWidth: `${caretCoords.maxWidth}px`,
319
- lineHeight: `${caretCoords.height}px`,
320
- zIndex: 45,
321
- pointerEvents: "none"
322
- },
323
- className: cn(
324
- "inline-flex items-center text-muted-foreground/60 dark:text-muted-foreground/50 select-none font-normal animate-in fade-in-50 duration-150 overflow-hidden",
325
- caretCoords.isNextLine && "py-0.5 px-1.5 rounded-md bg-muted/20 border border-border/40 backdrop-blur-xs shadow-xs"
326
- ),
327
- children: [
328
- caretCoords.isNextLine && /* @__PURE__ */ jsx("span", { className: "text-[10px] not-italic text-muted-foreground/50 font-mono select-none mr-1.5 shrink-0", children: "\u21B5" }),
329
- /* @__PURE__ */ jsx("span", { className: "truncate min-w-0 flex-1 italic whitespace-pre", children: caretCoords.isNextLine ? suggestion.trimStart() : suggestion.startsWith(" ") ? "\xA0" + suggestion.slice(1) : suggestion }),
330
- /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 ml-2 px-1.5 py-0.5 rounded text-[10px] bg-background/95 text-foreground border border-border/80 shadow-xs not-italic font-mono font-medium backdrop-blur-xs pointer-events-auto shrink-0", children: [
331
- /* @__PURE__ */ jsx("span", { children: "Tab" }),
332
- /* @__PURE__ */ jsx("span", { className: "text-[9px] text-muted-foreground", children: "\u21E5 accept" })
333
- ] })
334
- ]
335
- }
336
- ),
337
- /* @__PURE__ */ jsx("div", { className: "fixed bottom-4 left-4 z-40 hidden sm:flex items-center gap-1.5 animate-in fade-in duration-300", children: /* @__PURE__ */ jsxs(
338
- "button",
339
- {
340
- type: "button",
341
- onClick: toggleEnabled,
342
- className: cn(
343
- "flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium transition-all shadow-sm border backdrop-blur-md",
344
- isEnabled ? "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/30 hover:bg-purple-500/20" : "bg-muted/70 text-muted-foreground border-border/60 hover:bg-muted"
345
- ),
346
- title: `AI Copilot (${isEnabled ? "Active" : "Paused"}). Press Alt+C to toggle.`,
347
- "aria-label": "Toggle AI Ghost Text Copilot",
348
- children: [
349
- isLoading ? /* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin text-purple-500" }) : /* @__PURE__ */ jsx(Sparkles, { className: cn("w-3 h-3", isEnabled && "text-purple-500") }),
350
- /* @__PURE__ */ jsx("span", { children: isEnabled ? "Copilot on" : "Copilot off" }),
351
- /* @__PURE__ */ jsx("kbd", { className: "text-[9px] font-mono opacity-60 bg-background/60 px-1 rounded", children: "Alt+C" })
352
- ]
353
- }
354
- ) })
355
- ] });
356
- }
357
- export {
358
- computeCopilotPositioning,
359
- InlineCopilotPlugin as default
360
- };