@copilotkit/react-textarea 1.51.4-next.7 → 1.51.4
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/CHANGELOG.md +22 -0
- package/README.md +18 -12
- package/dist/{chunk-D47EKHIF.mjs → chunk-2X3CZVEP.mjs} +9 -3
- package/dist/chunk-2X3CZVEP.mjs.map +1 -0
- package/dist/{chunk-GU5LTWGL.mjs → chunk-3WLGLZTY.mjs} +19 -13
- package/dist/chunk-3WLGLZTY.mjs.map +1 -0
- package/dist/{chunk-DRV2FOHZ.mjs → chunk-7GZWOXE4.mjs} +2 -2
- package/dist/chunk-7GZWOXE4.mjs.map +1 -0
- package/dist/{chunk-NAFNY4FL.mjs → chunk-7V4ORVQX.mjs} +1 -1
- package/dist/chunk-7V4ORVQX.mjs.map +1 -0
- package/dist/{chunk-ECR45NSD.mjs → chunk-A6YGJFQI.mjs} +9 -2
- package/dist/chunk-A6YGJFQI.mjs.map +1 -0
- package/dist/{chunk-WGWQRALG.mjs → chunk-AHNPJMBR.mjs} +10 -3
- package/dist/chunk-AHNPJMBR.mjs.map +1 -0
- package/dist/{chunk-VSVQZUPW.mjs → chunk-ARLBRSB7.mjs} +23 -7
- package/dist/chunk-ARLBRSB7.mjs.map +1 -0
- package/dist/{chunk-72GJNLCO.mjs → chunk-AZ7RF6ED.mjs} +5 -5
- package/dist/chunk-AZ7RF6ED.mjs.map +1 -0
- package/dist/{chunk-I72DKFHD.mjs → chunk-CFCMZVQ2.mjs} +29 -7
- package/dist/chunk-CFCMZVQ2.mjs.map +1 -0
- package/dist/{chunk-T6MTDQZ7.mjs → chunk-CMKGYQFX.mjs} +1 -1
- package/dist/chunk-CMKGYQFX.mjs.map +1 -0
- package/dist/{chunk-DFTV4TST.mjs → chunk-DZMQBOPG.mjs} +1 -1
- package/dist/chunk-DZMQBOPG.mjs.map +1 -0
- package/dist/{chunk-CLGAJCZ5.mjs → chunk-E7C63KQP.mjs} +10 -6
- package/dist/chunk-E7C63KQP.mjs.map +1 -0
- package/dist/{chunk-GQN2HYFJ.mjs → chunk-EGBZSVLK.mjs} +5 -2
- package/dist/{chunk-GQN2HYFJ.mjs.map → chunk-EGBZSVLK.mjs.map} +1 -1
- package/dist/{chunk-3QJOFG3V.mjs → chunk-FTG7P3NP.mjs} +1 -1
- package/dist/chunk-FTG7P3NP.mjs.map +1 -0
- package/dist/{chunk-KMVGEY7Q.mjs → chunk-IBZTDP72.mjs} +9 -4
- package/dist/chunk-IBZTDP72.mjs.map +1 -0
- package/dist/{chunk-4PDYALMP.mjs → chunk-LYNGBKJR.mjs} +9 -3
- package/dist/chunk-LYNGBKJR.mjs.map +1 -0
- package/dist/{chunk-DL3JWL2E.mjs → chunk-M7GTVHFB.mjs} +26 -8
- package/dist/chunk-M7GTVHFB.mjs.map +1 -0
- package/dist/chunk-MQBPYOOZ.mjs +97 -0
- package/dist/chunk-MQBPYOOZ.mjs.map +1 -0
- package/dist/{chunk-6SGWO63I.mjs → chunk-MQXYWOE2.mjs} +3 -3
- package/dist/chunk-MQXYWOE2.mjs.map +1 -0
- package/dist/{chunk-F2ULK22F.mjs → chunk-NFMCLTJU.mjs} +1 -1
- package/dist/chunk-NFMCLTJU.mjs.map +1 -0
- package/dist/{chunk-F6RLSVG3.mjs → chunk-O4WCM57A.mjs} +1 -1
- package/dist/chunk-O4WCM57A.mjs.map +1 -0
- package/dist/{chunk-4NHVQZ67.mjs → chunk-PDFIUPCS.mjs} +1 -1
- package/dist/chunk-PDFIUPCS.mjs.map +1 -0
- package/dist/{chunk-7NOLZ5T3.mjs → chunk-SWX3MRZ4.mjs} +31 -22
- package/dist/chunk-SWX3MRZ4.mjs.map +1 -0
- package/dist/{chunk-QJNFNPWH.mjs → chunk-TGN3YVSO.mjs} +2 -2
- package/dist/chunk-TGN3YVSO.mjs.map +1 -0
- package/dist/{chunk-LYB4B6MK.mjs → chunk-UB4Y22EF.mjs} +4 -2
- package/dist/chunk-UB4Y22EF.mjs.map +1 -0
- package/dist/{chunk-ZQSEYPNN.mjs → chunk-UIBUYQPG.mjs} +7 -2
- package/dist/chunk-UIBUYQPG.mjs.map +1 -0
- package/dist/{chunk-AJ5OMEXM.mjs → chunk-VBPZTMXB.mjs} +2 -2
- package/dist/{chunk-EJGGLWWR.mjs → chunk-VH7INUR5.mjs} +1 -1
- package/dist/{chunk-EJGGLWWR.mjs.map → chunk-VH7INUR5.mjs.map} +1 -1
- package/dist/{chunk-7LSRNPNI.mjs → chunk-VVRGAA43.mjs} +1 -1
- package/dist/chunk-VVRGAA43.mjs.map +1 -0
- package/dist/{chunk-YLFAIYRY.mjs → chunk-VYLLLBUP.mjs} +1 -1
- package/dist/chunk-VYLLLBUP.mjs.map +1 -0
- package/dist/{chunk-2QDCE7PD.mjs → chunk-WXKPRNNO.mjs} +1 -1
- package/dist/chunk-WXKPRNNO.mjs.map +1 -0
- package/dist/{chunk-JLOABKLH.mjs → chunk-YINY56BI.mjs} +2 -2
- package/dist/{chunk-23Q6A46J.mjs → chunk-ZBP4SABT.mjs} +22 -8
- package/dist/chunk-ZBP4SABT.mjs.map +1 -0
- package/dist/{chunk-H5ZNEKUR.mjs → chunk-ZWI5KPQ5.mjs} +2 -2
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +154 -86
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +29 -29
- package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.js.map +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.js.map +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.js.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.js +190 -95
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +34 -34
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.js +3 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js +57 -63
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js +117 -77
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +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.js +60 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +11 -11
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +60 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +12 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +14 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
- 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.js +60 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +12 -12
- package/dist/components/index.js +190 -95
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +34 -34
- package/dist/components/manual-ui/chip-with-icon.d.ts +1 -1
- package/dist/components/manual-ui/chip-with-icon.js +13 -2
- package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +13 -2
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.js +28 -5
- package/dist/components/source-search-box/source-search-box.js.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +4 -4
- package/dist/components/ui/button.js +7 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/button.mjs +2 -2
- package/dist/components/ui/command.js +47 -9
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/command.mjs +3 -3
- package/dist/components/ui/dialog.js +27 -5
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dialog.mjs +2 -2
- package/dist/components/ui/label.js +7 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/label.mjs +2 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +18 -4
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +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.js.map +1 -1
- 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.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +2 -2
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +6 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +25 -7
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
- package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
- package/dist/index.js +190 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -35
- package/dist/index.umd.js +16 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/debouncer.js.map +1 -1
- package/dist/lib/debouncer.mjs +1 -1
- package/dist/lib/editor-to-text.js.map +1 -1
- package/dist/lib/editor-to-text.mjs +1 -1
- package/dist/lib/get-text-around-cursor.js.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.js +4 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +1 -1
- package/dist/lib/stream-promise-flatten.js.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +3 -3
- package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +3 -3
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
- package/dist/types/base/base-autosuggestions-config.js.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +1 -1
- package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
- package/dist/types/base/editor-autocomplete-state.js.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +2 -2
- package/dist/types/base/index.js.map +1 -1
- package/dist/types/base/index.mjs +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +3 -3
- package/package.json +8 -8
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +30 -10
- package/src/components/base-copilot-textarea/render-element.tsx +6 -2
- package/src/components/base-copilot-textarea/render-placeholder.tsx +3 -1
- package/src/components/base-copilot-textarea/use-add-branding-css.tsx +3 -1
- package/src/components/copilot-textarea/copilot-textarea.tsx +15 -9
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +3 -1
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +63 -52
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +21 -5
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +13 -7
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +7 -2
- package/src/components/manual-ui/chip-with-icon.tsx +12 -3
- package/src/components/source-search-box/source-search-box.tsx +12 -2
- package/src/components/ui/button.tsx +13 -5
- package/src/components/ui/command.tsx +17 -4
- package/src/components/ui/dialog.tsx +23 -5
- package/src/components/ui/label.tsx +7 -2
- package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +35 -9
- package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +5 -1
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +5 -1
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +9 -2
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +24 -6
- package/src/hooks/misc/use-autosize-textarea.tsx +4 -1
- package/src/lib/debouncer.ts +3 -1
- package/src/lib/editor-to-text.ts +5 -2
- package/src/lib/get-text-around-cursor.ts +14 -2
- package/src/lib/slatejs-edits/clear-autocompletions.ts +4 -1
- package/src/lib/slatejs-edits/with-partial-history.ts +10 -3
- package/src/lib/stream-promise-flatten.ts +3 -1
- package/src/lib/utils.ts +6 -2
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -2
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +20 -5
- package/src/types/autosuggestions-config/editing-api-config.tsx +2 -1
- package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +4 -1
- package/src/types/base/base-autosuggestions-config.tsx +10 -4
- package/src/types/base/base-copilot-textarea-props.tsx +4 -2
- package/tsconfig.json +1 -1
- package/tsup.config.ts +5 -1
- package/dist/chunk-23Q6A46J.mjs.map +0 -1
- package/dist/chunk-2IWVZ4PP.mjs +0 -103
- package/dist/chunk-2IWVZ4PP.mjs.map +0 -1
- package/dist/chunk-2QDCE7PD.mjs.map +0 -1
- package/dist/chunk-3QJOFG3V.mjs.map +0 -1
- package/dist/chunk-4NHVQZ67.mjs.map +0 -1
- package/dist/chunk-4PDYALMP.mjs.map +0 -1
- package/dist/chunk-6SGWO63I.mjs.map +0 -1
- package/dist/chunk-72GJNLCO.mjs.map +0 -1
- package/dist/chunk-7LSRNPNI.mjs.map +0 -1
- package/dist/chunk-7NOLZ5T3.mjs.map +0 -1
- package/dist/chunk-CLGAJCZ5.mjs.map +0 -1
- package/dist/chunk-D47EKHIF.mjs.map +0 -1
- package/dist/chunk-DFTV4TST.mjs.map +0 -1
- package/dist/chunk-DL3JWL2E.mjs.map +0 -1
- package/dist/chunk-DRV2FOHZ.mjs.map +0 -1
- package/dist/chunk-ECR45NSD.mjs.map +0 -1
- package/dist/chunk-F2ULK22F.mjs.map +0 -1
- package/dist/chunk-F6RLSVG3.mjs.map +0 -1
- package/dist/chunk-GU5LTWGL.mjs.map +0 -1
- package/dist/chunk-I72DKFHD.mjs.map +0 -1
- package/dist/chunk-KMVGEY7Q.mjs.map +0 -1
- package/dist/chunk-LYB4B6MK.mjs.map +0 -1
- package/dist/chunk-NAFNY4FL.mjs.map +0 -1
- package/dist/chunk-QJNFNPWH.mjs.map +0 -1
- package/dist/chunk-T6MTDQZ7.mjs.map +0 -1
- package/dist/chunk-VSVQZUPW.mjs.map +0 -1
- package/dist/chunk-WGWQRALG.mjs.map +0 -1
- package/dist/chunk-YLFAIYRY.mjs.map +0 -1
- package/dist/chunk-ZQSEYPNN.mjs.map +0 -1
- /package/dist/{chunk-AJ5OMEXM.mjs.map → chunk-VBPZTMXB.mjs.map} +0 -0
- /package/dist/{chunk-JLOABKLH.mjs.map → chunk-YINY56BI.mjs.map} +0 -0
- /package/dist/{chunk-H5ZNEKUR.mjs.map → chunk-ZWI5KPQ5.mjs.map} +0 -0
|
@@ -33,13 +33,13 @@ export const HoveringInsertionPromptBoxCore = ({
|
|
|
33
33
|
const { getDocumentsContext } = useCopilotContext();
|
|
34
34
|
|
|
35
35
|
const [editSuggestion, setEditSuggestion] = useState<string>("");
|
|
36
|
-
const [suggestionIsLoading, setSuggestionIsLoading] =
|
|
36
|
+
const [suggestionIsLoading, setSuggestionIsLoading] =
|
|
37
|
+
useState<boolean>(false);
|
|
37
38
|
|
|
38
39
|
const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>("");
|
|
39
40
|
|
|
40
|
-
const [generatingSuggestion, setGeneratingSuggestion] =
|
|
41
|
-
null
|
|
42
|
-
);
|
|
41
|
+
const [generatingSuggestion, setGeneratingSuggestion] =
|
|
42
|
+
useState<ReadableStream<string> | null>(null);
|
|
43
43
|
|
|
44
44
|
const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
45
45
|
const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
@@ -88,7 +88,8 @@ export const HoveringInsertionPromptBoxCore = ({
|
|
|
88
88
|
|
|
89
89
|
// Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.
|
|
90
90
|
if (suggestionTextAreaRef.current) {
|
|
91
|
-
suggestionTextAreaRef.current.scrollTop =
|
|
91
|
+
suggestionTextAreaRef.current.scrollTop =
|
|
92
|
+
suggestionTextAreaRef.current.scrollHeight;
|
|
92
93
|
}
|
|
93
94
|
return newSuggestion;
|
|
94
95
|
});
|
|
@@ -251,14 +252,19 @@ export const HoveringInsertionPromptBoxCore = ({
|
|
|
251
252
|
<div className="w-full flex flex-col items-start relative gap-2">
|
|
252
253
|
{AdjustmentPromptComponent}
|
|
253
254
|
{filePointers.length > 0 && (
|
|
254
|
-
<IncludedFilesPreview
|
|
255
|
+
<IncludedFilesPreview
|
|
256
|
+
includedFiles={filePointers}
|
|
257
|
+
setIncludedFiles={setFilePointers}
|
|
258
|
+
/>
|
|
255
259
|
)}
|
|
256
260
|
{sourceSearchWord !== undefined && (
|
|
257
261
|
<SourceSearchBox
|
|
258
262
|
searchTerm={sourceSearchWord}
|
|
259
263
|
suggestedFiles={suggestedFiles}
|
|
260
264
|
onSelectedFile={(filePointer) => {
|
|
261
|
-
setAdjustmentPrompt(
|
|
265
|
+
setAdjustmentPrompt(
|
|
266
|
+
adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""),
|
|
267
|
+
);
|
|
262
268
|
setFilePointers((prev) => [...prev, filePointer]);
|
|
263
269
|
|
|
264
270
|
// 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,7 +23,9 @@ export const IncludedFilesPreview = ({
|
|
|
23
23
|
key={`file-${filePointer.sourceApplication}.${filePointer.name}`}
|
|
24
24
|
filePointer={filePointer}
|
|
25
25
|
onDelete={() => {
|
|
26
|
-
setIncludedFiles((prev) =>
|
|
26
|
+
setIncludedFiles((prev) =>
|
|
27
|
+
prev.filter((fp) => fp !== filePointer),
|
|
28
|
+
);
|
|
27
29
|
}}
|
|
28
30
|
/>
|
|
29
31
|
);
|
|
@@ -38,7 +40,10 @@ export interface FileChipPreviewProps {
|
|
|
38
40
|
onDelete: () => void;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
export const FileChipPreview = ({
|
|
43
|
+
export const FileChipPreview = ({
|
|
44
|
+
filePointer,
|
|
45
|
+
onDelete,
|
|
46
|
+
}: FileChipPreviewProps) => {
|
|
42
47
|
return (
|
|
43
48
|
<Chip
|
|
44
49
|
label={filePointer.name}
|
|
@@ -4,12 +4,21 @@ export interface ChipWithIconProps {
|
|
|
4
4
|
iconUrl: string;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const ChipWithIcon = ({
|
|
7
|
+
export const ChipWithIcon = ({
|
|
8
|
+
label,
|
|
9
|
+
onDelete,
|
|
10
|
+
iconUrl,
|
|
11
|
+
}: ChipWithIconProps) => {
|
|
8
12
|
return (
|
|
9
13
|
<span className="inline-flex items-center px-3 py-1 rounded-full bg-slate-200 text-sm font-medium text-white">
|
|
10
|
-
{iconUrl &&
|
|
14
|
+
{iconUrl && (
|
|
15
|
+
<img src={iconUrl} alt="icon" className="w-4 h-4 rounded-full mr-2" />
|
|
16
|
+
)}
|
|
11
17
|
{label}
|
|
12
|
-
<button
|
|
18
|
+
<button
|
|
19
|
+
className="ml-2 text-white hover:text-gray-200 focus:outline-none"
|
|
20
|
+
onClick={onDelete}
|
|
21
|
+
>
|
|
13
22
|
x
|
|
14
23
|
</button>
|
|
15
24
|
</span>
|
|
@@ -11,7 +11,14 @@ import {
|
|
|
11
11
|
CommandShortcut,
|
|
12
12
|
} from "../ui/command";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Calculator,
|
|
16
|
+
Calendar,
|
|
17
|
+
CreditCard,
|
|
18
|
+
Settings,
|
|
19
|
+
Smile,
|
|
20
|
+
User,
|
|
21
|
+
} from "lucide-react";
|
|
15
22
|
|
|
16
23
|
import { DocumentPointer } from "@copilotkit/react-core";
|
|
17
24
|
|
|
@@ -110,7 +117,10 @@ export function Logo({
|
|
|
110
117
|
height: string;
|
|
111
118
|
}) {
|
|
112
119
|
return (
|
|
113
|
-
<div
|
|
120
|
+
<div
|
|
121
|
+
className="flex items-center justify-center"
|
|
122
|
+
style={{ width: width, height: height }}
|
|
123
|
+
>
|
|
114
124
|
{children}
|
|
115
125
|
</div>
|
|
116
126
|
);
|
|
@@ -10,9 +10,12 @@ 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
|
-
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
15
|
+
outline:
|
|
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",
|
|
16
19
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
17
20
|
link: "text-primary underline-offset-4 hover:underline",
|
|
18
21
|
},
|
|
@@ -31,7 +34,8 @@ const buttonVariants = cva(
|
|
|
31
34
|
);
|
|
32
35
|
|
|
33
36
|
export interface ButtonProps
|
|
34
|
-
extends
|
|
37
|
+
extends
|
|
38
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
35
39
|
VariantProps<typeof buttonVariants> {
|
|
36
40
|
asChild?: boolean;
|
|
37
41
|
}
|
|
@@ -40,7 +44,11 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
40
44
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
41
45
|
const Comp = asChild ? Slot : "button";
|
|
42
46
|
return (
|
|
43
|
-
<Comp
|
|
47
|
+
<Comp
|
|
48
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
49
|
+
ref={ref}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
44
52
|
);
|
|
45
53
|
},
|
|
46
54
|
);
|
|
@@ -58,7 +58,10 @@ const CommandList = React.forwardRef<
|
|
|
58
58
|
>(({ className, ...props }, ref) => (
|
|
59
59
|
<CommandPrimitive.List
|
|
60
60
|
ref={ref}
|
|
61
|
-
className={cn(
|
|
61
|
+
className={cn(
|
|
62
|
+
"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
62
65
|
{...props}
|
|
63
66
|
/>
|
|
64
67
|
));
|
|
@@ -69,7 +72,11 @@ const CommandEmpty = React.forwardRef<
|
|
|
69
72
|
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
70
73
|
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
71
74
|
>((props, ref) => (
|
|
72
|
-
<CommandPrimitive.Empty
|
|
75
|
+
<CommandPrimitive.Empty
|
|
76
|
+
ref={ref}
|
|
77
|
+
className="py-6 text-center text-sm"
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
73
80
|
));
|
|
74
81
|
|
|
75
82
|
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
@@ -118,10 +125,16 @@ const CommandItem = React.forwardRef<
|
|
|
118
125
|
|
|
119
126
|
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
120
127
|
|
|
121
|
-
const CommandShortcut = ({
|
|
128
|
+
const CommandShortcut = ({
|
|
129
|
+
className,
|
|
130
|
+
...props
|
|
131
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
122
132
|
return (
|
|
123
133
|
<span
|
|
124
|
-
className={cn(
|
|
134
|
+
className={cn(
|
|
135
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
136
|
+
className,
|
|
137
|
+
)}
|
|
125
138
|
{...props}
|
|
126
139
|
/>
|
|
127
140
|
);
|
|
@@ -59,14 +59,29 @@ const DialogContent = React.forwardRef<
|
|
|
59
59
|
));
|
|
60
60
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
61
61
|
|
|
62
|
-
const DialogHeader = ({
|
|
63
|
-
|
|
62
|
+
const DialogHeader = ({
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
66
|
+
<div
|
|
67
|
+
className={cn(
|
|
68
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
64
73
|
);
|
|
65
74
|
DialogHeader.displayName = "DialogHeader";
|
|
66
75
|
|
|
67
|
-
const DialogFooter = ({
|
|
76
|
+
const DialogFooter = ({
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
68
80
|
<div
|
|
69
|
-
className={cn(
|
|
81
|
+
className={cn(
|
|
82
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
83
|
+
className,
|
|
84
|
+
)}
|
|
70
85
|
{...props}
|
|
71
86
|
/>
|
|
72
87
|
);
|
|
@@ -78,7 +93,10 @@ const DialogTitle = React.forwardRef<
|
|
|
78
93
|
>(({ className, ...props }, ref) => (
|
|
79
94
|
<DialogPrimitive.Title
|
|
80
95
|
ref={ref}
|
|
81
|
-
className={cn(
|
|
96
|
+
className={cn(
|
|
97
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
98
|
+
className,
|
|
99
|
+
)}
|
|
82
100
|
{...props}
|
|
83
101
|
/>
|
|
84
102
|
));
|
|
@@ -10,9 +10,14 @@ const labelVariants = cva(
|
|
|
10
10
|
|
|
11
11
|
const Label = React.forwardRef<
|
|
12
12
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
13
|
-
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof labelVariants>
|
|
14
15
|
>(({ className, ...props }, ref) => (
|
|
15
|
-
<LabelPrimitive.Root
|
|
16
|
+
<LabelPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(labelVariants(), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
16
21
|
));
|
|
17
22
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
18
23
|
|
|
@@ -17,8 +17,12 @@ export interface UseAutosuggestionsResult {
|
|
|
17
17
|
|
|
18
18
|
export function useAutosuggestions(
|
|
19
19
|
debounceTime: number,
|
|
20
|
-
shouldAcceptAutosuggestionOnKeyPress: (
|
|
21
|
-
|
|
20
|
+
shouldAcceptAutosuggestionOnKeyPress: (
|
|
21
|
+
event: React.KeyboardEvent<HTMLDivElement>,
|
|
22
|
+
) => boolean,
|
|
23
|
+
shouldAcceptAutosuggestionOnTouch: (
|
|
24
|
+
event: React.TouchEvent<HTMLDivElement>,
|
|
25
|
+
) => boolean,
|
|
22
26
|
autosuggestionFunction: AutosuggestionsBareFunction,
|
|
23
27
|
insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,
|
|
24
28
|
disableWhenEmpty: boolean,
|
|
@@ -34,7 +38,10 @@ export function useAutosuggestions(
|
|
|
34
38
|
editorAutocompleteState: EditorAutocompleteState,
|
|
35
39
|
abortSignal: AbortSignal,
|
|
36
40
|
) => Promise<void> = useCallback(
|
|
37
|
-
async (
|
|
41
|
+
async (
|
|
42
|
+
editorAutocompleteState: EditorAutocompleteState,
|
|
43
|
+
abortSignal: AbortSignal,
|
|
44
|
+
) => {
|
|
38
45
|
// early return if disabled
|
|
39
46
|
if (disabled) {
|
|
40
47
|
return;
|
|
@@ -49,7 +56,10 @@ export function useAutosuggestions(
|
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
// fetch the suggestion
|
|
52
|
-
const suggestion = await autosuggestionFunction(
|
|
59
|
+
const suggestion = await autosuggestionFunction(
|
|
60
|
+
editorAutocompleteState,
|
|
61
|
+
abortSignal,
|
|
62
|
+
);
|
|
53
63
|
|
|
54
64
|
// We'll assume for now that the autocomplete function might or might not respect the abort signal.
|
|
55
65
|
if (!suggestion || abortSignal.aborted) {
|
|
@@ -61,11 +71,19 @@ export function useAutosuggestions(
|
|
|
61
71
|
point: editorAutocompleteState.cursorPoint,
|
|
62
72
|
});
|
|
63
73
|
},
|
|
64
|
-
[
|
|
74
|
+
[
|
|
75
|
+
autosuggestionFunction,
|
|
76
|
+
setCurrentAutocompleteSuggestion,
|
|
77
|
+
disableWhenEmpty,
|
|
78
|
+
disabled,
|
|
79
|
+
],
|
|
65
80
|
);
|
|
66
81
|
|
|
67
82
|
const debouncedFunction = useMemo(
|
|
68
|
-
() =>
|
|
83
|
+
() =>
|
|
84
|
+
new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(
|
|
85
|
+
debounceTime,
|
|
86
|
+
),
|
|
69
87
|
[debounceTime],
|
|
70
88
|
);
|
|
71
89
|
|
|
@@ -111,12 +129,20 @@ export function useAutosuggestions(
|
|
|
111
129
|
);
|
|
112
130
|
|
|
113
131
|
const keyDownOrTouchHandler = useCallback(
|
|
114
|
-
(
|
|
132
|
+
(
|
|
133
|
+
event:
|
|
134
|
+
| React.KeyboardEvent<HTMLDivElement>
|
|
135
|
+
| React.TouchEvent<HTMLDivElement>,
|
|
136
|
+
) => {
|
|
115
137
|
if (currentAutocompleteSuggestion) {
|
|
116
138
|
const shouldAcceptSuggestion =
|
|
117
139
|
event.type === "touchstart"
|
|
118
|
-
? shouldAcceptAutosuggestionOnTouch(
|
|
119
|
-
|
|
140
|
+
? shouldAcceptAutosuggestionOnTouch(
|
|
141
|
+
event as React.TouchEvent<HTMLDivElement>,
|
|
142
|
+
)
|
|
143
|
+
: shouldAcceptAutosuggestionOnKeyPress(
|
|
144
|
+
event as React.KeyboardEvent<HTMLDivElement>,
|
|
145
|
+
);
|
|
120
146
|
|
|
121
147
|
if (shouldAcceptSuggestion) {
|
|
122
148
|
event.preventDefault();
|
|
@@ -35,7 +35,11 @@ const shouldSave: ShouldSaveToHistory = (op, prev) => {
|
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
38
|
+
if (
|
|
39
|
+
op.type == "set_node" &&
|
|
40
|
+
"type" in op.properties &&
|
|
41
|
+
op.properties.type === excludedNodeType
|
|
42
|
+
) {
|
|
39
43
|
return false;
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -60,7 +60,11 @@ export function usePopulateCopilotTextareaRef(
|
|
|
60
60
|
get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {
|
|
61
61
|
return target.get(target, propKey);
|
|
62
62
|
},
|
|
63
|
-
set(
|
|
63
|
+
set(
|
|
64
|
+
target: any,
|
|
65
|
+
propKey: keyof CustomMethods | keyof HTMLElement,
|
|
66
|
+
value: any,
|
|
67
|
+
) {
|
|
64
68
|
return target.set(target, propKey, value);
|
|
65
69
|
},
|
|
66
70
|
};
|
package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
CHANGED
|
@@ -35,10 +35,17 @@ export function useMakeStandardAutosuggestionFunction(
|
|
|
35
35
|
): AutosuggestionsBareFunction {
|
|
36
36
|
const runtimeClient = { generateCopilotResponse: (...args: any[]) => {} };
|
|
37
37
|
const { getContextString, copilotApiConfig } = useCopilotContext();
|
|
38
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
chatApiEndpoint: url,
|
|
40
|
+
publicApiKey,
|
|
41
|
+
credentials,
|
|
42
|
+
properties,
|
|
43
|
+
} = copilotApiConfig;
|
|
39
44
|
const headers = {
|
|
40
45
|
...copilotApiConfig.headers,
|
|
41
|
-
...(publicApiKey
|
|
46
|
+
...(publicApiKey
|
|
47
|
+
? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey }
|
|
48
|
+
: {}),
|
|
42
49
|
};
|
|
43
50
|
const { maxTokens, stop, temperature = 0 } = apiConfig;
|
|
44
51
|
|
|
@@ -39,7 +39,9 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
39
39
|
insertionApiConfig: InsertionsApiConfig,
|
|
40
40
|
editingApiConfig: EditingApiConfig,
|
|
41
41
|
): Generator_InsertionOrEditingSuggestion {
|
|
42
|
-
const runtimeClient: any = {
|
|
42
|
+
const runtimeClient: any = {
|
|
43
|
+
generateCopilotResponse: (...args: any[]) => {},
|
|
44
|
+
};
|
|
43
45
|
const { getContextString, copilotApiConfig } = useCopilotContext();
|
|
44
46
|
const headers = {
|
|
45
47
|
...(copilotApiConfig.publicApiKey
|
|
@@ -63,7 +65,9 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
63
65
|
break;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
const messages = convertGqlOutputToMessages(
|
|
68
|
+
const messages = convertGqlOutputToMessages(
|
|
69
|
+
value.generateCopilotResponse.messages,
|
|
70
|
+
);
|
|
67
71
|
|
|
68
72
|
let newContent = "";
|
|
69
73
|
|
|
@@ -121,7 +125,9 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
121
125
|
actions: [],
|
|
122
126
|
url: window.location.href,
|
|
123
127
|
},
|
|
124
|
-
messages: convertMessagesToGqlInput(
|
|
128
|
+
messages: convertMessagesToGqlInput(
|
|
129
|
+
filterAgentStateMessages(messages),
|
|
130
|
+
),
|
|
125
131
|
metadata: {
|
|
126
132
|
requestType: CopilotRequestType.TextareaCompletion,
|
|
127
133
|
},
|
|
@@ -179,7 +185,9 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
179
185
|
actions: [],
|
|
180
186
|
url: window.location.href,
|
|
181
187
|
},
|
|
182
|
-
messages: convertMessagesToGqlInput(
|
|
188
|
+
messages: convertMessagesToGqlInput(
|
|
189
|
+
filterAgentStateMessages(messages),
|
|
190
|
+
),
|
|
183
191
|
metadata: {
|
|
184
192
|
requestType: CopilotRequestType.TextareaCompletion,
|
|
185
193
|
},
|
|
@@ -203,9 +211,19 @@ export function useMakeStandardInsertionOrEditingFunction(
|
|
|
203
211
|
abortSignal: AbortSignal,
|
|
204
212
|
) => {
|
|
205
213
|
if (editorState.selectedText === "") {
|
|
206
|
-
return await insertionFunction(
|
|
214
|
+
return await insertionFunction(
|
|
215
|
+
editorState,
|
|
216
|
+
insertionPrompt,
|
|
217
|
+
documents,
|
|
218
|
+
abortSignal,
|
|
219
|
+
);
|
|
207
220
|
} else {
|
|
208
|
-
return await editingFunction(
|
|
221
|
+
return await editingFunction(
|
|
222
|
+
editorState,
|
|
223
|
+
insertionPrompt,
|
|
224
|
+
documents,
|
|
225
|
+
abortSignal,
|
|
226
|
+
);
|
|
209
227
|
}
|
|
210
228
|
},
|
|
211
229
|
[insertionFunction, editingFunction],
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Ref, RefObject, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
// Updates the height of a <textarea> when the value changes.
|
|
4
|
-
const useAutosizeTextArea = (
|
|
4
|
+
const useAutosizeTextArea = (
|
|
5
|
+
textAreaRef: RefObject<HTMLTextAreaElement | null>,
|
|
6
|
+
value: string,
|
|
7
|
+
) => {
|
|
5
8
|
useEffect(() => {
|
|
6
9
|
if (textAreaRef.current !== null) {
|
|
7
10
|
// We need to reset the height momentarily to get the correct scrollHeight for the textarea
|
package/src/lib/debouncer.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export type AsyncFunction<T extends any[]> = (
|
|
1
|
+
export type AsyncFunction<T extends any[]> = (
|
|
2
|
+
...args: [...T, AbortSignal]
|
|
3
|
+
) => Promise<void>;
|
|
2
4
|
|
|
3
5
|
export class Debouncer<T extends any[]> {
|
|
4
6
|
private timeoutId?: ReturnType<typeof setTimeout>;
|
|
@@ -28,7 +28,8 @@ function nodeChildrenToTextComponents(
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const isNeighbourOfInline =
|
|
31
|
-
indeciesOfInlineElements.has(index - 1) ||
|
|
31
|
+
indeciesOfInlineElements.has(index - 1) ||
|
|
32
|
+
indeciesOfInlineElements.has(index + 1);
|
|
32
33
|
if (isNeighbourOfInline) {
|
|
33
34
|
return (node as any).text !== "";
|
|
34
35
|
}
|
|
@@ -52,7 +53,9 @@ function nodeChildrenToTextComponents(
|
|
|
52
53
|
.reduce((acc, val) => acc.concat(val), []);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
export const editorToText = (
|
|
56
|
+
export const editorToText = (
|
|
57
|
+
editor: BaseEditor & ReactEditor & HistoryEditor,
|
|
58
|
+
) => {
|
|
56
59
|
const flattened = nodeChildrenToTextComponents(editor, editor.children);
|
|
57
60
|
|
|
58
61
|
const text = flattened.map((textComponent) => textComponent.text).join("\n");
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Editor,
|
|
3
|
+
Node,
|
|
4
|
+
Path,
|
|
5
|
+
Range,
|
|
6
|
+
Text,
|
|
7
|
+
Element,
|
|
8
|
+
BasePoint,
|
|
9
|
+
BaseRange,
|
|
10
|
+
Point,
|
|
11
|
+
} from "slate";
|
|
2
12
|
import { EditorAutocompleteState } from "../types/base/editor-autocomplete-state";
|
|
3
13
|
|
|
4
14
|
export interface EditorTextState {
|
|
@@ -9,7 +19,9 @@ export interface EditorTextState {
|
|
|
9
19
|
textAfterCursor: string;
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
export function getTextAroundCollapsedCursor(
|
|
22
|
+
export function getTextAroundCollapsedCursor(
|
|
23
|
+
editor: Editor,
|
|
24
|
+
): EditorAutocompleteState | null {
|
|
13
25
|
const { selection } = editor;
|
|
14
26
|
if (!selection || !Range.isCollapsed(selection)) {
|
|
15
27
|
return null;
|
|
@@ -13,7 +13,10 @@ export function clearAutocompletionsFromEditor(editor: CustomEditor) {
|
|
|
13
13
|
try {
|
|
14
14
|
Transforms.removeNodes(editor, { at: path });
|
|
15
15
|
} catch (e) {
|
|
16
|
-
console.log(
|
|
16
|
+
console.log(
|
|
17
|
+
"CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
|
|
18
|
+
e,
|
|
19
|
+
);
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -3,7 +3,10 @@ import { HistoryEditor } from "slate-history";
|
|
|
3
3
|
|
|
4
4
|
// Copy-pasted from `https://github.com/ianstormtaylor/slate/blob/main/packages/slate-history/src/with-history.ts`
|
|
5
5
|
// With one exception: the `shouldSave` function is passed in as an argument to `withPartialHistory` instead of being hardcoded
|
|
6
|
-
export type ShouldSaveToHistory = (
|
|
6
|
+
export type ShouldSaveToHistory = (
|
|
7
|
+
op: Operation,
|
|
8
|
+
prev: Operation | undefined,
|
|
9
|
+
) => boolean;
|
|
7
10
|
|
|
8
11
|
export const withPartialHistory = <T extends Editor>(
|
|
9
12
|
editor: T,
|
|
@@ -66,7 +69,8 @@ export const withPartialHistory = <T extends Editor>(
|
|
|
66
69
|
const { operations, history } = e;
|
|
67
70
|
const { undos } = history;
|
|
68
71
|
const lastBatch = undos[undos.length - 1];
|
|
69
|
-
const lastOp =
|
|
72
|
+
const lastOp =
|
|
73
|
+
lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
|
|
70
74
|
let save = HistoryEditor.isSaving(e);
|
|
71
75
|
let merge = HistoryEditor.isMerging(e);
|
|
72
76
|
|
|
@@ -140,7 +144,10 @@ const shouldMerge = (op: Operation, prev: Operation | undefined): boolean => {
|
|
|
140
144
|
return false;
|
|
141
145
|
};
|
|
142
146
|
|
|
143
|
-
export const defaultShouldSave = (
|
|
147
|
+
export const defaultShouldSave = (
|
|
148
|
+
op: Operation,
|
|
149
|
+
prev: Operation | undefined,
|
|
150
|
+
): boolean => {
|
|
144
151
|
if (op.type === "set_selection") {
|
|
145
152
|
return false;
|
|
146
153
|
}
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* @returns {ReadableStream<A>} - The flattened stream.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export function streamPromiseFlatten<A>(
|
|
11
|
+
export function streamPromiseFlatten<A>(
|
|
12
|
+
promise: Promise<ReadableStream<A>>,
|
|
13
|
+
): ReadableStream<A> {
|
|
12
14
|
return new ReadableStream<A>({
|
|
13
15
|
async start(controller) {
|
|
14
16
|
try {
|
package/src/lib/utils.ts
CHANGED
|
@@ -5,7 +5,10 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
5
5
|
return twMerge(clsx(inputs));
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export async function fetcher<JSON = any>(
|
|
8
|
+
export async function fetcher<JSON = any>(
|
|
9
|
+
input: RequestInfo,
|
|
10
|
+
init?: RequestInit,
|
|
11
|
+
): Promise<JSON> {
|
|
9
12
|
const res = await fetch(input, init);
|
|
10
13
|
|
|
11
14
|
if (!res.ok) {
|
|
@@ -34,7 +37,8 @@ export function formatDate(input: string | number | Date): string {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>
|
|
37
|
-
arr1.length === arr2.length &&
|
|
40
|
+
arr1.length === arr2.length &&
|
|
41
|
+
arr1.every((value, index) => value === arr2[index]);
|
|
38
42
|
|
|
39
43
|
export function nullableCompatibleEqualityCheck<T>(
|
|
40
44
|
naiveEqualityCheck: (a: T, b: T) => boolean,
|
|
@@ -9,8 +9,9 @@ export interface SuggestionsApiConfigUserSpecified extends Partial<SuggestionsAp
|
|
|
9
9
|
export interface InsertionsApiConfigUserSpecified extends Partial<InsertionsApiConfig> {}
|
|
10
10
|
|
|
11
11
|
// Mostly mirrors a partial AutosuggestionsConfig, but with some fields MANDATORY.
|
|
12
|
-
export interface AutosuggestionsConfigUserSpecified
|
|
13
|
-
|
|
12
|
+
export interface AutosuggestionsConfigUserSpecified extends Partial<
|
|
13
|
+
Omit<AutosuggestionsConfig, "chatApiConfigs" | "textareaPurpose">
|
|
14
|
+
> {
|
|
14
15
|
textareaPurpose: string; // the user MUST specify textareaPurpose - it's not optional
|
|
15
16
|
chatApiConfigs: {
|
|
16
17
|
suggestionsApiConfig?: SuggestionsApiConfigUserSpecified;
|