@copilotkit/react-textarea 0.24.0 → 0.25.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.
- package/.turbo/turbo-build.log +99 -99
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-WJYQWL4I.mjs → chunk-2C7O2EVM.mjs} +1 -1
- package/dist/{chunk-WJYQWL4I.mjs.map → chunk-2C7O2EVM.mjs.map} +1 -1
- package/dist/{chunk-KCHYD3EB.mjs → chunk-2CDXHWVF.mjs} +1 -1
- package/dist/chunk-2CDXHWVF.mjs.map +1 -0
- package/dist/{chunk-GCMQHIRF.mjs → chunk-2QDCE7PD.mjs} +1 -1
- package/dist/chunk-2QDCE7PD.mjs.map +1 -0
- package/dist/{chunk-ND5PXTAW.mjs → chunk-3PQ7GSFE.mjs} +1 -1
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -0
- package/dist/{chunk-GIJ3JZ4P.mjs → chunk-5IISSXS2.mjs} +11 -11
- package/dist/chunk-5IISSXS2.mjs.map +1 -0
- package/dist/{chunk-RQHOUUXQ.mjs → chunk-5UNJXFUO.mjs} +1 -1
- package/dist/{chunk-RQHOUUXQ.mjs.map → chunk-5UNJXFUO.mjs.map} +1 -1
- package/dist/{chunk-JYVC4AW3.mjs → chunk-74HF6Q3L.mjs} +26 -27
- package/dist/chunk-74HF6Q3L.mjs.map +1 -0
- package/dist/{chunk-MPME5BW2.mjs → chunk-7LSRNPNI.mjs} +1 -1
- package/dist/chunk-7LSRNPNI.mjs.map +1 -0
- package/dist/{chunk-4UYKBG35.mjs → chunk-7SZDD6XT.mjs} +4 -8
- package/dist/chunk-7SZDD6XT.mjs.map +1 -0
- package/dist/{chunk-AQHORK66.mjs → chunk-7VKOE5UL.mjs} +6 -10
- package/dist/chunk-7VKOE5UL.mjs.map +1 -0
- package/dist/{chunk-463BFNUP.mjs → chunk-AUCHS4VR.mjs} +2 -2
- package/dist/chunk-AUCHS4VR.mjs.map +1 -0
- package/dist/{chunk-JAFCXEPU.mjs → chunk-BLRAOGXD.mjs} +2 -2
- package/dist/{chunk-JAFCXEPU.mjs.map → chunk-BLRAOGXD.mjs.map} +1 -1
- package/dist/{chunk-O4MHJSK2.mjs → chunk-CK7Q3Y5A.mjs} +2 -2
- package/dist/{chunk-IXJ2HCOA.mjs → chunk-ECR45NSD.mjs} +1 -1
- package/dist/chunk-ECR45NSD.mjs.map +1 -0
- package/dist/{chunk-OELUUJZY.mjs → chunk-EZCKXWQF.mjs} +1 -1
- package/dist/chunk-EZCKXWQF.mjs.map +1 -0
- package/dist/{chunk-KGKLUWKW.mjs → chunk-F626GQCD.mjs} +1 -1
- package/dist/chunk-F626GQCD.mjs.map +1 -0
- package/dist/{chunk-5EJ5XOGP.mjs → chunk-FK2XUDQQ.mjs} +2 -2
- package/dist/chunk-FK2XUDQQ.mjs.map +1 -0
- package/dist/chunk-FP2EKU3L.mjs +28 -0
- package/dist/chunk-FP2EKU3L.mjs.map +1 -0
- package/dist/{chunk-F3MHL6ZY.mjs → chunk-GQN2HYFJ.mjs} +2 -5
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -0
- package/dist/{chunk-AXN37AHC.mjs → chunk-K5LNB36H.mjs} +1 -1
- package/dist/chunk-K5LNB36H.mjs.map +1 -0
- package/dist/{chunk-JHTAOLEW.mjs → chunk-KDVMG3XF.mjs} +1 -1
- package/dist/chunk-KDVMG3XF.mjs.map +1 -0
- package/dist/{chunk-2NURR2DX.mjs → chunk-KMXSZRIA.mjs} +2 -2
- package/dist/chunk-KMXSZRIA.mjs.map +1 -0
- package/dist/{chunk-4S5ZJH3I.mjs → chunk-KNQIEOFP.mjs} +1 -1
- package/dist/{chunk-4S5ZJH3I.mjs.map → chunk-KNQIEOFP.mjs.map} +1 -1
- package/dist/{chunk-YQU7WG7T.mjs → chunk-LZ3UOAQ4.mjs} +3 -3
- package/dist/chunk-LZ3UOAQ4.mjs.map +1 -0
- package/dist/{chunk-NKW5OU2S.mjs → chunk-M2DR4KVB.mjs} +1 -1
- package/dist/chunk-M2DR4KVB.mjs.map +1 -0
- package/dist/{chunk-GUH3Y2H4.mjs → chunk-NTLVQENP.mjs} +5 -5
- package/dist/chunk-NTLVQENP.mjs.map +1 -0
- package/dist/{chunk-O5OWT5GE.mjs → chunk-PDCIGRCE.mjs} +8 -29
- package/dist/chunk-PDCIGRCE.mjs.map +1 -0
- package/dist/{chunk-YW3REYX6.mjs → chunk-QRKKPCUD.mjs} +2 -4
- package/dist/chunk-QRKKPCUD.mjs.map +1 -0
- package/dist/{chunk-RR6OQGTI.mjs → chunk-RBR32FWA.mjs} +1 -1
- package/dist/chunk-RBR32FWA.mjs.map +1 -0
- package/dist/{chunk-YTOPHPSG.mjs → chunk-T6MTDQZ7.mjs} +1 -1
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -0
- package/dist/{chunk-QJDMIGLU.mjs → chunk-TZLW7PBU.mjs} +9 -12
- package/dist/chunk-TZLW7PBU.mjs.map +1 -0
- package/dist/{chunk-CSGFJU3L.mjs → chunk-U3LUDDT5.mjs} +2 -2
- package/dist/chunk-U3LUDDT5.mjs.map +1 -0
- package/dist/{chunk-LNAIMEB2.mjs → chunk-UEQYKC4W.mjs} +1 -1
- package/dist/chunk-UEQYKC4W.mjs.map +1 -0
- package/dist/{chunk-OD7ZMOVE.mjs → chunk-V55OPCG4.mjs} +2 -2
- package/dist/chunk-V55OPCG4.mjs.map +1 -0
- package/dist/{chunk-4HHYJGZE.mjs → chunk-VYECMH73.mjs} +7 -25
- package/dist/chunk-VYECMH73.mjs.map +1 -0
- package/dist/{chunk-3L6CNVCE.mjs → chunk-W2ZHOUV6.mjs} +5 -5
- package/dist/chunk-W2ZHOUV6.mjs.map +1 -0
- package/dist/{chunk-UHD44NC5.mjs → chunk-WVRTFPNO.mjs} +10 -20
- package/dist/chunk-WVRTFPNO.mjs.map +1 -0
- package/dist/{chunk-4LOLCQGR.mjs → chunk-ZEHF3AXH.mjs} +4 -9
- package/dist/chunk-ZEHF3AXH.mjs.map +1 -0
- package/dist/{chunk-XHUMROEY.mjs → chunk-ZKRM3DIR.mjs} +1 -1
- package/dist/chunk-ZKRM3DIR.mjs.map +1 -0
- package/dist/{chunk-WLPYYGES.mjs → chunk-ZMNOLW5V.mjs} +6 -16
- package/dist/chunk-ZMNOLW5V.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +31 -31
- package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +2 -2
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +40 -40
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +15 -15
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +10 -10
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +11 -11
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +3 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +11 -11
- package/dist/components/index.mjs +40 -40
- package/dist/components/manual-ui/chip-with-icon.mjs +1 -5
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +4 -4
- package/dist/components/ui/button.mjs +2 -2
- package/dist/components/ui/card.mjs +46 -42
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +3 -3
- package/dist/components/ui/dialog.mjs +2 -2
- package/dist/components/ui/label.mjs +2 -2
- package/dist/components/ui/separator.mjs +14 -16
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +1 -1
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +4 -4
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +2 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +3 -3
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -8
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -8
- package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
- package/dist/index.mjs +40 -40
- package/dist/lib/debouncer.mjs +1 -1
- package/dist/lib/editor-to-text.mjs +1 -1
- package/dist/lib/get-text-around-cursor.mjs +1 -1
- package/dist/lib/retry.mjs +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +1 -1
- package/dist/lib/stream-promise-flatten.mjs +1 -1
- package/dist/lib/utils.mjs +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +5 -5
- package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
- package/dist/types/autosuggestions-config/index.mjs +6 -6
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +1 -1
- package/dist/types/base/base-autosuggestions-config.d.ts +55 -2
- package/dist/types/base/base-autosuggestions-config.mjs +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +2 -2
- package/dist/types/base/index.mjs +1 -1
- package/dist/types/index.mjs +6 -6
- package/package.json +2 -2
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +31 -37
- package/src/components/base-copilot-textarea/render-element.tsx +3 -5
- package/src/components/base-copilot-textarea/render-placeholder.tsx +2 -4
- package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +2 -5
- package/src/components/base-copilot-textarea/use-add-branding-css.tsx +2 -4
- package/src/components/copilot-textarea/copilot-textarea.tsx +11 -18
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +1 -3
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +14 -31
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +4 -16
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +11 -25
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +2 -7
- package/src/components/manual-ui/chip-with-icon.tsx +3 -12
- package/src/components/source-search-box/source-search-box.tsx +2 -12
- package/src/components/ui/button.tsx +6 -13
- package/src/components/ui/card.tsx +35 -65
- package/src/components/ui/command.tsx +8 -21
- package/src/components/ui/dialog.tsx +8 -29
- package/src/components/ui/label.tsx +3 -8
- package/src/components/ui/separator.tsx +13 -18
- package/src/components/ui/textarea.tsx +3 -4
- package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +13 -27
- package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +1 -5
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -11
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +5 -10
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +15 -35
- package/src/hooks/misc/use-autosize-textarea.tsx +1 -4
- package/src/lib/debouncer.ts +1 -3
- package/src/lib/editor-to-text.ts +4 -7
- package/src/lib/get-text-around-cursor.ts +2 -14
- package/src/lib/retry.tsx +1 -1
- package/src/lib/slatejs-edits/add-autocompletions.ts +2 -2
- package/src/lib/slatejs-edits/clear-autocompletions.ts +1 -4
- package/src/lib/slatejs-edits/replace-text.ts +1 -1
- package/src/lib/slatejs-edits/with-partial-history.ts +4 -11
- package/src/lib/stream-promise-flatten.ts +1 -3
- package/src/lib/utils.ts +4 -8
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -7
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +5 -18
- package/src/types/autosuggestions-config/editing-api-config.tsx +3 -5
- package/src/types/autosuggestions-config/insertions-api-config.tsx +2 -3
- package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +18 -26
- package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +1 -4
- package/src/types/autosuggestions-config/suggestions-api-config.tsx +2 -3
- package/src/types/base/autosuggestions-bare-function.ts +2 -2
- package/src/types/base/base-autosuggestions-config.tsx +80 -3
- package/src/types/base/editor-autocomplete-state.ts +1 -1
- package/dist/chunk-2NURR2DX.mjs.map +0 -1
- package/dist/chunk-3L6CNVCE.mjs.map +0 -1
- package/dist/chunk-463BFNUP.mjs.map +0 -1
- package/dist/chunk-4HHYJGZE.mjs.map +0 -1
- package/dist/chunk-4LOLCQGR.mjs.map +0 -1
- package/dist/chunk-4UYKBG35.mjs.map +0 -1
- package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
- package/dist/chunk-6Z2ATUNY.mjs +0 -15
- package/dist/chunk-6Z2ATUNY.mjs.map +0 -1
- package/dist/chunk-AQHORK66.mjs.map +0 -1
- package/dist/chunk-AXN37AHC.mjs.map +0 -1
- package/dist/chunk-CSGFJU3L.mjs.map +0 -1
- package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
- package/dist/chunk-GCMQHIRF.mjs.map +0 -1
- package/dist/chunk-GIJ3JZ4P.mjs.map +0 -1
- package/dist/chunk-GUH3Y2H4.mjs.map +0 -1
- package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
- package/dist/chunk-JHTAOLEW.mjs.map +0 -1
- package/dist/chunk-JYVC4AW3.mjs.map +0 -1
- package/dist/chunk-KCHYD3EB.mjs.map +0 -1
- package/dist/chunk-KGKLUWKW.mjs.map +0 -1
- package/dist/chunk-LNAIMEB2.mjs.map +0 -1
- package/dist/chunk-MPME5BW2.mjs.map +0 -1
- package/dist/chunk-ND5PXTAW.mjs.map +0 -1
- package/dist/chunk-NKW5OU2S.mjs.map +0 -1
- package/dist/chunk-O5OWT5GE.mjs.map +0 -1
- package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
- package/dist/chunk-OELUUJZY.mjs.map +0 -1
- package/dist/chunk-QJDMIGLU.mjs.map +0 -1
- package/dist/chunk-RR6OQGTI.mjs.map +0 -1
- package/dist/chunk-UHD44NC5.mjs.map +0 -1
- package/dist/chunk-WLPYYGES.mjs.map +0 -1
- package/dist/chunk-XHUMROEY.mjs.map +0 -1
- package/dist/chunk-YQU7WG7T.mjs.map +0 -1
- package/dist/chunk-YTOPHPSG.mjs.map +0 -1
- package/dist/chunk-YW3REYX6.mjs.map +0 -1
- /package/dist/{chunk-O4MHJSK2.mjs.map → chunk-CK7Q3Y5A.mjs.map} +0 -0
|
@@ -2,85 +2,55 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils";
|
|
4
4
|
|
|
5
|
-
const Card = React.forwardRef<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)}
|
|
15
|
-
{...props}
|
|
16
|
-
/>
|
|
17
|
-
));
|
|
5
|
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
6
|
+
({ className, ...props }, ref) => (
|
|
7
|
+
<div
|
|
8
|
+
ref={ref}
|
|
9
|
+
className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
),
|
|
13
|
+
);
|
|
18
14
|
Card.displayName = "Card";
|
|
19
15
|
|
|
20
|
-
const CardHeader = React.forwardRef<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ref={ref}
|
|
26
|
-
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
27
|
-
{...props}
|
|
28
|
-
/>
|
|
29
|
-
));
|
|
16
|
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
17
|
+
({ className, ...props }, ref) => (
|
|
18
|
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
19
|
+
),
|
|
20
|
+
);
|
|
30
21
|
CardHeader.displayName = "CardHeader";
|
|
31
22
|
|
|
32
|
-
const CardTitle = React.forwardRef<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
));
|
|
23
|
+
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
24
|
+
({ className, ...props }, ref) => (
|
|
25
|
+
<h3
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn("text-2xl font-semibold leading-none tracking-tight", className)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
),
|
|
31
|
+
);
|
|
45
32
|
CardTitle.displayName = "CardTitle";
|
|
46
33
|
|
|
47
34
|
const CardDescription = React.forwardRef<
|
|
48
35
|
HTMLParagraphElement,
|
|
49
36
|
React.HTMLAttributes<HTMLParagraphElement>
|
|
50
37
|
>(({ className, ...props }, ref) => (
|
|
51
|
-
<p
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={cn("text-sm text-muted-foreground", className)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
38
|
+
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
56
39
|
));
|
|
57
40
|
CardDescription.displayName = "CardDescription";
|
|
58
41
|
|
|
59
|
-
const CardContent = React.forwardRef<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
));
|
|
42
|
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
43
|
+
({ className, ...props }, ref) => (
|
|
44
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
45
|
+
),
|
|
46
|
+
);
|
|
65
47
|
CardContent.displayName = "CardContent";
|
|
66
48
|
|
|
67
|
-
const CardFooter = React.forwardRef<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
ref={ref}
|
|
73
|
-
className={cn("flex items-center p-6 pt-0", className)}
|
|
74
|
-
{...props}
|
|
75
|
-
/>
|
|
76
|
-
));
|
|
49
|
+
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
50
|
+
({ className, ...props }, ref) => (
|
|
51
|
+
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
|
52
|
+
),
|
|
53
|
+
);
|
|
77
54
|
CardFooter.displayName = "CardFooter";
|
|
78
55
|
|
|
79
|
-
export {
|
|
80
|
-
Card,
|
|
81
|
-
CardHeader,
|
|
82
|
-
CardFooter,
|
|
83
|
-
CardTitle,
|
|
84
|
-
CardDescription,
|
|
85
|
-
CardContent,
|
|
86
|
-
};
|
|
56
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -16,7 +16,7 @@ const Command = React.forwardRef<
|
|
|
16
16
|
ref={ref}
|
|
17
17
|
className={cn(
|
|
18
18
|
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
19
|
-
className
|
|
19
|
+
className,
|
|
20
20
|
)}
|
|
21
21
|
{...props}
|
|
22
22
|
/>
|
|
@@ -47,7 +47,7 @@ const CommandInput = React.forwardRef<
|
|
|
47
47
|
ref={ref}
|
|
48
48
|
className={cn(
|
|
49
49
|
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
50
|
-
className
|
|
50
|
+
className,
|
|
51
51
|
)}
|
|
52
52
|
{...props}
|
|
53
53
|
/>
|
|
@@ -62,10 +62,7 @@ const CommandList = React.forwardRef<
|
|
|
62
62
|
>(({ className, ...props }, ref) => (
|
|
63
63
|
<CommandPrimitive.List
|
|
64
64
|
ref={ref}
|
|
65
|
-
className={cn(
|
|
66
|
-
"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
|
|
67
|
-
className
|
|
68
|
-
)}
|
|
65
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)}
|
|
69
66
|
{...props}
|
|
70
67
|
/>
|
|
71
68
|
));
|
|
@@ -76,11 +73,7 @@ const CommandEmpty = React.forwardRef<
|
|
|
76
73
|
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
77
74
|
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
78
75
|
>((props, ref) => (
|
|
79
|
-
<CommandPrimitive.Empty
|
|
80
|
-
ref={ref}
|
|
81
|
-
className="py-6 text-center text-sm"
|
|
82
|
-
{...props}
|
|
83
|
-
/>
|
|
76
|
+
<CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
|
|
84
77
|
));
|
|
85
78
|
|
|
86
79
|
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
@@ -93,7 +86,7 @@ const CommandGroup = React.forwardRef<
|
|
|
93
86
|
ref={ref}
|
|
94
87
|
className={cn(
|
|
95
88
|
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
96
|
-
className
|
|
89
|
+
className,
|
|
97
90
|
)}
|
|
98
91
|
{...props}
|
|
99
92
|
/>
|
|
@@ -121,7 +114,7 @@ const CommandItem = React.forwardRef<
|
|
|
121
114
|
ref={ref}
|
|
122
115
|
className={cn(
|
|
123
116
|
"relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
124
|
-
className
|
|
117
|
+
className,
|
|
125
118
|
)}
|
|
126
119
|
{...props}
|
|
127
120
|
/>
|
|
@@ -129,16 +122,10 @@ const CommandItem = React.forwardRef<
|
|
|
129
122
|
|
|
130
123
|
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
131
124
|
|
|
132
|
-
const CommandShortcut = ({
|
|
133
|
-
className,
|
|
134
|
-
...props
|
|
135
|
-
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
125
|
+
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
136
126
|
return (
|
|
137
127
|
<span
|
|
138
|
-
className={cn(
|
|
139
|
-
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
140
|
-
className
|
|
141
|
-
)}
|
|
128
|
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
|
142
129
|
{...props}
|
|
143
130
|
/>
|
|
144
131
|
);
|
|
@@ -10,10 +10,7 @@ const Dialog = DialogPrimitive.Root;
|
|
|
10
10
|
|
|
11
11
|
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
12
|
|
|
13
|
-
const DialogPortal = ({
|
|
14
|
-
className,
|
|
15
|
-
...props
|
|
16
|
-
}: DialogPrimitive.DialogPortalProps) => (
|
|
13
|
+
const DialogPortal = ({ className, ...props }: DialogPrimitive.DialogPortalProps) => (
|
|
17
14
|
<DialogPrimitive.Portal className={cn(className)} {...props} />
|
|
18
15
|
);
|
|
19
16
|
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
@@ -26,7 +23,7 @@ const DialogOverlay = React.forwardRef<
|
|
|
26
23
|
ref={ref}
|
|
27
24
|
className={cn(
|
|
28
25
|
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
29
|
-
className
|
|
26
|
+
className,
|
|
30
27
|
)}
|
|
31
28
|
{...props}
|
|
32
29
|
/>
|
|
@@ -43,7 +40,7 @@ const DialogContent = React.forwardRef<
|
|
|
43
40
|
ref={ref}
|
|
44
41
|
className={cn(
|
|
45
42
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
|
|
46
|
-
className
|
|
43
|
+
className,
|
|
47
44
|
)}
|
|
48
45
|
{...props}
|
|
49
46
|
>
|
|
@@ -57,29 +54,14 @@ const DialogContent = React.forwardRef<
|
|
|
57
54
|
));
|
|
58
55
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
59
56
|
|
|
60
|
-
const DialogHeader = ({
|
|
61
|
-
className,
|
|
62
|
-
...props
|
|
63
|
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
64
|
-
<div
|
|
65
|
-
className={cn(
|
|
66
|
-
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
67
|
-
className
|
|
68
|
-
)}
|
|
69
|
-
{...props}
|
|
70
|
-
/>
|
|
57
|
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
58
|
+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
|
71
59
|
);
|
|
72
60
|
DialogHeader.displayName = "DialogHeader";
|
|
73
61
|
|
|
74
|
-
const DialogFooter = ({
|
|
75
|
-
className,
|
|
76
|
-
...props
|
|
77
|
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
62
|
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
78
63
|
<div
|
|
79
|
-
className={cn(
|
|
80
|
-
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
81
|
-
className
|
|
82
|
-
)}
|
|
64
|
+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
|
83
65
|
{...props}
|
|
84
66
|
/>
|
|
85
67
|
);
|
|
@@ -91,10 +73,7 @@ const DialogTitle = React.forwardRef<
|
|
|
91
73
|
>(({ className, ...props }, ref) => (
|
|
92
74
|
<DialogPrimitive.Title
|
|
93
75
|
ref={ref}
|
|
94
|
-
className={cn(
|
|
95
|
-
"text-lg font-semibold leading-none tracking-tight",
|
|
96
|
-
className
|
|
97
|
-
)}
|
|
76
|
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
98
77
|
{...props}
|
|
99
78
|
/>
|
|
100
79
|
));
|
|
@@ -7,19 +7,14 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "../../lib/utils";
|
|
8
8
|
|
|
9
9
|
const labelVariants = cva(
|
|
10
|
-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const Label = React.forwardRef<
|
|
14
14
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
15
|
-
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
16
|
-
VariantProps<typeof labelVariants>
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
|
17
16
|
>(({ className, ...props }, ref) => (
|
|
18
|
-
<LabelPrimitive.Root
|
|
19
|
-
ref={ref}
|
|
20
|
-
className={cn(labelVariants(), className)}
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
17
|
+
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
|
23
18
|
));
|
|
24
19
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
25
20
|
|
|
@@ -8,24 +8,19 @@ import { cn } from "../../lib/utils";
|
|
|
8
8
|
const Separator = React.forwardRef<
|
|
9
9
|
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
10
10
|
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
11
|
-
>(
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
28
|
-
);
|
|
11
|
+
>(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
|
|
12
|
+
<SeparatorPrimitive.Root
|
|
13
|
+
ref={ref}
|
|
14
|
+
decorative={decorative}
|
|
15
|
+
orientation={orientation}
|
|
16
|
+
className={cn(
|
|
17
|
+
"shrink-0 bg-border",
|
|
18
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
29
24
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
30
25
|
|
|
31
26
|
export { Separator };
|
|
@@ -2,8 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils";
|
|
4
4
|
|
|
5
|
-
export interface TextareaProps
|
|
6
|
-
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
5
|
+
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
7
6
|
|
|
8
7
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
9
8
|
({ className, ...props }, ref) => {
|
|
@@ -11,13 +10,13 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
11
10
|
<textarea
|
|
12
11
|
className={cn(
|
|
13
12
|
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
14
|
-
className
|
|
13
|
+
className,
|
|
15
14
|
)}
|
|
16
15
|
ref={ref}
|
|
17
16
|
{...props}
|
|
18
17
|
/>
|
|
19
18
|
);
|
|
20
|
-
}
|
|
19
|
+
},
|
|
21
20
|
);
|
|
22
21
|
Textarea.displayName = "Textarea";
|
|
23
22
|
|
|
@@ -16,11 +16,11 @@ export interface UseAutosuggestionsResult {
|
|
|
16
16
|
|
|
17
17
|
export function useAutosuggestions(
|
|
18
18
|
debounceTime: number,
|
|
19
|
-
|
|
19
|
+
shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean,
|
|
20
20
|
autosuggestionFunction: AutosuggestionsBareFunction,
|
|
21
21
|
insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,
|
|
22
22
|
disableWhenEmpty: boolean,
|
|
23
|
-
disabled: boolean
|
|
23
|
+
disabled: boolean,
|
|
24
24
|
): UseAutosuggestionsResult {
|
|
25
25
|
const [previousAutocompleteState, setPreviousAutocompleteState] =
|
|
26
26
|
useState<EditorAutocompleteState | null>(null);
|
|
@@ -30,12 +30,9 @@ export function useAutosuggestions(
|
|
|
30
30
|
|
|
31
31
|
const awaitForAndAppendSuggestion: (
|
|
32
32
|
editorAutocompleteState: EditorAutocompleteState,
|
|
33
|
-
abortSignal: AbortSignal
|
|
33
|
+
abortSignal: AbortSignal,
|
|
34
34
|
) => Promise<void> = useCallback(
|
|
35
|
-
async (
|
|
36
|
-
editorAutocompleteState: EditorAutocompleteState,
|
|
37
|
-
abortSignal: AbortSignal
|
|
38
|
-
) => {
|
|
35
|
+
async (editorAutocompleteState: EditorAutocompleteState, abortSignal: AbortSignal) => {
|
|
39
36
|
// early return if disabled
|
|
40
37
|
if (disabled) {
|
|
41
38
|
return;
|
|
@@ -50,10 +47,7 @@ export function useAutosuggestions(
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// fetch the suggestion
|
|
53
|
-
const suggestion = await autosuggestionFunction(
|
|
54
|
-
editorAutocompleteState,
|
|
55
|
-
abortSignal
|
|
56
|
-
);
|
|
50
|
+
const suggestion = await autosuggestionFunction(editorAutocompleteState, abortSignal);
|
|
57
51
|
|
|
58
52
|
// We'll assume for now that the autocomplete function might or might not respect the abort signal.
|
|
59
53
|
if (!suggestion || abortSignal.aborted) {
|
|
@@ -65,20 +59,12 @@ export function useAutosuggestions(
|
|
|
65
59
|
point: editorAutocompleteState.cursorPoint,
|
|
66
60
|
});
|
|
67
61
|
},
|
|
68
|
-
[
|
|
69
|
-
autosuggestionFunction,
|
|
70
|
-
setCurrentAutocompleteSuggestion,
|
|
71
|
-
disableWhenEmpty,
|
|
72
|
-
disabled,
|
|
73
|
-
]
|
|
62
|
+
[autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled],
|
|
74
63
|
);
|
|
75
64
|
|
|
76
65
|
const debouncedFunction = useMemo(
|
|
77
|
-
() =>
|
|
78
|
-
|
|
79
|
-
debounceTime
|
|
80
|
-
),
|
|
81
|
-
[debounceTime]
|
|
66
|
+
() => new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(debounceTime),
|
|
67
|
+
[debounceTime],
|
|
82
68
|
);
|
|
83
69
|
|
|
84
70
|
// clean current state when unmounting or disabling
|
|
@@ -94,7 +80,7 @@ export function useAutosuggestions(
|
|
|
94
80
|
const editorStateHasChanged = !nullableCompatibleEqualityCheck(
|
|
95
81
|
areEqual_autocompleteState,
|
|
96
82
|
previousAutocompleteState,
|
|
97
|
-
newEditorState
|
|
83
|
+
newEditorState,
|
|
98
84
|
);
|
|
99
85
|
setPreviousAutocompleteState(newEditorState);
|
|
100
86
|
|
|
@@ -119,13 +105,13 @@ export function useAutosuggestions(
|
|
|
119
105
|
debouncedFunction,
|
|
120
106
|
awaitForAndAppendSuggestion,
|
|
121
107
|
setCurrentAutocompleteSuggestion,
|
|
122
|
-
]
|
|
108
|
+
],
|
|
123
109
|
);
|
|
124
110
|
|
|
125
111
|
const keyDownHandler = useCallback(
|
|
126
112
|
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
127
113
|
if (currentAutocompleteSuggestion) {
|
|
128
|
-
if (event
|
|
114
|
+
if (shouldAcceptAutosuggestionOnKeyPress(event)) {
|
|
129
115
|
event.preventDefault();
|
|
130
116
|
insertAutocompleteSuggestion(currentAutocompleteSuggestion);
|
|
131
117
|
setCurrentAutocompleteSuggestion(null);
|
|
@@ -136,8 +122,8 @@ export function useAutosuggestions(
|
|
|
136
122
|
currentAutocompleteSuggestion,
|
|
137
123
|
setCurrentAutocompleteSuggestion,
|
|
138
124
|
insertAutocompleteSuggestion,
|
|
139
|
-
|
|
140
|
-
]
|
|
125
|
+
shouldAcceptAutosuggestionOnKeyPress,
|
|
126
|
+
],
|
|
141
127
|
);
|
|
142
128
|
|
|
143
129
|
return {
|
|
@@ -35,11 +35,7 @@ const shouldSave: ShouldSaveToHistory = (op, prev) => {
|
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
op.type == "set_node" &&
|
|
40
|
-
"type" in op.properties &&
|
|
41
|
-
op.properties.type === excludedNodeType
|
|
42
|
-
) {
|
|
38
|
+
if (op.type == "set_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
|
|
43
39
|
return false;
|
|
44
40
|
}
|
|
45
41
|
|
|
@@ -8,16 +8,13 @@ import { CustomEditor } from "../../types/base/custom-editor";
|
|
|
8
8
|
|
|
9
9
|
export function usePopulateCopilotTextareaRef(
|
|
10
10
|
editor: Editor,
|
|
11
|
-
ref: React.Ref<HTMLCopilotTextAreaElement
|
|
11
|
+
ref: React.Ref<HTMLCopilotTextAreaElement>,
|
|
12
12
|
) {
|
|
13
13
|
React.useImperativeHandle(
|
|
14
14
|
ref,
|
|
15
15
|
() => {
|
|
16
16
|
class Combined {
|
|
17
|
-
constructor(
|
|
18
|
-
private customMethods: CustomMethods,
|
|
19
|
-
private editorHtmlElement: HTMLElement
|
|
20
|
-
) {}
|
|
17
|
+
constructor(private customMethods: CustomMethods, private editorHtmlElement: HTMLElement) {}
|
|
21
18
|
|
|
22
19
|
[key: string]: any;
|
|
23
20
|
|
|
@@ -62,11 +59,7 @@ export function usePopulateCopilotTextareaRef(
|
|
|
62
59
|
get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {
|
|
63
60
|
return target.get(target, propKey);
|
|
64
61
|
},
|
|
65
|
-
set(
|
|
66
|
-
target: any,
|
|
67
|
-
propKey: keyof CustomMethods | keyof HTMLElement,
|
|
68
|
-
value: any
|
|
69
|
-
) {
|
|
62
|
+
set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {
|
|
70
63
|
return target.set(target, propKey, value);
|
|
71
64
|
},
|
|
72
65
|
};
|
|
@@ -96,6 +89,6 @@ export function usePopulateCopilotTextareaRef(
|
|
|
96
89
|
const combined = new Combined(customMethods, editorHtmlElement);
|
|
97
90
|
return new Proxy(combined, handler);
|
|
98
91
|
},
|
|
99
|
-
[editor]
|
|
92
|
+
[editor],
|
|
100
93
|
);
|
|
101
94
|
}
|
package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
CHANGED
|
@@ -24,7 +24,7 @@ import { SuggestionsApiConfig } from "../../types/autosuggestions-config/suggest
|
|
|
24
24
|
export function useMakeStandardAutosuggestionFunction(
|
|
25
25
|
textareaPurpose: string,
|
|
26
26
|
contextCategories: string[],
|
|
27
|
-
apiConfig: SuggestionsApiConfig
|
|
27
|
+
apiConfig: SuggestionsApiConfig,
|
|
28
28
|
): AutosuggestionsBareFunction {
|
|
29
29
|
const { getContextString, copilotApiConfig } = useContext(CopilotContext);
|
|
30
30
|
|
|
@@ -36,7 +36,7 @@ export function useMakeStandardAutosuggestionFunction(
|
|
|
36
36
|
role: "system",
|
|
37
37
|
content: apiConfig.makeSystemPrompt(
|
|
38
38
|
textareaPurpose,
|
|
39
|
-
getContextString([], contextCategories)
|
|
39
|
+
getContextString([], contextCategories),
|
|
40
40
|
),
|
|
41
41
|
},
|
|
42
42
|
...apiConfig.fewShotMessages,
|
|
@@ -52,13 +52,8 @@ export function useMakeStandardAutosuggestionFunction(
|
|
|
52
52
|
},
|
|
53
53
|
];
|
|
54
54
|
|
|
55
|
-
const apiEndpoint =
|
|
56
|
-
|
|
57
|
-
const stream = await apiEndpoint.run(
|
|
58
|
-
abortSignal,
|
|
59
|
-
messages,
|
|
60
|
-
apiConfig.forwardedParams
|
|
61
|
-
);
|
|
55
|
+
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
56
|
+
const stream = await apiEndpoint.run(abortSignal, messages, apiConfig.forwardedParams);
|
|
62
57
|
|
|
63
58
|
// read the stream:
|
|
64
59
|
const reader = stream.getReader();
|
|
@@ -77,6 +72,6 @@ export function useMakeStandardAutosuggestionFunction(
|
|
|
77
72
|
|
|
78
73
|
return res;
|
|
79
74
|
},
|
|
80
|
-
[apiConfig, getContextString, contextCategories, textareaPurpose]
|
|
75
|
+
[apiConfig, getContextString, contextCategories, textareaPurpose],
|
|
81
76
|
);
|
|
82
77
|
}
|
|
@@ -29,7 +29,7 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
29
29
|
textareaPurpose: string,
|
|
30
30
|
contextCategories: string[],
|
|
31
31
|
insertionApiConfig: InsertionsApiConfig,
|
|
32
|
-
editingApiConfig: EditingApiConfig
|
|
32
|
+
editingApiConfig: EditingApiConfig,
|
|
33
33
|
): Generator_InsertionOrEditingSuggestion {
|
|
34
34
|
const { getContextString, copilotApiConfig } = useContext(CopilotContext);
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
38
38
|
editorState: EditingEditorState,
|
|
39
39
|
insertionPrompt: string,
|
|
40
40
|
documents: DocumentPointer[],
|
|
41
|
-
abortSignal: AbortSignal
|
|
41
|
+
abortSignal: AbortSignal,
|
|
42
42
|
) => {
|
|
43
43
|
const res = await retry(async () => {
|
|
44
44
|
const messages: MinimalChatGPTMessage[] = [
|
|
@@ -46,7 +46,7 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
46
46
|
role: "system",
|
|
47
47
|
content: insertionApiConfig.makeSystemPrompt(
|
|
48
48
|
textareaPurpose,
|
|
49
|
-
getContextString(documents, contextCategories)
|
|
49
|
+
getContextString(documents, contextCategories),
|
|
50
50
|
),
|
|
51
51
|
},
|
|
52
52
|
...insertionApiConfig.fewShotMessages,
|
|
@@ -67,18 +67,13 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
67
67
|
},
|
|
68
68
|
];
|
|
69
69
|
|
|
70
|
-
const apiEndpoint =
|
|
71
|
-
|
|
72
|
-
return await apiEndpoint.run(
|
|
73
|
-
abortSignal,
|
|
74
|
-
messages,
|
|
75
|
-
insertionApiConfig.forwardedParams
|
|
76
|
-
);
|
|
70
|
+
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
71
|
+
return await apiEndpoint.run(abortSignal, messages, insertionApiConfig.forwardedParams);
|
|
77
72
|
});
|
|
78
73
|
|
|
79
74
|
return res;
|
|
80
75
|
},
|
|
81
|
-
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
76
|
+
[insertionApiConfig, getContextString, contextCategories, textareaPurpose],
|
|
82
77
|
);
|
|
83
78
|
|
|
84
79
|
const editingFunction = useCallback(
|
|
@@ -86,7 +81,7 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
86
81
|
editorState: EditingEditorState,
|
|
87
82
|
editingPrompt: string,
|
|
88
83
|
documents: DocumentPointer[],
|
|
89
|
-
abortSignal: AbortSignal
|
|
84
|
+
abortSignal: AbortSignal,
|
|
90
85
|
) => {
|
|
91
86
|
const res = await retry(async () => {
|
|
92
87
|
const messages: MinimalChatGPTMessage[] = [
|
|
@@ -94,7 +89,7 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
94
89
|
role: "system",
|
|
95
90
|
content: editingApiConfig.makeSystemPrompt(
|
|
96
91
|
textareaPurpose,
|
|
97
|
-
getContextString(documents, contextCategories)
|
|
92
|
+
getContextString(documents, contextCategories),
|
|
98
93
|
),
|
|
99
94
|
},
|
|
100
95
|
...editingApiConfig.fewShotMessages,
|
|
@@ -120,18 +115,13 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
120
115
|
},
|
|
121
116
|
];
|
|
122
117
|
|
|
123
|
-
const apiEndpoint =
|
|
124
|
-
|
|
125
|
-
return await apiEndpoint.run(
|
|
126
|
-
abortSignal,
|
|
127
|
-
messages,
|
|
128
|
-
editingApiConfig.forwardedParams
|
|
129
|
-
);
|
|
118
|
+
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
119
|
+
return await apiEndpoint.run(abortSignal, messages, editingApiConfig.forwardedParams);
|
|
130
120
|
});
|
|
131
121
|
|
|
132
122
|
return res;
|
|
133
123
|
},
|
|
134
|
-
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
124
|
+
[editingApiConfig, getContextString, contextCategories, textareaPurpose],
|
|
135
125
|
);
|
|
136
126
|
|
|
137
127
|
const insertionOrEditingFunction = useCallback(
|
|
@@ -139,25 +129,15 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
139
129
|
editorState: EditingEditorState,
|
|
140
130
|
insertionPrompt: string,
|
|
141
131
|
documents: DocumentPointer[],
|
|
142
|
-
abortSignal: AbortSignal
|
|
132
|
+
abortSignal: AbortSignal,
|
|
143
133
|
) => {
|
|
144
134
|
if (editorState.selectedText === "") {
|
|
145
|
-
return await insertionFunction(
|
|
146
|
-
editorState,
|
|
147
|
-
insertionPrompt,
|
|
148
|
-
documents,
|
|
149
|
-
abortSignal
|
|
150
|
-
);
|
|
135
|
+
return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);
|
|
151
136
|
} else {
|
|
152
|
-
return await editingFunction(
|
|
153
|
-
editorState,
|
|
154
|
-
insertionPrompt,
|
|
155
|
-
documents,
|
|
156
|
-
abortSignal
|
|
157
|
-
);
|
|
137
|
+
return await editingFunction(editorState, insertionPrompt, documents, abortSignal);
|
|
158
138
|
}
|
|
159
139
|
},
|
|
160
|
-
[insertionFunction, editingFunction]
|
|
140
|
+
[insertionFunction, editingFunction],
|
|
161
141
|
);
|
|
162
142
|
|
|
163
143
|
return insertionOrEditingFunction;
|