@copilotkit/react-textarea 0.25.0 → 0.26.0-alpha.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 +313 -309
- package/CHANGELOG.md +11 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +29 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1745 -35
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +51 -3
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +49 -3
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +86 -4
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +57 -3
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +3 -0
- package/dist/components/copilot-textarea/copilot-textarea.mjs +2202 -47
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +7 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +17 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +137 -3
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +875 -18
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +558 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +581 -13
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +102 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +581 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.mjs +2203 -48
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +10 -22
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +211 -6
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +85 -4
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +71 -31
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +244 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +144 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +60 -4
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +63 -18
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +58 -14
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.mjs +0 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +158 -6
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +168 -4
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +148 -5
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +147 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +193 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.mjs +2206 -50
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +51 -3
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +43 -3
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +102 -3
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +17 -3
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +20 -3
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +47 -3
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +71 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.d.ts +1 -0
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +265 -8
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +81 -3
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +327 -10
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +75 -3
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +83 -3
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +64 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +0 -2
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +26 -3
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.mjs +0 -2
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +17 -4
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +26 -4
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +0 -2
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.mjs +328 -12
- package/dist/types/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +50 -10
- package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +23 -1
- package/src/components/copilot-textarea/copilot-textarea.tsx +3 -0
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +7 -3
- package/dist/chunk-2C7O2EVM.mjs +0 -27
- package/dist/chunk-2C7O2EVM.mjs.map +0 -1
- package/dist/chunk-2CDXHWVF.mjs +0 -107
- package/dist/chunk-2CDXHWVF.mjs.map +0 -1
- package/dist/chunk-2QDCE7PD.mjs +0 -29
- package/dist/chunk-2QDCE7PD.mjs.map +0 -1
- package/dist/chunk-3PQ7GSFE.mjs +0 -17
- package/dist/chunk-3PQ7GSFE.mjs.map +0 -1
- package/dist/chunk-5FO6ISW4.mjs +0 -3
- package/dist/chunk-5FO6ISW4.mjs.map +0 -1
- package/dist/chunk-5IISSXS2.mjs +0 -224
- package/dist/chunk-5IISSXS2.mjs.map +0 -1
- package/dist/chunk-5UNJXFUO.mjs +0 -29
- package/dist/chunk-5UNJXFUO.mjs.map +0 -1
- package/dist/chunk-74HF6Q3L.mjs +0 -204
- package/dist/chunk-74HF6Q3L.mjs.map +0 -1
- package/dist/chunk-7LSRNPNI.mjs +0 -59
- package/dist/chunk-7LSRNPNI.mjs.map +0 -1
- package/dist/chunk-7SZDD6XT.mjs +0 -53
- package/dist/chunk-7SZDD6XT.mjs.map +0 -1
- package/dist/chunk-7VKOE5UL.mjs +0 -45
- package/dist/chunk-7VKOE5UL.mjs.map +0 -1
- package/dist/chunk-AUCHS4VR.mjs +0 -77
- package/dist/chunk-AUCHS4VR.mjs.map +0 -1
- package/dist/chunk-BLRAOGXD.mjs +0 -10
- package/dist/chunk-BLRAOGXD.mjs.map +0 -1
- package/dist/chunk-CK7Q3Y5A.mjs +0 -21
- package/dist/chunk-CK7Q3Y5A.mjs.map +0 -1
- package/dist/chunk-DE5K76I2.mjs +0 -3
- package/dist/chunk-DE5K76I2.mjs.map +0 -1
- package/dist/chunk-ECR45NSD.mjs +0 -101
- package/dist/chunk-ECR45NSD.mjs.map +0 -1
- package/dist/chunk-EZCKXWQF.mjs +0 -16
- package/dist/chunk-EZCKXWQF.mjs.map +0 -1
- package/dist/chunk-F626GQCD.mjs +0 -47
- package/dist/chunk-F626GQCD.mjs.map +0 -1
- package/dist/chunk-FK2XUDQQ.mjs +0 -22
- package/dist/chunk-FK2XUDQQ.mjs.map +0 -1
- package/dist/chunk-FP2EKU3L.mjs +0 -28
- package/dist/chunk-FP2EKU3L.mjs.map +0 -1
- package/dist/chunk-GQN2HYFJ.mjs +0 -22
- package/dist/chunk-GQN2HYFJ.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -3
- package/dist/chunk-H4VKQGVU.mjs.map +0 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -3
- package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
- package/dist/chunk-K5LNB36H.mjs +0 -80
- package/dist/chunk-K5LNB36H.mjs.map +0 -1
- package/dist/chunk-KDVMG3XF.mjs +0 -63
- package/dist/chunk-KDVMG3XF.mjs.map +0 -1
- package/dist/chunk-KMXSZRIA.mjs +0 -47
- package/dist/chunk-KMXSZRIA.mjs.map +0 -1
- package/dist/chunk-KNQIEOFP.mjs +0 -18
- package/dist/chunk-KNQIEOFP.mjs.map +0 -1
- package/dist/chunk-L7VVZH4Q.mjs +0 -3
- package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
- package/dist/chunk-LZ3UOAQ4.mjs +0 -83
- package/dist/chunk-LZ3UOAQ4.mjs.map +0 -1
- package/dist/chunk-M2DR4KVB.mjs +0 -33
- package/dist/chunk-M2DR4KVB.mjs.map +0 -1
- package/dist/chunk-MMVDU6DF.mjs +0 -3
- package/dist/chunk-MMVDU6DF.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-NTLVQENP.mjs +0 -19
- package/dist/chunk-NTLVQENP.mjs.map +0 -1
- package/dist/chunk-PDCIGRCE.mjs +0 -93
- package/dist/chunk-PDCIGRCE.mjs.map +0 -1
- package/dist/chunk-QRKKPCUD.mjs +0 -21
- package/dist/chunk-QRKKPCUD.mjs.map +0 -1
- package/dist/chunk-RBR32FWA.mjs +0 -74
- package/dist/chunk-RBR32FWA.mjs.map +0 -1
- package/dist/chunk-T6MTDQZ7.mjs +0 -45
- package/dist/chunk-T6MTDQZ7.mjs.map +0 -1
- package/dist/chunk-TZLW7PBU.mjs +0 -35
- package/dist/chunk-TZLW7PBU.mjs.map +0 -1
- package/dist/chunk-U3LUDDT5.mjs +0 -65
- package/dist/chunk-U3LUDDT5.mjs.map +0 -1
- package/dist/chunk-UEQYKC4W.mjs +0 -34
- package/dist/chunk-UEQYKC4W.mjs.map +0 -1
- package/dist/chunk-V55OPCG4.mjs +0 -45
- package/dist/chunk-V55OPCG4.mjs.map +0 -1
- package/dist/chunk-VYECMH73.mjs +0 -99
- package/dist/chunk-VYECMH73.mjs.map +0 -1
- package/dist/chunk-W2ZHOUV6.mjs +0 -108
- package/dist/chunk-W2ZHOUV6.mjs.map +0 -1
- package/dist/chunk-WADHCMPK.mjs +0 -3
- package/dist/chunk-WADHCMPK.mjs.map +0 -1
- package/dist/chunk-WJHSY5T6.mjs +0 -3
- package/dist/chunk-WJHSY5T6.mjs.map +0 -1
- package/dist/chunk-WVRTFPNO.mjs +0 -91
- package/dist/chunk-WVRTFPNO.mjs.map +0 -1
- package/dist/chunk-ZEHF3AXH.mjs +0 -45
- package/dist/chunk-ZEHF3AXH.mjs.map +0 -1
- package/dist/chunk-ZKRM3DIR.mjs +0 -91
- package/dist/chunk-ZKRM3DIR.mjs.map +0 -1
- package/dist/chunk-ZMNOLW5V.mjs +0 -99
- package/dist/chunk-ZMNOLW5V.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAsBjC,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,SAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,UAAU;AAAA,cACjB;AAAA,cACA,iBAAiB,CAAC,GAAG,iBAAiB;AAAA,YACxC;AAAA,UACF;AAAA,UACA,GAAG,UAAU;AAAA,UACb;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,QACF;AAEA,cAAM,cAAc,oBAAoB,qBAAqB,gBAAgB;AAC7E,cAAM,SAAS,MAAM,YAAY,IAAI,aAAa,UAAU,UAAU,eAAe;AAGrF,cAAM,SAAS,OAAO,UAAU;AAChC,YAAI,SAAS;AAEb,eAAO,MAAM;AACX,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AAEA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n ChatlikeApiEndpoint,\n MinimalChatGPTMessage,\n} from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[],\n apiConfig: SuggestionsApiConfig,\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString([], contextCategories),\n ),\n },\n ...apiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n ];\n\n const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n const stream = await apiEndpoint.run(abortSignal, messages, apiConfig.forwardedParams);\n\n // read the stream:\n const reader = stream.getReader();\n let result = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n"]}
|
package/dist/chunk-7VKOE5UL.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useMakeStandardAutosuggestionFunction } from './chunk-7SZDD6XT.mjs';
|
|
2
|
-
import { useMakeStandardInsertionOrEditingFunction } from './chunk-VYECMH73.mjs';
|
|
3
|
-
import { defaultAutosuggestionsConfig } from './chunk-NTLVQENP.mjs';
|
|
4
|
-
import { BaseCopilotTextarea } from './chunk-74HF6Q3L.mjs';
|
|
5
|
-
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import merge from 'lodash.merge';
|
|
8
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
var CopilotTextarea = React.forwardRef(
|
|
11
|
-
(props, ref) => {
|
|
12
|
-
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
13
|
-
const autosuggestionsConfig = merge(
|
|
14
|
-
defaultAutosuggestionsConfig,
|
|
15
|
-
autosuggestionsConfigUserSpecified
|
|
16
|
-
);
|
|
17
|
-
const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(
|
|
18
|
-
autosuggestionsConfig.textareaPurpose,
|
|
19
|
-
autosuggestionsConfig.contextCategories,
|
|
20
|
-
autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig
|
|
21
|
-
);
|
|
22
|
-
const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(
|
|
23
|
-
autosuggestionsConfig.textareaPurpose,
|
|
24
|
-
autosuggestionsConfig.contextCategories,
|
|
25
|
-
autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
|
|
26
|
-
autosuggestionsConfig.chatApiConfigs.editingApiConfig
|
|
27
|
-
);
|
|
28
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
29
|
-
children: /* @__PURE__ */ jsx(BaseCopilotTextarea, __spreadProps(__spreadValues({
|
|
30
|
-
ref
|
|
31
|
-
}, forwardedProps), {
|
|
32
|
-
baseAutosuggestionsConfig: __spreadProps(__spreadValues({}, autosuggestionsConfig), {
|
|
33
|
-
apiConfig: {
|
|
34
|
-
insertionOrEditingFunction,
|
|
35
|
-
autosuggestionsFunction
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}))
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export { CopilotTextarea };
|
|
44
|
-
//# sourceMappingURL=out.js.map
|
|
45
|
-
//# sourceMappingURL=chunk-7VKOE5UL.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/copilot-textarea/copilot-textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAkCZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA4D;AAExF,UAAyF,YAAjF,yBAAuB,mCAxBnC,IAwB6F,IAAnB,2BAAmB,IAAnB,CAA9D;AAER,UAAM,wBAA+C;AAAA,MACnD;AAAA,MACA;AAAA,IACF;AAEA,UAAM,0BAA0B;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,IACvC;AAEA,UAAM,6BAA6B;AAAA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,MACrC,sBAAsB,eAAe;AAAA,IACvC;AAEA,WACE;AAAA,MACE,8BAAC;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACF;AAAA,KACF;AAAA,EAEJ;AACF","sourcesContent":["// This example is for an Editor with `ReactEditor` and `HistoryEditor`\nimport React from \"react\";\nimport { useMakeStandardAutosuggestionFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport {\n AutosuggestionsConfig,\n defaultAutosuggestionsConfig,\n} from \"../../types/autosuggestions-config\";\nimport { BaseCopilotTextarea } from \"../base-copilot-textarea/base-copilot-textarea\";\nimport { useMakeStandardInsertionOrEditingFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-insertion-function\";\nimport merge from \"lodash.merge\";\nimport { AutosuggestionsConfigUserSpecified } from \"../../types/autosuggestions-config/autosuggestions-config-user-specified\";\n\n// Like the base copilot textarea props,\n// but with baseAutosuggestionsConfig replaced with autosuggestionsConfig.\nexport interface CopilotTextareaProps\n extends Omit<BaseCopilotTextareaProps, \"baseAutosuggestionsConfig\"> {\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\nexport const CopilotTextarea = React.forwardRef(\n (props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {\n // separate the AutosuggestionsConfigUserSpecified from the rest of the props\n const { autosuggestionsConfig: autosuggestionsConfigUserSpecified, ...forwardedProps } = props;\n\n const autosuggestionsConfig: AutosuggestionsConfig = merge(\n defaultAutosuggestionsConfig,\n autosuggestionsConfigUserSpecified,\n );\n\n const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig,\n );\n\n const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.insertionApiConfig,\n autosuggestionsConfig.chatApiConfigs.editingApiConfig,\n );\n\n return (\n <>\n <BaseCopilotTextarea\n ref={ref}\n {...forwardedProps}\n baseAutosuggestionsConfig={{\n ...autosuggestionsConfig,\n apiConfig: {\n insertionOrEditingFunction: insertionOrEditingFunction,\n autosuggestionsFunction: autosuggestionsFunction,\n },\n }}\n />\n </>\n );\n },\n);\n"]}
|
package/dist/chunk-AUCHS4VR.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from './chunk-ZMNOLW5V.mjs';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
function SourceSearchBox(props) {
|
|
6
|
-
const [selectedValue, setSelectedValue] = useState("");
|
|
7
|
-
return /* @__PURE__ */ jsxs(Command, {
|
|
8
|
-
className: "rounded-lg border shadow-md",
|
|
9
|
-
value: selectedValue,
|
|
10
|
-
onValueChange: (value) => {
|
|
11
|
-
setSelectedValue(value);
|
|
12
|
-
},
|
|
13
|
-
filter: (value, search) => {
|
|
14
|
-
if (props.searchTerm === "")
|
|
15
|
-
return 1;
|
|
16
|
-
if (value.startsWith(props.searchTerm))
|
|
17
|
-
return 1;
|
|
18
|
-
return 0;
|
|
19
|
-
},
|
|
20
|
-
children: [
|
|
21
|
-
/* @__PURE__ */ jsx(CommandInput, {
|
|
22
|
-
value: props.searchTerm,
|
|
23
|
-
className: "rounded-t-lg hidden",
|
|
24
|
-
placeholder: "Search for a command..."
|
|
25
|
-
}),
|
|
26
|
-
/* @__PURE__ */ jsxs(CommandList, {
|
|
27
|
-
children: [
|
|
28
|
-
/* @__PURE__ */ jsx(CommandEmpty, {
|
|
29
|
-
children: "No results found."
|
|
30
|
-
}),
|
|
31
|
-
/* @__PURE__ */ jsx(CommandGroup, {
|
|
32
|
-
heading: "Available resources",
|
|
33
|
-
children: props.suggestedFiles.map((filePointer) => {
|
|
34
|
-
return /* @__PURE__ */ jsx(CommandItem, {
|
|
35
|
-
value: filePointer.name,
|
|
36
|
-
onSelect: (value) => {
|
|
37
|
-
props.onSelectedFile(filePointer);
|
|
38
|
-
},
|
|
39
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
40
|
-
className: " px-3 flex flex-row gap-1 items-center",
|
|
41
|
-
children: [
|
|
42
|
-
/* @__PURE__ */ jsx(Logo, {
|
|
43
|
-
width: "20px",
|
|
44
|
-
height: "20px",
|
|
45
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
46
|
-
src: filePointer.iconImageUri,
|
|
47
|
-
alt: filePointer.sourceApplication,
|
|
48
|
-
className: "w-full h-full"
|
|
49
|
-
})
|
|
50
|
-
}),
|
|
51
|
-
filePointer.name
|
|
52
|
-
]
|
|
53
|
-
})
|
|
54
|
-
}, `word-${filePointer.sourceApplication}.${filePointer.name}`);
|
|
55
|
-
})
|
|
56
|
-
}),
|
|
57
|
-
/* @__PURE__ */ jsx(CommandSeparator, {})
|
|
58
|
-
]
|
|
59
|
-
})
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function Logo({
|
|
64
|
-
children,
|
|
65
|
-
width,
|
|
66
|
-
height
|
|
67
|
-
}) {
|
|
68
|
-
return /* @__PURE__ */ jsx("div", {
|
|
69
|
-
className: "flex items-center justify-center",
|
|
70
|
-
style: { width, height },
|
|
71
|
-
children
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { Logo, SourceSearchBox };
|
|
76
|
-
//# sourceMappingURL=out.js.map
|
|
77
|
-
//# sourceMappingURL=chunk-AUCHS4VR.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/source-search-box/source-search-box.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,gBAAgB;AA4CnB,cAkBU,YAlBV;AArBC,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAE7D,SACE,qBAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO;AAAA,IACP,eAAe,CAAC,UAAU;AACxB,uBAAiB,KAAK;AAAA,IACxB;AAAA,IACA,QAAQ,CAAC,OAAO,WAAW;AAEzB,UAAI,MAAM,eAAe;AAAI,eAAO;AAGpC,UAAI,MAAM,WAAW,MAAM,UAAU;AAAG,eAAO;AAG/C,aAAO;AAAA,IACT;AAAA,IAEA;AAAA,0BAAC;AAAA,QACC,OAAO,MAAM;AAAA,QACb,WAAU;AAAA,QACV,aAAY;AAAA,OACd;AAAA,MACA,qBAAC;AAAA,QACC;AAAA,8BAAC;AAAA,YAAa;AAAA,WAAiB;AAAA,UAE/B,oBAAC;AAAA,YAAa,SAAQ;AAAA,YACnB,gBAAM,eAAe,IAAI,CAAC,gBAAgB;AACzC,qBACE,oBAAC;AAAA,gBAEC,OAAO,YAAY;AAAA,gBACnB,UAAU,CAAC,UAAU;AACnB,wBAAM,eAAe,WAAW;AAAA,gBAClC;AAAA,gBAEA,+BAAC;AAAA,kBAAI,WAAU;AAAA,kBACb;AAAA,wCAAC;AAAA,sBAAK,OAAM;AAAA,sBAAO,QAAO;AAAA,sBACxB,8BAAC;AAAA,wBACC,KAAK,YAAY;AAAA,wBACjB,KAAK,YAAY;AAAA,wBACjB,WAAU;AAAA,uBACZ;AAAA,qBACF;AAAA,oBACC,YAAY;AAAA;AAAA,iBACf;AAAA,iBAfK,QAAQ,YAAY,qBAAqB,YAAY,MAgB5D;AAAA,YAEJ,CAAC;AAAA,WACH;AAAA,UAqBA,oBAAC,oBAAiB;AAAA;AAAA,OACpB;AAAA;AAAA,GACF;AAEJ;AAEO,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SACE,oBAAC;AAAA,IAAI,WAAU;AAAA,IAAmC,OAAO,EAAE,OAAc,OAAe;AAAA,IACrF;AAAA,GACH;AAEJ","sourcesContent":["import { useState } from \"react\";\nimport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n} from \"../ui/command\";\n\nimport { Calculator, Calendar, CreditCard, Settings, Smile, User } from \"lucide-react\";\n\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\nexport interface SourceSearchBoxProps {\n searchTerm: string;\n suggestedFiles: DocumentPointer[];\n onSelectedFile: (filePointer: DocumentPointer) => void;\n}\n\nexport function SourceSearchBox(props: SourceSearchBoxProps) {\n const [selectedValue, setSelectedValue] = useState<string>(\"\");\n\n return (\n <Command\n className=\"rounded-lg border shadow-md\"\n value={selectedValue}\n onValueChange={(value) => {\n setSelectedValue(value);\n }}\n filter={(value, search) => {\n // if the search term is empty, show all commands\n if (props.searchTerm === \"\") return 1;\n\n // if the search term is a prefix of the command, show it\n if (value.startsWith(props.searchTerm)) return 1;\n\n // otherwise, don't show it\n return 0;\n }}\n >\n <CommandInput\n value={props.searchTerm}\n className=\"rounded-t-lg hidden\"\n placeholder=\"Search for a command...\"\n />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n\n <CommandGroup heading=\"Available resources\">\n {props.suggestedFiles.map((filePointer) => {\n return (\n <CommandItem\n key={`word-${filePointer.sourceApplication}.${filePointer.name}`}\n value={filePointer.name}\n onSelect={(value) => {\n props.onSelectedFile(filePointer);\n }}\n >\n <div className=\" px-3 flex flex-row gap-1 items-center\">\n <Logo width=\"20px\" height=\"20px\">\n <img\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n className=\"w-full h-full\"\n />\n </Logo>\n {filePointer.name}\n </div>\n </CommandItem>\n );\n })}\n </CommandGroup>\n\n {/* <CommandGroup heading=\"Suggestions\">\n <CommandItem\n onSelect={(value) => {\n console.log(value);\n console.log(value);\n }}\n >\n <Calendar className=\"mr-2 h-4 w-4\" />\n <span>Calendar</span>\n </CommandItem>\n <CommandItem>\n <Smile className=\"mr-2 h-4 w-4\" />\n <span>Search Emoji</span>\n </CommandItem>\n <CommandItem>\n <Calculator className=\"mr-2 h-4 w-4\" />\n <span>Calculator</span>\n </CommandItem>\n </CommandGroup> */}\n <CommandSeparator />\n </CommandList>\n </Command>\n );\n}\n\nexport function Logo({\n children,\n width,\n height,\n}: {\n children: React.ReactNode;\n width: string;\n height: string;\n}) {\n return (\n <div className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n"]}
|
package/dist/chunk-BLRAOGXD.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { arraysAreEqual } from './chunk-F626GQCD.mjs';
|
|
2
|
-
|
|
3
|
-
// src/types/base/editor-autocomplete-state.ts
|
|
4
|
-
function areEqual_autocompleteState(prev, next) {
|
|
5
|
-
return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { areEqual_autocompleteState };
|
|
9
|
-
//# sourceMappingURL=out.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-BLRAOGXD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"names":[],"mappings":";;;;;AASO,SAAS,2BACd,MACA,MACA;AACA,SACE,KAAK,YAAY,WAAW,KAAK,YAAY,UAC7C,eAAe,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,KAC3D,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,oBAAoB,KAAK;AAElC","sourcesContent":["import { BasePoint } from \"slate\";\nimport { arraysAreEqual } from \"../../lib/utils\";\n\nexport interface EditorAutocompleteState {\n cursorPoint: BasePoint;\n textBeforeCursor: string;\n textAfterCursor: string;\n}\n\nexport function areEqual_autocompleteState(\n prev: EditorAutocompleteState,\n next: EditorAutocompleteState,\n) {\n return (\n prev.cursorPoint.offset === next.cursorPoint.offset &&\n arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) &&\n prev.textBeforeCursor === next.textBeforeCursor &&\n prev.textAfterCursor === next.textAfterCursor\n );\n}\n"]}
|
package/dist/chunk-CK7Q3Y5A.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { HoveringInsertionPromptBoxCore } from './chunk-5IISSXS2.mjs';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
var HoveringInsertionPromptBox = (props) => {
|
|
5
|
-
return /* @__PURE__ */ jsx("div", {
|
|
6
|
-
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
7
|
-
style: { width: "35rem" },
|
|
8
|
-
children: /* @__PURE__ */ jsx(HoveringInsertionPromptBoxCore, {
|
|
9
|
-
state: {
|
|
10
|
-
editorState: props.editorState
|
|
11
|
-
},
|
|
12
|
-
insertionOrEditingFunction: props.apiConfig.insertionOrEditingFunction,
|
|
13
|
-
performInsertion: props.performInsertion,
|
|
14
|
-
contextCategories: props.contextCategories
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { HoveringInsertionPromptBox };
|
|
20
|
-
//# sourceMappingURL=out.js.map
|
|
21
|
-
//# sourceMappingURL=chunk-CK7Q3Y5A.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"names":[],"mappings":";;;;;AAqBM;AANC,IAAM,6BAA8C,CAAC,UAAU;AACpE,SACE,oBAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO,EAAE,OAAO,QAAQ;AAAA,IAExB,8BAAC;AAAA,MACC,OAAO;AAAA,QACL,aAAa,MAAM;AAAA,MACrB;AAAA,MACA,4BAA4B,MAAM,UAAU;AAAA,MAC5C,kBAAkB,MAAM;AAAA,MACxB,mBAAmB,MAAM;AAAA,KAC3B;AAAA,GACF;AAEJ","sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n closeWindow: () => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox: React.FC<Props> = (props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n"]}
|
package/dist/chunk-DE5K76I2.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-ECR45NSD.mjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Range, Editor, Text, Element, Path, Point } from 'slate';
|
|
2
|
-
|
|
3
|
-
// src/lib/get-text-around-cursor.ts
|
|
4
|
-
function getTextAroundCollapsedCursor(editor) {
|
|
5
|
-
const { selection } = editor;
|
|
6
|
-
if (!selection || !Range.isCollapsed(selection)) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const cursorPoint = selection.anchor;
|
|
10
|
-
const beforeRange = {
|
|
11
|
-
anchor: Editor.start(editor, []),
|
|
12
|
-
focus: cursorPoint
|
|
13
|
-
};
|
|
14
|
-
const afterRange = {
|
|
15
|
-
anchor: cursorPoint,
|
|
16
|
-
focus: Editor.end(editor, [])
|
|
17
|
-
};
|
|
18
|
-
const before = extractTextWithNewlines(editor, beforeRange);
|
|
19
|
-
const after = extractTextWithNewlines(editor, afterRange);
|
|
20
|
-
return {
|
|
21
|
-
cursorPoint,
|
|
22
|
-
textBeforeCursor: before,
|
|
23
|
-
textAfterCursor: after
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function getTextAroundSelection(editor) {
|
|
27
|
-
const { selection } = editor;
|
|
28
|
-
if (!selection) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const wellOrderedSelection = wellOrderedRange(selection);
|
|
32
|
-
const beforeRange = {
|
|
33
|
-
anchor: Editor.start(editor, []),
|
|
34
|
-
focus: wellOrderedSelection.anchor
|
|
35
|
-
};
|
|
36
|
-
const afterRange = {
|
|
37
|
-
anchor: wellOrderedSelection.focus,
|
|
38
|
-
focus: Editor.end(editor, [])
|
|
39
|
-
};
|
|
40
|
-
const before = extractTextWithNewlines(editor, beforeRange);
|
|
41
|
-
const after = extractTextWithNewlines(editor, afterRange);
|
|
42
|
-
const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);
|
|
43
|
-
return {
|
|
44
|
-
selection: wellOrderedSelection,
|
|
45
|
-
textBeforeCursor: before,
|
|
46
|
-
selectedText,
|
|
47
|
-
textAfterCursor: after
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function getFullEditorTextWithNewlines(editor) {
|
|
51
|
-
const fullDocumentRange = {
|
|
52
|
-
anchor: Editor.start(editor, []),
|
|
53
|
-
focus: Editor.end(editor, [])
|
|
54
|
-
};
|
|
55
|
-
return extractTextWithNewlines(editor, fullDocumentRange);
|
|
56
|
-
}
|
|
57
|
-
function extractTextWithNewlines(editor, range) {
|
|
58
|
-
const voids = false;
|
|
59
|
-
const [start, end] = Range.edges(range);
|
|
60
|
-
let text = "";
|
|
61
|
-
let lastBlock = null;
|
|
62
|
-
for (const [node, path] of Editor.nodes(editor, {
|
|
63
|
-
at: range,
|
|
64
|
-
match: Text.isText,
|
|
65
|
-
voids
|
|
66
|
-
})) {
|
|
67
|
-
let t = node.text;
|
|
68
|
-
const [block] = Editor.above(editor, {
|
|
69
|
-
at: path,
|
|
70
|
-
match: (n) => Element.isElement(n) && n.type === "paragraph"
|
|
71
|
-
}) || [null];
|
|
72
|
-
if (lastBlock !== block && block) {
|
|
73
|
-
if (lastBlock) {
|
|
74
|
-
text += "\n";
|
|
75
|
-
}
|
|
76
|
-
lastBlock = block;
|
|
77
|
-
}
|
|
78
|
-
if (Path.equals(path, end.path)) {
|
|
79
|
-
t = t.slice(0, end.offset);
|
|
80
|
-
}
|
|
81
|
-
if (Path.equals(path, start.path)) {
|
|
82
|
-
t = t.slice(start.offset);
|
|
83
|
-
}
|
|
84
|
-
text += t;
|
|
85
|
-
}
|
|
86
|
-
return text;
|
|
87
|
-
}
|
|
88
|
-
function wellOrderedRange(range) {
|
|
89
|
-
const { anchor, focus } = range;
|
|
90
|
-
if (Point.isBefore(anchor, focus)) {
|
|
91
|
-
return range;
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
anchor: focus,
|
|
95
|
-
focus: anchor
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { extractTextWithNewlines, getFullEditorTextWithNewlines, getTextAroundCollapsedCursor, getTextAroundSelection };
|
|
100
|
-
//# sourceMappingURL=out.js.map
|
|
101
|
-
//# sourceMappingURL=chunk-ECR45NSD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"names":[],"mappings":";AAAA,SAAS,QAAc,MAAM,OAAO,MAAM,SAA+B,aAAa;AAW/E,SAAS,6BAA6B,QAAgD;AAC3F,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,aAAa,CAAC,MAAM,YAAY,SAAS,GAAG;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,UAAU;AAG9B,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO;AAAA,EACT;AACA,QAAM,aAAoB;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AAGA,QAAM,SAAS,wBAAwB,QAAQ,WAAW;AAC1D,QAAM,QAAQ,wBAAwB,QAAQ,UAAU;AAExD,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,EACnB;AACF;AAEO,SAAS,uBAAuB,QAAwC;AAC7E,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,uBAAuB,iBAAiB,SAAS;AAGvD,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO,qBAAqB;AAAA,EAC9B;AACA,QAAM,aAAoB;AAAA,IACxB,QAAQ,qBAAqB;AAAA,IAC7B,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AAGA,QAAM,SAAS,wBAAwB,QAAQ,WAAW;AAC1D,QAAM,QAAQ,wBAAwB,QAAQ,UAAU;AACxD,QAAM,eAAe,wBAAwB,QAAQ,oBAAoB;AAEzE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB;AAAA,IACA,iBAAiB;AAAA,EACnB;AACF;AAEO,SAAS,8BAA8B,QAAwB;AACpE,QAAM,oBAA2B;AAAA,IAC/B,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AACA,SAAO,wBAAwB,QAAQ,iBAAiB;AAC1D;AAGO,SAAS,wBAAwB,QAAgB,OAAsB;AAC5E,QAAM,QAAQ;AACd,QAAM,CAAC,OAAO,GAAG,IAAI,MAAM,MAAM,KAAK;AACtC,MAAI,OAAO;AACX,MAAI,YAAyB;AAE7B,aAAW,CAAC,MAAM,IAAI,KAAK,OAAO,MAAM,QAAQ;AAAA,IAC9C,IAAI;AAAA,IACJ,OAAO,KAAK;AAAA,IACZ;AAAA,EACF,CAAC,GAAG;AACF,QAAI,IAAI,KAAK;AAGb,UAAM,CAAC,KAAK,IAAI,OAAO,MAAM,QAAQ;AAAA,MACnC,IAAI;AAAA,MACJ,OAAO,CAAC,MAAM,QAAQ,UAAU,CAAC,KAAK,EAAE,SAAS;AAAA,IACnD,CAAC,KAAK,CAAC,IAAI;AAGX,QAAI,cAAc,SAAS,OAAO;AAEhC,UAAI,WAAW;AACb,gBAAQ;AAAA,MACV;AACA,kBAAY;AAAA,IACd;AAEA,QAAI,KAAK,OAAO,MAAM,IAAI,IAAI,GAAG;AAC/B,UAAI,EAAE,MAAM,GAAG,IAAI,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,OAAO,MAAM,MAAM,IAAI,GAAG;AACjC,UAAI,EAAE,MAAM,MAAM,MAAM;AAAA,IAC1B;AAEA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,OAA6B;AACrD,QAAM,EAAE,QAAQ,MAAM,IAAI;AAE1B,MAAI,MAAM,SAAS,QAAQ,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAGA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF","sourcesContent":["import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(editor: Editor): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n"]}
|
package/dist/chunk-EZCKXWQF.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
5
|
-
return (props) => {
|
|
6
|
-
const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
|
|
7
|
-
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, restAttributes), {
|
|
8
|
-
style: __spreadValues(__spreadValues({}, style), placeholderStyle),
|
|
9
|
-
children: props.children
|
|
10
|
-
}));
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { makeRenderPlaceholderFunction };
|
|
15
|
-
//# sourceMappingURL=out.js.map
|
|
16
|
-
//# sourceMappingURL=chunk-EZCKXWQF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/base-copilot-textarea/render-placeholder.tsx"],"names":[],"mappings":";;;;;;;AAWM;AAPC,SAAS,8BACd,kBAC2B;AAC3B,SAAO,CAAC,UAAkC;AACxC,UAAqC,WAAM,YAAnC,QARZ,IAQyC,IAAnB,2BAAmB,IAAnB,CAAV;AAER,WACE,oBAAC,wCACK,iBADL;AAAA,MAEC,OAAO,kCACF,QACA;AAAA,MAGJ,gBAAM;AAAA,MACT;AAAA,EAEJ;AACF","sourcesContent":["import { RenderElementProps, RenderPlaceholderProps } from \"slate-react\";\n\nexport type RenderPlaceholderFunction = (props: RenderPlaceholderProps) => JSX.Element;\n\nexport function makeRenderPlaceholderFunction(\n placeholderStyle?: React.CSSProperties,\n): RenderPlaceholderFunction {\n return (props: RenderPlaceholderProps) => {\n const { style, ...restAttributes } = props.attributes;\n\n return (\n <div\n {...restAttributes}\n style={{\n ...style,\n ...placeholderStyle,\n }}\n >\n {props.children}\n </div>\n );\n };\n}\n"]}
|
package/dist/chunk-F626GQCD.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import { customAlphabet } from 'nanoid';
|
|
4
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
|
|
6
|
-
function cn(...inputs) {
|
|
7
|
-
return twMerge(clsx(inputs));
|
|
8
|
-
}
|
|
9
|
-
var nanoid = customAlphabet(
|
|
10
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
11
|
-
7
|
|
12
|
-
);
|
|
13
|
-
function fetcher(input, init) {
|
|
14
|
-
return __async(this, null, function* () {
|
|
15
|
-
const res = yield fetch(input, init);
|
|
16
|
-
if (!res.ok) {
|
|
17
|
-
const json = yield res.json();
|
|
18
|
-
if (json.error) {
|
|
19
|
-
const error = new Error(json.error);
|
|
20
|
-
error.status = res.status;
|
|
21
|
-
throw error;
|
|
22
|
-
} else {
|
|
23
|
-
throw new Error("An unexpected error occurred");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return res.json();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function formatDate(input) {
|
|
30
|
-
const date = new Date(input);
|
|
31
|
-
return date.toLocaleDateString("en-US", {
|
|
32
|
-
month: "long",
|
|
33
|
-
day: "numeric",
|
|
34
|
-
year: "numeric"
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
var arraysAreEqual = (arr1, arr2) => arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
|
|
38
|
-
function nullableCompatibleEqualityCheck(naiveEqualityCheck, a, b) {
|
|
39
|
-
if (a === null || a === void 0 || b === null || b === void 0) {
|
|
40
|
-
return a === b;
|
|
41
|
-
}
|
|
42
|
-
return naiveEqualityCheck(a, b);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { arraysAreEqual, cn, fetcher, formatDate, nanoid, nullableCompatibleEqualityCheck };
|
|
46
|
-
//# sourceMappingURL=out.js.map
|
|
47
|
-
//# sourceMappingURL=chunk-F626GQCD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/utils.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;AAEA,SAAsB,QAAoB,OAAoB,MAAmC;AAAA;AAC/F,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;AAEO,IAAM,iBAAiB,CAAC,MAAgB,SAC7C,KAAK,WAAW,KAAK,UAAU,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM;AAE5E,SAAS,gCACd,oBACA,GACA,GACS;AACT,MAAI,MAAM,QAAQ,MAAM,UAAa,MAAM,QAAQ,MAAM,QAAW;AAClE,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,mBAAmB,GAAG,CAAC;AAChC","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n"]}
|
package/dist/chunk-FK2XUDQQ.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { cn } from './chunk-F626GQCD.mjs';
|
|
2
|
-
import { __objRest, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
5
|
-
import { cva } from 'class-variance-authority';
|
|
6
|
-
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
var labelVariants = cva(
|
|
9
|
-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
10
|
-
);
|
|
11
|
-
var Label = React.forwardRef((_a, ref) => {
|
|
12
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
13
|
-
return /* @__PURE__ */ jsx(LabelPrimitive.Root, __spreadValues({
|
|
14
|
-
ref,
|
|
15
|
-
className: cn(labelVariants(), className)
|
|
16
|
-
}, props));
|
|
17
|
-
});
|
|
18
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
19
|
-
|
|
20
|
-
export { Label };
|
|
21
|
-
//# sourceMappingURL=out.js.map
|
|
22
|
-
//# sourceMappingURL=chunk-FK2XUDQQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ui/label.tsx"],"names":[],"mappings":";;;;;;;;;AAEA,YAAY,WAAW;AACvB,YAAY,oBAAoB;AAChC,SAAS,WAA8B;AAYrC;AAhBF;AAQA,IAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,IAAM,QAAc,iBAGlB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAfL,IAeG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAgB,qBAAf;AAAA,IAAoB;AAAA,IAAU,WAAW,GAAG,cAAc,GAAG,SAAS;AAAA,KAAO,MAAO;AAAA,CACtF;AACD,MAAM,cAA6B,oBAAK","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n"]}
|
package/dist/chunk-FP2EKU3L.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defaultCopilotContextCategories } from '@copilotkit/react-core';
|
|
2
|
-
|
|
3
|
-
// src/types/base/base-autosuggestions-config.tsx
|
|
4
|
-
var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
|
|
5
|
-
if (event.key === "k" && event.metaKey) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
return false;
|
|
9
|
-
};
|
|
10
|
-
var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
|
|
11
|
-
if (event.key === "Tab") {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
var defaultBaseAutosuggestionsConfig = {
|
|
17
|
-
debounceTime: 250,
|
|
18
|
-
contextCategories: defaultCopilotContextCategories,
|
|
19
|
-
disableWhenEmpty: true,
|
|
20
|
-
disabled: false,
|
|
21
|
-
temporarilyDisableWhenMovingCursorWithoutChangingText: true,
|
|
22
|
-
shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
|
|
23
|
-
shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { defaultBaseAutosuggestionsConfig };
|
|
27
|
-
//# sourceMappingURL=out.js.map
|
|
28
|
-
//# sourceMappingURL=chunk-FP2EKU3L.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/base/base-autosuggestions-config.tsx"],"names":[],"mappings":";AACA,SAAS,uCAAuC;AAyDhD,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAS;AACtC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcO,IAAM,mCAGT;AAAA,EACF,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uDAAuD;AAAA,EACvD,sCAAsC;AAAA,EACtC,sCAAsC;AACxC","sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n/**\n * @interface BaseAutosuggestionsConfig\n *\n * @property {string} textareaPurpose - The purpose of the textarea. This is used to guide the autosuggestions.\n *\n * @property {string[]} contextCategories - The categories of context to consider when providing autosuggestions.\n *\n * @property {number} debounceTime - The amount of time (in milliseconds) to wait before triggering autosuggestions after the user has stopped typing.\n *\n * @property {BaseCopilotTextareaApiConfig} apiConfig - The configuration for the API that provides the autosuggestions.\n *\n * @property {boolean} disableWhenEmpty - Whether to disable autosuggestions when the textarea is empty.\n *\n * @property {boolean} disabled - Whether to disable autosuggestions entirely.\n *\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable autosuggestions when the user moves the cursor without changing the text.\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the current autosuggestion based on a key press event. By default, the Tab key is used to accept the autosuggestion. Example code:\n *\n * ```typescript\n * const defaultShouldAcceptAutosuggestionOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if tab, accept the autosuggestion\n * if (event.key === \"Tab\") {\n * return true;\n * }\n * return false;\n * }\n * ```\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:\n *\n * ```typescript\n * const defaultShouldToggleHoveringEditorOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if command-k, toggle the hovering editor\n * if (event.key === \"k\" && event.metaKey) {\n * return true;\n * }\n * return false;\n * }\n * ```\n */\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n contextCategories: string[];\n debounceTime: number;\n apiConfig: BaseCopilotTextareaApiConfig;\n\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n shouldToggleHoveringEditorOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === \"k\" && event.metaKey) {\n return true;\n }\n return false;\n};\n\nconst defaultShouldAcceptAutosuggestionOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if tab, accept the autosuggestion\n if (event.key === \"Tab\") {\n return true;\n }\n return false;\n};\n\n/**\n * Default configuration for the BaseAutosuggestions.\n *\n * @property {number} debounceTime - The amount of time to wait before triggering the autosuggestions API call.\n * @property {string[]} contextCategories - The categories to use for context when making the autosuggestions API call.\n * @property {boolean} disableWhenEmpty - Whether to disable the autosuggestions when the textarea is empty.\n * @property {boolean} disabled - Whether to disable the autosuggestions feature entirely.\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.\n */\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n contextCategories: defaultCopilotContextCategories,\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,\n shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,\n};\n"]}
|
package/dist/chunk-GQN2HYFJ.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Node, Element, Transforms } from 'slate';
|
|
2
|
-
|
|
3
|
-
// src/lib/slatejs-edits/clear-autocompletions.ts
|
|
4
|
-
function clearAutocompletionsFromEditor(editor) {
|
|
5
|
-
const paths = [];
|
|
6
|
-
for (const [node, path] of Node.nodes(editor)) {
|
|
7
|
-
if (Element.isElement(node) && node.type === "suggestion") {
|
|
8
|
-
paths.push(path);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
for (const path of paths) {
|
|
12
|
-
try {
|
|
13
|
-
Transforms.removeNodes(editor, { at: path });
|
|
14
|
-
} catch (e) {
|
|
15
|
-
console.log("CopilotTextarea.clearAutocompletionsFromEditor: error removing node", e);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { clearAutocompletionsFromEditor };
|
|
21
|
-
//# sourceMappingURL=out.js.map
|
|
22
|
-
//# sourceMappingURL=chunk-GQN2HYFJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/slatejs-edits/clear-autocompletions.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,MAAY,kBAAkB;AAGzC,SAAS,+BAA+B,QAAsB;AAEnE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QAAI,QAAQ,UAAU,IAAI,KAAK,KAAK,SAAS,cAAc;AACzD,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,iBAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,GAAP;AACA,cAAQ,IAAI,uEAAuE,CAAC;AAAA,IACtF;AAAA,EACF;AACF","sourcesContent":["import { Element, Node, Path, Transforms } from \"slate\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function clearAutocompletionsFromEditor(editor: CustomEditor) {\n // clear previous suggestion\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (Element.isElement(node) && node.type === \"suggestion\") {\n paths.push(path);\n }\n }\n for (const path of paths) {\n try {\n Transforms.removeNodes(editor, { at: path });\n } catch (e) {\n console.log(\"CopilotTextarea.clearAutocompletionsFromEditor: error removing node\", e);\n }\n }\n}\n"]}
|
package/dist/chunk-H4VKQGVU.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-IU3WTXLQ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-K5LNB36H.mjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// src/types/autosuggestions-config/editing-api-config.tsx
|
|
2
|
-
var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
3
|
-
return `You are a versatile writing assistant.
|
|
4
|
-
|
|
5
|
-
The user is writing some text.
|
|
6
|
-
The purpose is: "${textareaPurpose}"
|
|
7
|
-
|
|
8
|
-
The following external context is also provided. Use it to help you make better suggestions!!!
|
|
9
|
-
\`\`\`
|
|
10
|
-
${contextString}
|
|
11
|
-
\`\`\`
|
|
12
|
-
|
|
13
|
-
The user also provides you with a prompt for EDITING some text they are writing.
|
|
14
|
-
Your job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.
|
|
15
|
-
|
|
16
|
-
Adjust yourself to the user's style and implied intent.
|
|
17
|
-
|
|
18
|
-
The user will provide the following information; use this to infer the best relevant EDIT:
|
|
19
|
-
<TextBeforeCursor>
|
|
20
|
-
<TextToEdit>
|
|
21
|
-
<TextAfterCursor>
|
|
22
|
-
<EditingPrompt>
|
|
23
|
-
|
|
24
|
-
<YourEditSuggestion>
|
|
25
|
-
`;
|
|
26
|
-
};
|
|
27
|
-
var defaultEditingFewShotMessages = [
|
|
28
|
-
{
|
|
29
|
-
role: "user",
|
|
30
|
-
name: "TextBeforeCursor",
|
|
31
|
-
content: "This morning I woke up and went straight to the grocery store. "
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
role: "user",
|
|
35
|
-
name: "TextToEdit",
|
|
36
|
-
content: "While I was there I also picked up some apples, oranges, and bananas. "
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
role: "user",
|
|
40
|
-
name: "TextAfterCursor",
|
|
41
|
-
content: "The grocery store was having a sale on fruit, so I decided to stock up."
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
role: "user",
|
|
45
|
-
name: "EditingPrompt",
|
|
46
|
-
content: "I bought a big watermelon"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
role: "assistant",
|
|
50
|
-
content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
role: "user",
|
|
54
|
-
name: "TextAfterCursor",
|
|
55
|
-
content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
role: "user",
|
|
59
|
-
name: "TextBeforeCursor",
|
|
60
|
-
content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
role: "user",
|
|
64
|
-
name: "InsertionPrompt",
|
|
65
|
-
content: "add section about the optionholder's pro rata share"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
role: "assistant",
|
|
69
|
-
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
70
|
-
}
|
|
71
|
-
];
|
|
72
|
-
var defaultEditingApiConfig = {
|
|
73
|
-
makeSystemPrompt: defaultEditingMakeSystemPrompt,
|
|
74
|
-
fewShotMessages: defaultEditingFewShotMessages,
|
|
75
|
-
forwardedParams: void 0
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export { defaultEditingApiConfig, defaultEditingFewShotMessages, defaultEditingMakeSystemPrompt };
|
|
79
|
-
//# sourceMappingURL=out.js.map
|
|
80
|
-
//# sourceMappingURL=chunk-K5LNB36H.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/autosuggestions-config/editing-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,iCAAmD,CAC9D,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBF;AAEO,IAAM,gCAAyD;AAAA,EACpE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,0BAA4C;AAAA,EACvD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface EditingApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultEditingMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user also provides you with a prompt for EDITING some text they are writing. \nYour job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the following information; use this to infer the best relevant EDIT:\n<TextBeforeCursor>\n<TextToEdit>\n<TextAfterCursor>\n<EditingPrompt>\n\n<YourEditSuggestion>\n`;\n};\n\nexport const defaultEditingFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store. \",\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: \"While I was there I also picked up some apples, oranges, and bananas. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"The grocery store was having a sale on fruit, so I decided to stock up.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"I bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultEditingApiConfig: EditingApiConfig = {\n makeSystemPrompt: defaultEditingMakeSystemPrompt,\n fewShotMessages: defaultEditingFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
|