@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
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
import { addAutocompletionsToEditor } from "../../lib/slatejs-edits/add-autocompletions";
|
|
13
13
|
import { clearAutocompletionsFromEditor } from "../../lib/slatejs-edits/clear-autocompletions";
|
|
14
14
|
import { replaceEditorText } from "../../lib/slatejs-edits/replace-text";
|
|
15
|
-
import {
|
|
16
|
-
BaseAutosuggestionsConfig,
|
|
17
|
-
defaultBaseAutosuggestionsConfig,
|
|
18
|
-
} from "../../types/base";
|
|
15
|
+
import { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from "../../types/base";
|
|
19
16
|
import { AutosuggestionState } from "../../types/base/autosuggestion-state";
|
|
20
17
|
import { BaseCopilotTextareaProps } from "../../types/base/base-copilot-textarea-props";
|
|
21
18
|
import "./base-copilot-textarea.css";
|
|
@@ -37,20 +34,15 @@ export interface HTMLCopilotTextAreaElement extends HTMLElement {
|
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
40
|
-
(
|
|
41
|
-
props: BaseCopilotTextareaProps,
|
|
42
|
-
ref: React.Ref<HTMLCopilotTextAreaElement>
|
|
43
|
-
): JSX.Element => {
|
|
37
|
+
(props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {
|
|
44
38
|
const autosuggestionsConfig: BaseAutosuggestionsConfig = {
|
|
45
39
|
...defaultBaseAutosuggestionsConfig,
|
|
46
40
|
...props.baseAutosuggestionsConfig,
|
|
47
41
|
};
|
|
48
42
|
|
|
49
43
|
const valueOnInitialRender = useMemo(() => props.value ?? "", []);
|
|
50
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] =
|
|
51
|
-
|
|
52
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] =
|
|
53
|
-
useState(false);
|
|
44
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);
|
|
45
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);
|
|
54
46
|
|
|
55
47
|
// // When the editor text changes, we want to reset the `textEditedSinceLastCursorMovement` state.
|
|
56
48
|
// useEffect(() => {
|
|
@@ -68,10 +60,8 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
68
60
|
|
|
69
61
|
const editor = useCopilotTextareaEditor();
|
|
70
62
|
|
|
71
|
-
const {
|
|
72
|
-
|
|
73
|
-
setIsDisplayed: setHoveringEditorIsDisplayed,
|
|
74
|
-
} = useHoveringEditorContext();
|
|
63
|
+
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } =
|
|
64
|
+
useHoveringEditorContext();
|
|
75
65
|
|
|
76
66
|
const insertText = useCallback(
|
|
77
67
|
(autosuggestion: AutosuggestionState) => {
|
|
@@ -79,33 +69,43 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
79
69
|
at: autosuggestion.point,
|
|
80
70
|
});
|
|
81
71
|
},
|
|
82
|
-
[editor]
|
|
72
|
+
[editor],
|
|
83
73
|
);
|
|
84
74
|
|
|
75
|
+
const shouldDisableAutosuggestions =
|
|
76
|
+
// textarea is manually disabled:
|
|
77
|
+
autosuggestionsConfig.disabled ||
|
|
78
|
+
// hovering editor is displayed:
|
|
79
|
+
hoveringEditorIsDisplayed ||
|
|
80
|
+
// the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:
|
|
81
|
+
(cursorMovedSinceLastTextChange &&
|
|
82
|
+
autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText);
|
|
83
|
+
|
|
85
84
|
const {
|
|
86
85
|
currentAutocompleteSuggestion,
|
|
87
86
|
onChangeHandler: onChangeHandlerForAutocomplete,
|
|
88
87
|
onKeyDownHandler: onKeyDownHandlerForAutocomplete,
|
|
89
88
|
} = useAutosuggestions(
|
|
90
89
|
autosuggestionsConfig.debounceTime,
|
|
91
|
-
autosuggestionsConfig.
|
|
90
|
+
autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,
|
|
92
91
|
autosuggestionsConfig.apiConfig.autosuggestionsFunction,
|
|
93
92
|
insertText,
|
|
94
93
|
autosuggestionsConfig.disableWhenEmpty,
|
|
95
|
-
|
|
96
|
-
hoveringEditorIsDisplayed || // disable autosuggestions when the hovering editor is displayed
|
|
97
|
-
(cursorMovedSinceLastTextChange &&
|
|
98
|
-
autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText) // disable autosuggestions when the cursor has moved since the last text change
|
|
94
|
+
shouldDisableAutosuggestions,
|
|
99
95
|
);
|
|
96
|
+
|
|
100
97
|
const onKeyDownHandlerForHoveringEditor = useCallback(
|
|
101
98
|
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
102
|
-
|
|
103
|
-
if (event.key === "k" && event.metaKey) {
|
|
99
|
+
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {
|
|
104
100
|
event.preventDefault();
|
|
105
101
|
setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);
|
|
106
102
|
}
|
|
107
103
|
},
|
|
108
|
-
[
|
|
104
|
+
[
|
|
105
|
+
hoveringEditorIsDisplayed,
|
|
106
|
+
setHoveringEditorIsDisplayed,
|
|
107
|
+
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress,
|
|
108
|
+
],
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
// sync autosuggestions state with the editor
|
|
@@ -115,7 +115,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
115
115
|
addAutocompletionsToEditor(
|
|
116
116
|
editor,
|
|
117
117
|
currentAutocompleteSuggestion.text,
|
|
118
|
-
currentAutocompleteSuggestion.point
|
|
118
|
+
currentAutocompleteSuggestion.point,
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
}, [currentAutocompleteSuggestion]);
|
|
@@ -177,10 +177,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
177
177
|
const baseClassName = "copilot-textarea";
|
|
178
178
|
const brandingClass = disableBranding ? "no-branding" : "with-branding";
|
|
179
179
|
const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
|
|
180
|
-
const mergedClassName = twMerge(
|
|
181
|
-
defaultTailwindClassName,
|
|
182
|
-
className ?? ""
|
|
183
|
-
);
|
|
180
|
+
const mergedClassName = twMerge(defaultTailwindClassName, className ?? "");
|
|
184
181
|
return `${baseClassName} ${brandingClass} ${mergedClassName}`;
|
|
185
182
|
})();
|
|
186
183
|
|
|
@@ -228,7 +225,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
228
225
|
/>
|
|
229
226
|
</Slate>
|
|
230
227
|
);
|
|
231
|
-
}
|
|
228
|
+
},
|
|
232
229
|
);
|
|
233
230
|
|
|
234
231
|
// Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.
|
|
@@ -243,7 +240,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
|
243
240
|
//
|
|
244
241
|
// If this proves problematic, we can always revisit this decision.
|
|
245
242
|
function makeSemiFakeReactTextAreaEvent(
|
|
246
|
-
currentText: string
|
|
243
|
+
currentText: string,
|
|
247
244
|
): React.ChangeEvent<HTMLTextAreaElement> {
|
|
248
245
|
return {
|
|
249
246
|
target: {
|
|
@@ -258,14 +255,11 @@ function makeSemiFakeReactTextAreaEvent(
|
|
|
258
255
|
}
|
|
259
256
|
|
|
260
257
|
export const BaseCopilotTextarea = React.forwardRef(
|
|
261
|
-
(
|
|
262
|
-
props: BaseCopilotTextareaProps,
|
|
263
|
-
ref: React.Ref<HTMLCopilotTextAreaElement>
|
|
264
|
-
): JSX.Element => {
|
|
258
|
+
(props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {
|
|
265
259
|
return (
|
|
266
260
|
<HoveringEditorProvider>
|
|
267
261
|
<BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />
|
|
268
262
|
</HoveringEditorProvider>
|
|
269
263
|
);
|
|
270
|
-
}
|
|
264
|
+
},
|
|
271
265
|
);
|
|
@@ -3,16 +3,14 @@ import { RenderElementProps } from "slate-react";
|
|
|
3
3
|
export type RenderElementFunction = (props: RenderElementProps) => JSX.Element;
|
|
4
4
|
|
|
5
5
|
export function makeRenderElementFunction(
|
|
6
|
-
suggestionsStyle: React.CSSProperties
|
|
6
|
+
suggestionsStyle: React.CSSProperties,
|
|
7
7
|
): RenderElementFunction {
|
|
8
8
|
return (props: RenderElementProps) => {
|
|
9
9
|
switch (props.element.type) {
|
|
10
10
|
case "paragraph":
|
|
11
11
|
return <DefaultElement {...props} />;
|
|
12
12
|
case "suggestion":
|
|
13
|
-
return
|
|
14
|
-
<SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />
|
|
15
|
-
);
|
|
13
|
+
return <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />;
|
|
16
14
|
}
|
|
17
15
|
};
|
|
18
16
|
}
|
|
@@ -23,7 +21,7 @@ const DefaultElement = (props: RenderElementProps) => {
|
|
|
23
21
|
const SuggestionElement = (
|
|
24
22
|
props: RenderElementProps & {
|
|
25
23
|
suggestionsStyle: React.CSSProperties;
|
|
26
|
-
}
|
|
24
|
+
},
|
|
27
25
|
) => {
|
|
28
26
|
return (
|
|
29
27
|
<span
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { RenderElementProps, RenderPlaceholderProps } from "slate-react";
|
|
2
2
|
|
|
3
|
-
export type RenderPlaceholderFunction = (
|
|
4
|
-
props: RenderPlaceholderProps
|
|
5
|
-
) => JSX.Element;
|
|
3
|
+
export type RenderPlaceholderFunction = (props: RenderPlaceholderProps) => JSX.Element;
|
|
6
4
|
|
|
7
5
|
export function makeRenderPlaceholderFunction(
|
|
8
|
-
placeholderStyle?: React.CSSProperties
|
|
6
|
+
placeholderStyle?: React.CSSProperties,
|
|
9
7
|
): RenderPlaceholderFunction {
|
|
10
8
|
return (props: RenderPlaceholderProps) => {
|
|
11
9
|
const { style, ...restAttributes } = props.attributes;
|
|
@@ -8,7 +8,7 @@ interface TrackerTextEditedSinceLastCursorMovementProps {
|
|
|
8
8
|
setCursorMovedSinceLastTextChange: (value: boolean) => void;
|
|
9
9
|
}
|
|
10
10
|
export function TrackerTextEditedSinceLastCursorMovement(
|
|
11
|
-
props: TrackerTextEditedSinceLastCursorMovementProps
|
|
11
|
+
props: TrackerTextEditedSinceLastCursorMovementProps,
|
|
12
12
|
): JSX.Element {
|
|
13
13
|
const cursorState: RelevantEditorState = useSlateSelector((state) => ({
|
|
14
14
|
selection: state.selection,
|
|
@@ -33,10 +33,7 @@ type RelevantEditorState = {
|
|
|
33
33
|
selection: BaseSelection;
|
|
34
34
|
text: string;
|
|
35
35
|
};
|
|
36
|
-
const cursorChangedWithoutTextChanged = (
|
|
37
|
-
prev: RelevantEditorState,
|
|
38
|
-
next: RelevantEditorState
|
|
39
|
-
) => {
|
|
36
|
+
const cursorChangedWithoutTextChanged = (prev: RelevantEditorState, next: RelevantEditorState) => {
|
|
40
37
|
// Check if the selection has changed
|
|
41
38
|
const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
|
|
42
39
|
|
|
@@ -2,7 +2,7 @@ import { useEffect } from "react";
|
|
|
2
2
|
|
|
3
3
|
export function useAddBrandingCss(
|
|
4
4
|
suggestionStyleAugmented: React.CSSProperties,
|
|
5
|
-
disableBranding: boolean | undefined
|
|
5
|
+
disableBranding: boolean | undefined,
|
|
6
6
|
) {
|
|
7
7
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
8
8
|
useEffect(() => {
|
|
@@ -18,9 +18,7 @@ export function useAddBrandingCss(
|
|
|
18
18
|
// Build the CSS string dynamically
|
|
19
19
|
let dynamicStyles = Object.entries(suggestionStyleAugmented)
|
|
20
20
|
.map(([key, value]) => {
|
|
21
|
-
const kebabCaseKey = key
|
|
22
|
-
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
23
|
-
.toLowerCase();
|
|
21
|
+
const kebabCaseKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
24
22
|
return `${kebabCaseKey}: ${value};`;
|
|
25
23
|
})
|
|
26
24
|
.join(" ");
|
|
@@ -20,34 +20,27 @@ export interface CopilotTextareaProps
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const CopilotTextarea = React.forwardRef(
|
|
23
|
-
(
|
|
24
|
-
props: CopilotTextareaProps,
|
|
25
|
-
ref: React.Ref<HTMLCopilotTextAreaElement>
|
|
26
|
-
): JSX.Element => {
|
|
23
|
+
(props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {
|
|
27
24
|
// separate the AutosuggestionsConfigUserSpecified from the rest of the props
|
|
28
|
-
const {
|
|
29
|
-
autosuggestionsConfig: autosuggestionsConfigUserSpecified,
|
|
30
|
-
...forwardedProps
|
|
31
|
-
} = props;
|
|
25
|
+
const { autosuggestionsConfig: autosuggestionsConfigUserSpecified, ...forwardedProps } = props;
|
|
32
26
|
|
|
33
27
|
const autosuggestionsConfig: AutosuggestionsConfig = merge(
|
|
34
28
|
defaultAutosuggestionsConfig,
|
|
35
|
-
autosuggestionsConfigUserSpecified
|
|
29
|
+
autosuggestionsConfigUserSpecified,
|
|
36
30
|
);
|
|
37
31
|
|
|
38
32
|
const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(
|
|
39
33
|
autosuggestionsConfig.textareaPurpose,
|
|
40
34
|
autosuggestionsConfig.contextCategories,
|
|
41
|
-
autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig
|
|
35
|
+
autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig,
|
|
42
36
|
);
|
|
43
37
|
|
|
44
|
-
const insertionOrEditingFunction =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
38
|
+
const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(
|
|
39
|
+
autosuggestionsConfig.textareaPurpose,
|
|
40
|
+
autosuggestionsConfig.contextCategories,
|
|
41
|
+
autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
|
|
42
|
+
autosuggestionsConfig.chatApiConfigs.editingApiConfig,
|
|
43
|
+
);
|
|
51
44
|
|
|
52
45
|
return (
|
|
53
46
|
<>
|
|
@@ -64,5 +57,5 @@ export const CopilotTextarea = React.forwardRef(
|
|
|
64
57
|
/>
|
|
65
58
|
</>
|
|
66
59
|
);
|
|
67
|
-
}
|
|
60
|
+
},
|
|
68
61
|
);
|
|
@@ -14,9 +14,7 @@ interface HoveringEditorProviderProps {
|
|
|
14
14
|
children: ReactNode;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const HoveringEditorProvider = ({
|
|
18
|
-
children,
|
|
19
|
-
}: HoveringEditorProviderProps) => {
|
|
17
|
+
export const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {
|
|
20
18
|
const [isDisplayed, setIsDisplayed] = useState(false);
|
|
21
19
|
|
|
22
20
|
return (
|
|
@@ -20,7 +20,7 @@ export const Button = React.forwardRef(
|
|
|
20
20
|
reversed: boolean;
|
|
21
21
|
} & BaseProps
|
|
22
22
|
>,
|
|
23
|
-
ref: Ref<HTMLSpanElement | null
|
|
23
|
+
ref: Ref<HTMLSpanElement | null>,
|
|
24
24
|
) => (
|
|
25
25
|
<span
|
|
26
26
|
{...props}
|
|
@@ -29,24 +29,15 @@ export const Button = React.forwardRef(
|
|
|
29
29
|
className,
|
|
30
30
|
css`
|
|
31
31
|
cursor: pointer;
|
|
32
|
-
color: ${reversed
|
|
33
|
-
|
|
34
|
-
? "white"
|
|
35
|
-
: "#aaa"
|
|
36
|
-
: active
|
|
37
|
-
? "black"
|
|
38
|
-
: "#ccc"};
|
|
39
|
-
`
|
|
32
|
+
color: ${reversed ? (active ? "white" : "#aaa") : active ? "black" : "#ccc"};
|
|
33
|
+
`,
|
|
40
34
|
)}
|
|
41
35
|
/>
|
|
42
|
-
)
|
|
36
|
+
),
|
|
43
37
|
);
|
|
44
38
|
|
|
45
39
|
export const Icon = React.forwardRef(
|
|
46
|
-
(
|
|
47
|
-
{ className, ...props }: PropsWithChildren<BaseProps>,
|
|
48
|
-
ref: Ref<HTMLSpanElement | null>
|
|
49
|
-
) => (
|
|
40
|
+
({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLSpanElement | null>) => (
|
|
50
41
|
<span
|
|
51
42
|
{...props}
|
|
52
43
|
ref={ref as Ref<HTMLSpanElement>}
|
|
@@ -56,17 +47,14 @@ export const Icon = React.forwardRef(
|
|
|
56
47
|
css`
|
|
57
48
|
font-size: 18px;
|
|
58
49
|
vertical-align: text-bottom;
|
|
59
|
-
|
|
50
|
+
`,
|
|
60
51
|
)}
|
|
61
52
|
/>
|
|
62
|
-
)
|
|
53
|
+
),
|
|
63
54
|
);
|
|
64
55
|
|
|
65
56
|
export const Menu = React.forwardRef(
|
|
66
|
-
(
|
|
67
|
-
{ className, ...props }: PropsWithChildren<BaseProps>,
|
|
68
|
-
ref: Ref<HTMLDivElement | null>
|
|
69
|
-
) => (
|
|
57
|
+
({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLDivElement | null>) => (
|
|
70
58
|
<div
|
|
71
59
|
{...props}
|
|
72
60
|
data-test-id="menu"
|
|
@@ -81,22 +69,17 @@ export const Menu = React.forwardRef(
|
|
|
81
69
|
& > * + * {
|
|
82
70
|
margin-left: 15px;
|
|
83
71
|
}
|
|
84
|
-
|
|
72
|
+
`,
|
|
85
73
|
)}
|
|
86
74
|
/>
|
|
87
|
-
)
|
|
75
|
+
),
|
|
88
76
|
);
|
|
89
77
|
export const Portal = ({ children }: { children: React.ReactNode }) => {
|
|
90
|
-
return typeof document === "object"
|
|
91
|
-
? ReactDOM.createPortal(children, document.body)
|
|
92
|
-
: null;
|
|
78
|
+
return typeof document === "object" ? ReactDOM.createPortal(children, document.body) : null;
|
|
93
79
|
};
|
|
94
80
|
|
|
95
81
|
export const Toolbar = React.forwardRef(
|
|
96
|
-
(
|
|
97
|
-
{ className, ...props }: PropsWithChildren<BaseProps>,
|
|
98
|
-
ref?: Ref<HTMLDivElement>
|
|
99
|
-
) => (
|
|
82
|
+
({ className, ...props }: PropsWithChildren<BaseProps>, ref?: Ref<HTMLDivElement>) => (
|
|
100
83
|
<Menu
|
|
101
84
|
{...props}
|
|
102
85
|
ref={ref}
|
|
@@ -108,8 +91,8 @@ export const Toolbar = React.forwardRef(
|
|
|
108
91
|
margin: 0 -20px;
|
|
109
92
|
border-bottom: 2px solid #eee;
|
|
110
93
|
margin-bottom: 20px;
|
|
111
|
-
|
|
94
|
+
`,
|
|
112
95
|
)}
|
|
113
96
|
/>
|
|
114
|
-
)
|
|
97
|
+
),
|
|
115
98
|
);
|
|
@@ -20,9 +20,7 @@ export interface HoveringToolbarProps {
|
|
|
20
20
|
hoverMenuClassname: string | undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const HoveringToolbar: (
|
|
24
|
-
props: HoveringToolbarProps
|
|
25
|
-
) => JSX.Element | null = (props) => {
|
|
23
|
+
export const HoveringToolbar: (props: HoveringToolbarProps) => JSX.Element | null = (props) => {
|
|
26
24
|
const ref = useRef<HTMLDivElement>(null);
|
|
27
25
|
const editor = useSlate();
|
|
28
26
|
const selection = useSlateSelection();
|
|
@@ -59,20 +57,14 @@ export const HoveringToolbar: (
|
|
|
59
57
|
// but inside the hovering window.
|
|
60
58
|
//
|
|
61
59
|
// in such case, we simply do nothing.
|
|
62
|
-
if (
|
|
63
|
-
rect.top === 0 &&
|
|
64
|
-
rect.left === 0 &&
|
|
65
|
-
rect.width === 0 &&
|
|
66
|
-
rect.height === 0
|
|
67
|
-
) {
|
|
60
|
+
if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {
|
|
68
61
|
return;
|
|
69
62
|
}
|
|
70
63
|
|
|
71
64
|
const minGapFromEdge = 60;
|
|
72
65
|
const verticalOffsetFromCorner = 35;
|
|
73
66
|
const horizontalOffsetFromCorner = 15;
|
|
74
|
-
let top =
|
|
75
|
-
rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;
|
|
67
|
+
let top = rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;
|
|
76
68
|
// make sure top is in the viewport and not too close to the edge
|
|
77
69
|
if (top < minGapFromEdge) {
|
|
78
70
|
top = rect.bottom + window.scrollY + minGapFromEdge;
|
|
@@ -81,11 +73,7 @@ export const HoveringToolbar: (
|
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
let left =
|
|
84
|
-
rect.left +
|
|
85
|
-
window.scrollX -
|
|
86
|
-
el.offsetWidth / 2 +
|
|
87
|
-
rect.width / 2 +
|
|
88
|
-
horizontalOffsetFromCorner;
|
|
76
|
+
rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;
|
|
89
77
|
// make sure left is in the viewport and not too close to the edge
|
|
90
78
|
if (left < minGapFromEdge) {
|
|
91
79
|
left = minGapFromEdge;
|
|
@@ -8,13 +8,7 @@ import { SourceSearchBox } from "../../source-search-box/source-search-box";
|
|
|
8
8
|
import { DocumentPointer } from "@copilotkit/react-core";
|
|
9
9
|
import { Button } from "../../ui/button";
|
|
10
10
|
import { Label } from "../../ui/label";
|
|
11
|
-
import React, {
|
|
12
|
-
useCallback,
|
|
13
|
-
useContext,
|
|
14
|
-
useEffect,
|
|
15
|
-
useRef,
|
|
16
|
-
useState,
|
|
17
|
-
} from "react";
|
|
11
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
18
12
|
|
|
19
13
|
import { streamPromiseFlatten } from "../../../lib/stream-promise-flatten";
|
|
20
14
|
import { CopilotContext } from "@copilotkit/react-core";
|
|
@@ -31,9 +25,7 @@ export interface HoveringInsertionPromptBoxCoreProps {
|
|
|
31
25
|
contextCategories: string[];
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
export const HoveringInsertionPromptBoxCore: React.FC<
|
|
35
|
-
HoveringInsertionPromptBoxCoreProps
|
|
36
|
-
> = ({
|
|
28
|
+
export const HoveringInsertionPromptBoxCore: React.FC<HoveringInsertionPromptBoxCoreProps> = ({
|
|
37
29
|
performInsertion,
|
|
38
30
|
state,
|
|
39
31
|
insertionOrEditingFunction,
|
|
@@ -42,13 +34,13 @@ export const HoveringInsertionPromptBoxCore: React.FC<
|
|
|
42
34
|
const { getDocumentsContext } = useContext(CopilotContext);
|
|
43
35
|
|
|
44
36
|
const [editSuggestion, setEditSuggestion] = useState<string>("");
|
|
45
|
-
const [suggestionIsLoading, setSuggestionIsLoading] =
|
|
46
|
-
useState<boolean>(false);
|
|
37
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);
|
|
47
38
|
|
|
48
39
|
const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>("");
|
|
49
40
|
|
|
50
|
-
const [generatingSuggestion, setGeneratingSuggestion] =
|
|
51
|
-
|
|
41
|
+
const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(
|
|
42
|
+
null,
|
|
43
|
+
);
|
|
52
44
|
|
|
53
45
|
const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
54
46
|
const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
@@ -97,8 +89,7 @@ export const HoveringInsertionPromptBoxCore: React.FC<
|
|
|
97
89
|
|
|
98
90
|
// Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.
|
|
99
91
|
if (suggestionTextAreaRef.current) {
|
|
100
|
-
suggestionTextAreaRef.current.scrollTop =
|
|
101
|
-
suggestionTextAreaRef.current.scrollHeight;
|
|
92
|
+
suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
|
|
102
93
|
}
|
|
103
94
|
return newSuggestion;
|
|
104
95
|
});
|
|
@@ -141,10 +132,10 @@ export const HoveringInsertionPromptBoxCore: React.FC<
|
|
|
141
132
|
modificationState,
|
|
142
133
|
adjustmentPrompt,
|
|
143
134
|
filePointers,
|
|
144
|
-
new AbortController().signal
|
|
135
|
+
new AbortController().signal,
|
|
145
136
|
);
|
|
146
137
|
const adjustmentSuggestionTextStream = streamPromiseFlatten(
|
|
147
|
-
adjustmentSuggestionTextStreamPromise
|
|
138
|
+
adjustmentSuggestionTextStreamPromise,
|
|
148
139
|
);
|
|
149
140
|
|
|
150
141
|
setGeneratingSuggestion(adjustmentSuggestionTextStream);
|
|
@@ -255,19 +246,14 @@ export const HoveringInsertionPromptBoxCore: React.FC<
|
|
|
255
246
|
<div className="w-full flex flex-col items-start relative gap-2">
|
|
256
247
|
{AdjustmentPromptComponent}
|
|
257
248
|
{filePointers.length > 0 && (
|
|
258
|
-
<IncludedFilesPreview
|
|
259
|
-
includedFiles={filePointers}
|
|
260
|
-
setIncludedFiles={setFilePointers}
|
|
261
|
-
/>
|
|
249
|
+
<IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />
|
|
262
250
|
)}
|
|
263
251
|
{sourceSearchWord !== undefined && (
|
|
264
252
|
<SourceSearchBox
|
|
265
253
|
searchTerm={sourceSearchWord}
|
|
266
254
|
suggestedFiles={suggestedFiles}
|
|
267
255
|
onSelectedFile={(filePointer) => {
|
|
268
|
-
setAdjustmentPrompt(
|
|
269
|
-
adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
|
|
270
|
-
);
|
|
256
|
+
setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""));
|
|
271
257
|
setFilePointers((prev) => [...prev, filePointer]);
|
|
272
258
|
|
|
273
259
|
// focus back on the adjustment prompt, and move the cursor to the end
|
package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
CHANGED
|
@@ -23,9 +23,7 @@ export const IncludedFilesPreview: React.FC<IncludedFilesPreviewProps> = ({
|
|
|
23
23
|
key={`file-${filePointer.sourceApplication}.${filePointer.name}`}
|
|
24
24
|
filePointer={filePointer}
|
|
25
25
|
onDelete={() => {
|
|
26
|
-
setIncludedFiles((prev) =>
|
|
27
|
-
prev.filter((fp) => fp !== filePointer)
|
|
28
|
-
);
|
|
26
|
+
setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
|
|
29
27
|
}}
|
|
30
28
|
/>
|
|
31
29
|
);
|
|
@@ -40,10 +38,7 @@ export interface FileChipPreviewProp {
|
|
|
40
38
|
onDelete: () => void;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
export const FileChipPreview: React.FC<FileChipPreviewProp> = ({
|
|
44
|
-
filePointer,
|
|
45
|
-
onDelete,
|
|
46
|
-
}) => {
|
|
41
|
+
export const FileChipPreview: React.FC<FileChipPreviewProp> = ({ filePointer, onDelete }) => {
|
|
47
42
|
return (
|
|
48
43
|
<Chip
|
|
49
44
|
label={filePointer.name}
|
|
@@ -6,21 +6,12 @@ export interface ChipWithIconProps {
|
|
|
6
6
|
iconUrl: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const ChipWithIcon: React.FC<ChipWithIconProps> = ({
|
|
10
|
-
label,
|
|
11
|
-
onDelete,
|
|
12
|
-
iconUrl,
|
|
13
|
-
}) => {
|
|
9
|
+
export const ChipWithIcon: React.FC<ChipWithIconProps> = ({ label, onDelete, iconUrl }) => {
|
|
14
10
|
return (
|
|
15
11
|
<span className="inline-flex items-center px-3 py-1 rounded-full bg-slate-200 text-sm font-medium text-white">
|
|
16
|
-
{iconUrl &&
|
|
17
|
-
<img src={iconUrl} alt="icon" className="w-4 h-4 rounded-full mr-2" />
|
|
18
|
-
)}
|
|
12
|
+
{iconUrl && <img src={iconUrl} alt="icon" className="w-4 h-4 rounded-full mr-2" />}
|
|
19
13
|
{label}
|
|
20
|
-
<button
|
|
21
|
-
className="ml-2 text-white hover:text-gray-200 focus:outline-none"
|
|
22
|
-
onClick={onDelete}
|
|
23
|
-
>
|
|
14
|
+
<button className="ml-2 text-white hover:text-gray-200 focus:outline-none" onClick={onDelete}>
|
|
24
15
|
x
|
|
25
16
|
</button>
|
|
26
17
|
</span>
|
|
@@ -11,14 +11,7 @@ import {
|
|
|
11
11
|
CommandShortcut,
|
|
12
12
|
} from "../ui/command";
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
Calculator,
|
|
16
|
-
Calendar,
|
|
17
|
-
CreditCard,
|
|
18
|
-
Settings,
|
|
19
|
-
Smile,
|
|
20
|
-
User,
|
|
21
|
-
} from "lucide-react";
|
|
14
|
+
import { Calculator, Calendar, CreditCard, Settings, Smile, User } from "lucide-react";
|
|
22
15
|
|
|
23
16
|
import { DocumentPointer } from "@copilotkit/react-core";
|
|
24
17
|
|
|
@@ -117,10 +110,7 @@ export function Logo({
|
|
|
117
110
|
height: string;
|
|
118
111
|
}) {
|
|
119
112
|
return (
|
|
120
|
-
<div
|
|
121
|
-
className="flex items-center justify-center"
|
|
122
|
-
style={{ width: width, height: height }}
|
|
123
|
-
>
|
|
113
|
+
<div className="flex items-center justify-center" style={{ width: width, height: height }}>
|
|
124
114
|
{children}
|
|
125
115
|
</div>
|
|
126
116
|
);
|
|
@@ -10,12 +10,9 @@ const buttonVariants = cva(
|
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
12
12
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
13
|
-
destructive:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
17
|
-
secondary:
|
|
18
|
-
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
13
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
14
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19
16
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
17
|
link: "text-primary underline-offset-4 hover:underline",
|
|
21
18
|
},
|
|
@@ -30,7 +27,7 @@ const buttonVariants = cva(
|
|
|
30
27
|
variant: "default",
|
|
31
28
|
size: "default",
|
|
32
29
|
},
|
|
33
|
-
}
|
|
30
|
+
},
|
|
34
31
|
);
|
|
35
32
|
|
|
36
33
|
export interface ButtonProps
|
|
@@ -43,13 +40,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
43
40
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
44
41
|
const Comp = asChild ? Slot : "button";
|
|
45
42
|
return (
|
|
46
|
-
<Comp
|
|
47
|
-
className={cn(buttonVariants({ variant, size, className }))}
|
|
48
|
-
ref={ref}
|
|
49
|
-
{...props}
|
|
50
|
-
/>
|
|
43
|
+
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
|
|
51
44
|
);
|
|
52
|
-
}
|
|
45
|
+
},
|
|
53
46
|
);
|
|
54
47
|
Button.displayName = "Button";
|
|
55
48
|
|