@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,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
- };