@copilotkit/react-textarea 1.1.1-athena-preview.2 → 1.1.1-feat-runtime-remote-actions.1
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 +10 -19
- package/dist/{chunk-32Q3LXX3.mjs → chunk-26TDTINS.mjs} +6 -6
- package/dist/{chunk-GXU6UYHI.mjs → chunk-2RGJ6YD6.mjs} +2 -2
- package/dist/{chunk-2PEBAJRK.mjs → chunk-5ABUS3VY.mjs} +2 -2
- package/dist/chunk-5ABUS3VY.mjs.map +1 -0
- package/dist/{chunk-WGWQRALG.mjs → chunk-5G7N3XVC.mjs} +2 -2
- package/dist/{chunk-6HH3NECQ.mjs → chunk-6QIA4FWK.mjs} +2 -3
- package/dist/chunk-6QIA4FWK.mjs.map +1 -0
- package/dist/chunk-FMQG2ZM3.mjs +89 -0
- package/dist/chunk-FMQG2ZM3.mjs.map +1 -0
- package/dist/{chunk-VSVQZUPW.mjs → chunk-Q5KJBZUF.mjs} +2 -2
- package/dist/{chunk-I72DKFHD.mjs → chunk-QQLDM3AI.mjs} +3 -9
- package/dist/chunk-QQLDM3AI.mjs.map +1 -0
- package/dist/{chunk-WPOOZJ3W.mjs → chunk-UNLOFAW7.mjs} +2 -2
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +66 -63
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +9 -9
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +1 -3
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +25 -72
- package/dist/components/copilot-textarea/copilot-textarea.js +66 -63
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +10 -10
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -2
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +1 -2
- package/dist/components/hovering-toolbar/hovering-toolbar.js +0 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +6 -6
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.d.ts +1 -2
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +4 -4
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +1 -2
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +5 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +2 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.ts +0 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +5 -5
- package/dist/components/index.d.ts +5 -5
- package/dist/components/index.js +66 -63
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/components/manual-ui/chip-with-icon.d.ts +1 -3
- package/dist/components/source-search-box/source-search-box.d.ts +2 -3
- package/dist/components/source-search-box/source-search-box.mjs +3 -3
- package/dist/components/ui/command.d.ts +15 -20
- package/dist/components/ui/command.js +2 -8
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/command.mjs +2 -2
- package/dist/components/ui/dialog.d.ts +2 -3
- package/dist/components/ui/dialog.js +2 -8
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dialog.mjs +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js +66 -62
- 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 +1 -1
- package/dist/index.css +5 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +66 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/lib/slatejs-edits/with-partial-history.d.ts +4 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +1 -1
- package/dist/types/base/base-copilot-textarea-props.d.ts +51 -4
- package/dist/types/base/index.d.ts +3 -52
- package/dist/types/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/copilot-textarea/copilot-textarea.tsx +24 -71
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +1 -2
- package/src/components/ui/dialog.tsx +2 -9
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +67 -63
- package/dist/chunk-2PEBAJRK.mjs.map +0 -1
- package/dist/chunk-6HH3NECQ.mjs.map +0 -1
- package/dist/chunk-I72DKFHD.mjs.map +0 -1
- package/dist/chunk-QJNFNPWH.mjs +0 -85
- package/dist/chunk-QJNFNPWH.mjs.map +0 -1
- /package/dist/{chunk-32Q3LXX3.mjs.map → chunk-26TDTINS.mjs.map} +0 -0
- /package/dist/{chunk-GXU6UYHI.mjs.map → chunk-2RGJ6YD6.mjs.map} +0 -0
- /package/dist/{chunk-WGWQRALG.mjs.map → chunk-5G7N3XVC.mjs.map} +0 -0
- /package/dist/{chunk-VSVQZUPW.mjs.map → chunk-Q5KJBZUF.mjs.map} +0 -0
- /package/dist/{chunk-WPOOZJ3W.mjs.map → chunk-UNLOFAW7.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 1.1.1-
|
|
3
|
+
## 1.1.1-feat-runtime-remote-actions.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- faccbe1d: state-abuse resistance for useCopilotChat
|
|
9
|
-
- b0cf700e: remove unnecessary logging
|
|
10
|
-
- Add useCopilotChat stale actions fix
|
|
11
|
-
- Updated dependencies [638d51d9]
|
|
12
|
-
- Updated dependencies [faccbe1d]
|
|
13
|
-
- Updated dependencies [b0cf700e]
|
|
7
|
+
- Include agent state
|
|
14
8
|
- Updated dependencies
|
|
15
|
-
- @copilotkit/
|
|
16
|
-
- @copilotkit/
|
|
17
|
-
- @copilotkit/shared@1.1.1-
|
|
9
|
+
- @copilotkit/runtime-client-gql@1.1.1-feat-runtime-remote-actions.1
|
|
10
|
+
- @copilotkit/react-core@1.1.1-feat-runtime-remote-actions.1
|
|
11
|
+
- @copilotkit/shared@1.1.1-feat-runtime-remote-actions.1
|
|
18
12
|
|
|
19
|
-
## 1.1.1
|
|
13
|
+
## 1.1.1-feat-runtime-remote-actions.0
|
|
20
14
|
|
|
21
15
|
### Patch Changes
|
|
22
16
|
|
|
23
|
-
-
|
|
24
|
-
- center textarea popup
|
|
25
|
-
- show/hide dev console
|
|
26
|
-
- forward maxTokens, stop and force function calling
|
|
17
|
+
- Remote actions preview
|
|
27
18
|
- Updated dependencies
|
|
28
|
-
- @copilotkit/
|
|
29
|
-
- @copilotkit/
|
|
30
|
-
- @copilotkit/shared@1.1.1
|
|
19
|
+
- @copilotkit/runtime-client-gql@1.1.1-feat-runtime-remote-actions.0
|
|
20
|
+
- @copilotkit/react-core@1.1.1-feat-runtime-remote-actions.0
|
|
21
|
+
- @copilotkit/shared@1.1.1-feat-runtime-remote-actions.0
|
|
31
22
|
|
|
32
23
|
## 1.1.0
|
|
33
24
|
|
|
@@ -12,10 +12,13 @@ import {
|
|
|
12
12
|
} from "./chunk-DRV2FOHZ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
usePopulateCopilotTextareaRef
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-FMQG2ZM3.mjs";
|
|
16
16
|
import {
|
|
17
17
|
replaceEditorText
|
|
18
18
|
} from "./chunk-5UNJXFUO.mjs";
|
|
19
|
+
import {
|
|
20
|
+
makeRenderPlaceholderFunction
|
|
21
|
+
} from "./chunk-XW3ICO4S.mjs";
|
|
19
22
|
import {
|
|
20
23
|
TrackerTextEditedSinceLastCursorMovement
|
|
21
24
|
} from "./chunk-LQ2OWQU7.mjs";
|
|
@@ -24,7 +27,7 @@ import {
|
|
|
24
27
|
} from "./chunk-7LSRNPNI.mjs";
|
|
25
28
|
import {
|
|
26
29
|
HoveringToolbar
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6QIA4FWK.mjs";
|
|
28
31
|
import {
|
|
29
32
|
HoveringEditorProvider,
|
|
30
33
|
useHoveringEditorContext
|
|
@@ -35,9 +38,6 @@ import {
|
|
|
35
38
|
import {
|
|
36
39
|
makeRenderElementFunction
|
|
37
40
|
} from "./chunk-224UKA7C.mjs";
|
|
38
|
-
import {
|
|
39
|
-
makeRenderPlaceholderFunction
|
|
40
|
-
} from "./chunk-XW3ICO4S.mjs";
|
|
41
41
|
import {
|
|
42
42
|
getFullEditorTextWithNewlines,
|
|
43
43
|
getTextAroundCollapsedCursor
|
|
@@ -261,4 +261,4 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
261
261
|
export {
|
|
262
262
|
BaseCopilotTextarea
|
|
263
263
|
};
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
264
|
+
//# sourceMappingURL=chunk-26TDTINS.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBoxCore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UNLOFAW7.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -28,4 +28,4 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
28
28
|
export {
|
|
29
29
|
HoveringInsertionPromptBox
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-2RGJ6YD6.mjs.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-HL7EF7KA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
BaseCopilotTextarea
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-26TDTINS.mjs";
|
|
13
13
|
import {
|
|
14
14
|
__objRest,
|
|
15
15
|
__spreadProps,
|
|
@@ -57,4 +57,4 @@ var CopilotTextarea = React.forwardRef(
|
|
|
57
57
|
export {
|
|
58
58
|
CopilotTextarea
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-5ABUS3VY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/copilot-textarea/copilot-textarea.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotTextarea.gif\" width=\"500\" />\n *\n * `<CopilotTextarea>` is a React component that acts as a drop-in replacement for the standard `<textarea>`,\n * offering enhanced autocomplete features powered by AI. It is context-aware, integrating seamlessly with the\n * [`useCopilotReadable`](/reference/hooks/useCopilotReadable) hook to provide intelligent suggestions based on the application context.\n *\n * In addition, it provides a hovering editor window (available by default via `Cmd + K` on Mac and `Ctrl + K` on Windows) that allows the user to\n * suggest changes to the text, for example providing a summary or rephrasing the text.\n *\n *\n * ## Example\n *\n * ```tsx\n * import { CopilotTextarea } from '@copilot/react-ui';\n *\n * <CopilotTextarea\n * autosuggestionsConfig={{\n * textareaPurpose:\n * \"the body of an email message\",\n * chatApiConfigs: {},\n * }}\n * />\n * ```\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Usage\n *\n * Use the CopilotTextarea component in your React application similarly to a standard `<textarea />`,\n * with additional configurations for AI-powered features.\n *\n * For example:\n *\n * ```tsx\n * import { CopilotTextarea } from \"@copilotkit/react-textarea\";\n * import { useState } from \"react\";\n *\n * export function ExampleComponent() {\n * const [text, setText] = useState(\"\");\n *\n * return (\n * <CopilotTextarea\n * className=\"custom-textarea-class\"\n * value={text}\n * onValueChange={(value: string) => setText(value)}\n * placeholder=\"Enter your text here...\"\n * autosuggestionsConfig={{\n * textareaPurpose: \"Provide context or purpose of the textarea.\",\n * chatApiConfigs: {\n * suggestionsApiConfig: {\n * maxTokens: 20,\n * stop: [\".\", \"?\", \"!\"],\n * },\n * },\n * }}\n * />\n * );\n * }\n * ```\n * */\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 /**\n * Configuration settings for the autosuggestions feature.\n * Includes a mandatory `textareaPurpose` to guide the autosuggestions.\n *\n * Autosuggestions can be configured as follows:\n *\n * ```ts\n * {\n * // the purpose of the textarea\n * textareaPurpose: string,\n * chatApiConfigs: {\n * // the config for the suggestions api (optional)\n * suggestionsApiConfig: {\n * // use this to provide a custom system prompt\n * makeSystemPrompt: (textareaPurpose: string, contextString: string) => string;\n * // custom few shot messages\n * fewShotMessages: Message[];\n * // max number of tokens to generate\n * maxTokens: number,\n * // stop generating when these characters are encountered, e.g. [\".\", \"?\", \"!\"]\n * stop: string[],\n * },\n * },\n * insertionApiConfig: //... the similar options as suggestionsApiConfig\n * },\n * }\n * ```\n */\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\n/**\n * A copilot textarea that uses the standard autosuggestions function.\n */\nexport const CopilotTextarea = React.forwardRef(\n (props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;AAsEA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAiEZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA+C;AAE3E,UAAyF,YAAjF,yBAAuB,mCA5HnC,IA4H6F,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,gCACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
CommandItem,
|
|
7
7
|
CommandList,
|
|
8
8
|
CommandSeparator
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q5KJBZUF.mjs";
|
|
10
10
|
|
|
11
11
|
// src/components/source-search-box/source-search-box.tsx
|
|
12
12
|
import { useState } from "react";
|
|
@@ -80,4 +80,4 @@ export {
|
|
|
80
80
|
SourceSearchBox,
|
|
81
81
|
Logo
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-5G7N3XVC.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBox
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2RGJ6YD6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useHoveringEditorContext
|
|
6
6
|
} from "./chunk-LYB4B6MK.mjs";
|
|
@@ -62,7 +62,6 @@ var HoveringToolbar = (props) => {
|
|
|
62
62
|
left = window.innerWidth - el.offsetWidth - minGapFromEdge;
|
|
63
63
|
}
|
|
64
64
|
el.style.opacity = "1";
|
|
65
|
-
el.style.position = "absolute";
|
|
66
65
|
el.style.top = `${top}px`;
|
|
67
66
|
el.style.left = `${left}px`;
|
|
68
67
|
});
|
|
@@ -121,4 +120,4 @@ function editorState(editor, selection) {
|
|
|
121
120
|
export {
|
|
122
121
|
HoveringToolbar
|
|
123
122
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-6QIA4FWK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { Editor, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\nimport { Menu, Portal } from \"./hovering-toolbar-components\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n hoverMenuClassname: string | undefined;\n}\n\nexport const HoveringToolbar = (props: HoveringToolbarProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const editor = useSlate();\n const selection = useSlateSelection();\n const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();\n\n // only render on client\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection || domSelection.rangeCount === 0) {\n return;\n }\n\n const domRange = domSelection.getRangeAt(0);\n const rect = domRange.getBoundingClientRect();\n\n // We use window = (0,0,0,0) as a signal that the selection is not in the original copilot-textarea,\n // but inside the hovering window.\n //\n // in such case, we simply do nothing.\n if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {\n return;\n }\n\n const minGapFromEdge = 60;\n const verticalOffsetFromCorner = 35;\n const horizontalOffsetFromCorner = 15;\n let top = rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;\n // make sure top is in the viewport and not too close to the edge\n if (top < minGapFromEdge) {\n top = rect.bottom + window.scrollY + minGapFromEdge;\n } else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {\n top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;\n }\n\n let left =\n rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;\n // make sure left is in the viewport and not too close to the edge\n if (left < minGapFromEdge) {\n left = minGapFromEdge;\n } else if (left + el.offsetWidth > window.innerWidth - minGapFromEdge) {\n left = window.innerWidth - el.offsetWidth - minGapFromEdge;\n }\n\n el.style.opacity = \"1\";\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsDisplayed(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isClient) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className={\n \"copilot-kit-textarea-css-scope \" +\n (props.hoverMenuClassname ||\n \"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\")\n }\n >\n {isDisplayed && selection && (\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n closeWindow={() => {\n setIsDisplayed(false);\n }}\n performInsertion={(insertedText) => {\n // replace the selection with the inserted text\n Transforms.delete(editor, { at: selection });\n Transforms.insertText(editor, insertedText, {\n at: selection,\n });\n setIsDisplayed(false);\n }}\n contextCategories={props.contextCategories}\n />\n )}\n </Menu>\n </Portal>\n );\n};\n\nfunction editorState(editor: Editor, selection: Location): EditingEditorState {\n const textAroundCursor = getTextAroundSelection(editor);\n if (textAroundCursor) {\n return textAroundCursor;\n }\n\n return {\n textBeforeCursor: getFullEditorTextWithNewlines(editor),\n textAfterCursor: \"\",\n selectedText: \"\",\n };\n}\n"],"mappings":"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","names":["selection"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceEditorText
|
|
3
|
+
} from "./chunk-5UNJXFUO.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getFullEditorTextWithNewlines
|
|
6
|
+
} from "./chunk-ECR45NSD.mjs";
|
|
7
|
+
|
|
8
|
+
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { ReactEditor } from "slate-react";
|
|
11
|
+
function usePopulateCopilotTextareaRef(editor, ref) {
|
|
12
|
+
React.useImperativeHandle(
|
|
13
|
+
ref,
|
|
14
|
+
() => {
|
|
15
|
+
class Combined {
|
|
16
|
+
constructor(customMethods2, editorHtmlElement2) {
|
|
17
|
+
this.customMethods = customMethods2;
|
|
18
|
+
this.editorHtmlElement = editorHtmlElement2;
|
|
19
|
+
}
|
|
20
|
+
get(target, propKey) {
|
|
21
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
22
|
+
const value = this.customMethods[propKey];
|
|
23
|
+
if (typeof value === "function") {
|
|
24
|
+
return value.bind(this.customMethods);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
28
|
+
const value = this.editorHtmlElement[propKey];
|
|
29
|
+
if (typeof value === "function") {
|
|
30
|
+
return value.bind(this.editorHtmlElement);
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
set(target, propKey, value) {
|
|
36
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
37
|
+
this.customMethods[propKey] = value;
|
|
38
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
39
|
+
this.editorHtmlElement[propKey] = value;
|
|
40
|
+
} else {
|
|
41
|
+
target[propKey] = value;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
isKeyOfCustomMethods(key) {
|
|
46
|
+
return key in this.customMethods;
|
|
47
|
+
}
|
|
48
|
+
isKeyOfHTMLElement(key) {
|
|
49
|
+
return key in this.editorHtmlElement;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const handler = {
|
|
53
|
+
get(target, propKey) {
|
|
54
|
+
return target.get(target, propKey);
|
|
55
|
+
},
|
|
56
|
+
set(target, propKey, value) {
|
|
57
|
+
return target.set(target, propKey, value);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
class CustomMethods {
|
|
61
|
+
constructor(editor2) {
|
|
62
|
+
this.editor = editor2;
|
|
63
|
+
}
|
|
64
|
+
focus() {
|
|
65
|
+
ReactEditor.focus(this.editor);
|
|
66
|
+
}
|
|
67
|
+
blur() {
|
|
68
|
+
ReactEditor.blur(this.editor);
|
|
69
|
+
}
|
|
70
|
+
get value() {
|
|
71
|
+
return getFullEditorTextWithNewlines(this.editor);
|
|
72
|
+
}
|
|
73
|
+
set value(value) {
|
|
74
|
+
replaceEditorText(this.editor, value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);
|
|
78
|
+
const customMethods = new CustomMethods(editor);
|
|
79
|
+
const combined = new Combined(customMethods, editorHtmlElement);
|
|
80
|
+
return new Proxy(combined, handler);
|
|
81
|
+
},
|
|
82
|
+
[editor]
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
usePopulateCopilotTextareaRef
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=chunk-FMQG2ZM3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts"],"sourcesContent":["import React from \"react\";\nimport { Editor } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\nimport { getFullEditorTextWithNewlines } from \"../../lib/get-text-around-cursor\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function usePopulateCopilotTextareaRef(\n editor: Editor,\n ref: React.Ref<HTMLCopilotTextAreaElement>,\n) {\n React.useImperativeHandle(\n ref,\n () => {\n class Combined {\n constructor(\n private customMethods: CustomMethods,\n private editorHtmlElement: HTMLElement,\n ) {}\n\n [key: string]: any;\n\n get(target: any, propKey: string): any {\n if (this.isKeyOfCustomMethods(propKey)) {\n const value = this.customMethods[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.customMethods);\n }\n return value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n const value = this.editorHtmlElement[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.editorHtmlElement);\n }\n return value;\n }\n }\n\n set(target: any, propKey: string, value: any): boolean {\n if (this.isKeyOfCustomMethods(propKey)) {\n (this.customMethods as any)[propKey] = value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n (this.editorHtmlElement as any)[propKey] = value;\n } else {\n // Default behavior (optional)\n target[propKey] = value;\n }\n return true;\n }\n\n private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {\n return key in this.customMethods;\n }\n\n private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {\n return key in this.editorHtmlElement;\n }\n }\n\n const handler = {\n get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {\n return target.get(target, propKey);\n },\n set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {\n return target.set(target, propKey, value);\n },\n };\n\n class CustomMethods {\n constructor(private editor: CustomEditor) {}\n\n focus() {\n ReactEditor.focus(this.editor);\n }\n\n blur() {\n ReactEditor.blur(this.editor);\n }\n\n get value() {\n return getFullEditorTextWithNewlines(this.editor);\n }\n set value(value: string) {\n replaceEditorText(this.editor, value);\n }\n }\n\n const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);\n const customMethods = new CustomMethods(editor);\n\n const combined = new Combined(customMethods, editorHtmlElement);\n return new Proxy(combined, handler);\n },\n [editor],\n );\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAS,mBAAmB;AAMrB,SAAS,8BACd,QACA,KACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AACJ,YAAM,SAAS;AAAA,QACb,YACUA,gBACAC,oBACR;AAFQ,+BAAAD;AACA,mCAAAC;AAAA,QACP;AAAA,QAIH,IAAI,QAAa,SAAsB;AACrC,cAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,kBAAM,QAAQ,KAAK,cAAc,OAAO;AACxC,gBAAI,OAAO,UAAU,YAAY;AAC/B,qBAAO,MAAM,KAAK,KAAK,aAAa;AAAA,YACtC;AACA,mBAAO;AAAA,UACT,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,kBAAM,QAAQ,KAAK,kBAAkB,OAAO;AAC5C,gBAAI,OAAO,UAAU,YAAY;AAC/B,qBAAO,MAAM,KAAK,KAAK,iBAAiB;AAAA,YAC1C;AACA,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QAEA,IAAI,QAAa,SAAiB,OAAqB;AACrD,cAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,YAAC,KAAK,cAAsB,OAAO,IAAI;AAAA,UACzC,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,YAAC,KAAK,kBAA0B,OAAO,IAAI;AAAA,UAC7C,OAAO;AAEL,mBAAO,OAAO,IAAI;AAAA,UACpB;AACA,iBAAO;AAAA,QACT;AAAA,QAEQ,qBAAqB,KAAyC;AACpE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,QAEQ,mBAAmB,KAAuC;AAChE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,MACF;AAEA,YAAM,UAAU;AAAA,QACd,IAAI,QAAa,SAAkD;AACjE,iBAAO,OAAO,IAAI,QAAQ,OAAO;AAAA,QACnC;AAAA,QACA,IAAI,QAAa,SAAkD,OAAY;AAC7E,iBAAO,OAAO,IAAI,QAAQ,SAAS,KAAK;AAAA,QAC1C;AAAA,MACF;AAEA,YAAM,cAAc;AAAA,QAClB,YAAoBC,SAAsB;AAAtB,wBAAAA;AAAA,QAAuB;AAAA,QAE3C,QAAQ;AACN,sBAAY,MAAM,KAAK,MAAM;AAAA,QAC/B;AAAA,QAEA,OAAO;AACL,sBAAY,KAAK,KAAK,MAAM;AAAA,QAC9B;AAAA,QAEA,IAAI,QAAQ;AACV,iBAAO,8BAA8B,KAAK,MAAM;AAAA,QAClD;AAAA,QACA,IAAI,MAAM,OAAe;AACvB,4BAAkB,KAAK,QAAQ,KAAK;AAAA,QACtC;AAAA,MACF;AAEA,YAAM,oBAAoB,YAAY,UAAU,QAAQ,MAAM;AAC9D,YAAM,gBAAgB,IAAI,cAAc,MAAM;AAE9C,YAAM,WAAW,IAAI,SAAS,eAAe,iBAAiB;AAC9D,aAAO,IAAI,MAAM,UAAU,OAAO;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF;","names":["customMethods","editorHtmlElement","editor"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Dialog,
|
|
3
3
|
DialogContent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QQLDM3AI.mjs";
|
|
5
5
|
import {
|
|
6
6
|
cn
|
|
7
7
|
} from "./chunk-YLFAIYRY.mjs";
|
|
@@ -121,4 +121,4 @@ export {
|
|
|
121
121
|
CommandItem,
|
|
122
122
|
CommandShortcut
|
|
123
123
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-Q5KJBZUF.mjs.map
|
|
@@ -15,14 +15,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
var Dialog = DialogPrimitive.Root;
|
|
16
16
|
var DialogTrigger = DialogPrimitive.Trigger;
|
|
17
17
|
var DialogPortal = (_a) => {
|
|
18
|
-
var _b = _a, {
|
|
19
|
-
|
|
20
|
-
children
|
|
21
|
-
} = _b, props = __objRest(_b, [
|
|
22
|
-
"className",
|
|
23
|
-
"children"
|
|
24
|
-
]);
|
|
25
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx("div", { className: cn(className), children }) }));
|
|
18
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
19
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, __spreadValues({ className: cn(className) }, props));
|
|
26
20
|
};
|
|
27
21
|
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
28
22
|
var DialogOverlay = React.forwardRef((_a, ref) => {
|
|
@@ -111,4 +105,4 @@ export {
|
|
|
111
105
|
DialogTitle,
|
|
112
106
|
DialogDescription
|
|
113
107
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-QQLDM3AI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/dialog.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = ({ className, ...props }: DialogPrimitive.DialogPortalProps) => (\n <DialogPrimitive.Portal className={cn(className)} {...props} />\n);\nDialogPortal.displayName = DialogPrimitive.Portal.displayName;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col space-y-1.5 text-center sm:text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\", className)}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;;;;AAAA,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAShB,cAkCI,YAlCJ;AALF,IAAM,SAAyB;AAE/B,IAAM,gBAAgC;AAEtC,IAAM,eAAe,CAAC,OAA4D;AAA5D,eAAE,YAVxB,IAUsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB,6BAAiB,wBAAhB,iBAAuB,WAAW,GAAG,SAAS,KAAO,MAAO;AAAA;AAE/D,aAAa,cAA8B,uBAAO;AAElD,IAAM,gBAAsB,iBAG1B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAlBL,IAkBG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAAA,CACD;AACD,cAAc,cAA8B,wBAAQ;AAEpD,IAAM,gBAAsB,iBAG1B,CAAC,IAAmC,QAAK;AAAxC,eAAE,aAAW,SAjChB,IAiCG,IAA0B,kBAA1B,IAA0B,CAAxB,aAAW;AACd,8BAAC,gBACC;AAAA,wBAAC,iBAAc;AAAA,IACf;AAAA,MAAiB;AAAA,MAAhB;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,SACI,QANL;AAAA,QAQE;AAAA;AAAA,UACD,qBAAiB,uBAAhB,EAAsB,WAAU,iRAC/B;AAAA,gCAAC,KAAE,WAAU,WAAU;AAAA,YACvB,oBAAC,UAAK,WAAU,WAAU,mBAAK;AAAA,aACjC;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAAA,CACD;AACD,cAAc,cAA8B,wBAAQ;AAEpD,IAAM,eAAe,CAAC,OAA+D;AAA/D,eAAE,YAtDxB,IAsDsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB,6BAAC,wBAAI,WAAW,GAAG,sDAAsD,SAAS,KAAO,MAAO;AAAA;AAElG,aAAa,cAAc;AAE3B,IAAM,eAAe,CAAC,OAA+D;AAA/D,eAAE,YA3DxB,IA2DsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,iEAAiE,SAAS;AAAA,OACpF;AAAA,EACN;AAAA;AAEF,aAAa,cAAc;AAE3B,IAAM,cAAoB,iBAGxB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAtEL,IAsEG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,qDAAqD,SAAS;AAAA,OACxE;AAAA,EACN;AAAA,CACD;AACD,YAAY,cAA8B,sBAAM;AAEhD,IAAM,oBAA0B,iBAG9B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAlFL,IAkFG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,iCAAiC,SAAS;AAAA,OACpD;AAAA,EACN;AAAA,CACD;AACD,kBAAkB,cAA8B,4BAAY;","names":[]}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-LYB4B6MK.mjs";
|
|
16
16
|
import {
|
|
17
17
|
SourceSearchBox
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5G7N3XVC.mjs";
|
|
19
19
|
import {
|
|
20
20
|
streamPromiseFlatten
|
|
21
21
|
} from "./chunk-2QDCE7PD.mjs";
|
|
@@ -222,4 +222,4 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
222
222
|
export {
|
|
223
223
|
HoveringInsertionPromptBoxCore
|
|
224
224
|
};
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-UNLOFAW7.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { BaseCopilotTextareaProps } from '../../types/base/
|
|
2
|
+
import { BaseCopilotTextareaProps } from '../../types/base/base-copilot-textarea-props.js';
|
|
3
3
|
import '../../types/base/base-autosuggestions-config.js';
|
|
4
4
|
import '../../types/base/autosuggestions-bare-function.js';
|
|
5
5
|
import '@copilotkit/react-core';
|
|
@@ -516,74 +516,78 @@ function replaceEditorText(editor, newText) {
|
|
|
516
516
|
|
|
517
517
|
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
518
518
|
function usePopulateCopilotTextareaRef(editor, ref) {
|
|
519
|
-
import_react3.default.useImperativeHandle(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (
|
|
529
|
-
|
|
519
|
+
import_react3.default.useImperativeHandle(
|
|
520
|
+
ref,
|
|
521
|
+
() => {
|
|
522
|
+
class Combined {
|
|
523
|
+
constructor(customMethods2, editorHtmlElement2) {
|
|
524
|
+
this.customMethods = customMethods2;
|
|
525
|
+
this.editorHtmlElement = editorHtmlElement2;
|
|
526
|
+
}
|
|
527
|
+
get(target, propKey) {
|
|
528
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
529
|
+
const value = this.customMethods[propKey];
|
|
530
|
+
if (typeof value === "function") {
|
|
531
|
+
return value.bind(this.customMethods);
|
|
532
|
+
}
|
|
533
|
+
return value;
|
|
534
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
535
|
+
const value = this.editorHtmlElement[propKey];
|
|
536
|
+
if (typeof value === "function") {
|
|
537
|
+
return value.bind(this.editorHtmlElement);
|
|
538
|
+
}
|
|
539
|
+
return value;
|
|
530
540
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
541
|
+
}
|
|
542
|
+
set(target, propKey, value) {
|
|
543
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
544
|
+
this.customMethods[propKey] = value;
|
|
545
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
546
|
+
this.editorHtmlElement[propKey] = value;
|
|
547
|
+
} else {
|
|
548
|
+
target[propKey] = value;
|
|
536
549
|
}
|
|
537
|
-
return
|
|
550
|
+
return true;
|
|
538
551
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this.editorHtmlElement[propKey] = value;
|
|
545
|
-
} else {
|
|
546
|
-
target[propKey] = value;
|
|
552
|
+
isKeyOfCustomMethods(key) {
|
|
553
|
+
return key in this.customMethods;
|
|
554
|
+
}
|
|
555
|
+
isKeyOfHTMLElement(key) {
|
|
556
|
+
return key in this.editorHtmlElement;
|
|
547
557
|
}
|
|
548
|
-
return true;
|
|
549
|
-
}
|
|
550
|
-
isKeyOfCustomMethods(key) {
|
|
551
|
-
return key in this.customMethods;
|
|
552
|
-
}
|
|
553
|
-
isKeyOfHTMLElement(key) {
|
|
554
|
-
return key in this.editorHtmlElement;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
const handler = {
|
|
558
|
-
get(target, propKey) {
|
|
559
|
-
return target.get(target, propKey);
|
|
560
|
-
},
|
|
561
|
-
set(target, propKey, value) {
|
|
562
|
-
return target.set(target, propKey, value);
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
class CustomMethods {
|
|
566
|
-
constructor(editor2) {
|
|
567
|
-
this.editor = editor2;
|
|
568
|
-
}
|
|
569
|
-
focus() {
|
|
570
|
-
import_slate_react2.ReactEditor.focus(this.editor);
|
|
571
|
-
}
|
|
572
|
-
blur() {
|
|
573
|
-
import_slate_react2.ReactEditor.blur(this.editor);
|
|
574
|
-
}
|
|
575
|
-
get value() {
|
|
576
|
-
return getFullEditorTextWithNewlines(this.editor);
|
|
577
558
|
}
|
|
578
|
-
|
|
579
|
-
|
|
559
|
+
const handler = {
|
|
560
|
+
get(target, propKey) {
|
|
561
|
+
return target.get(target, propKey);
|
|
562
|
+
},
|
|
563
|
+
set(target, propKey, value) {
|
|
564
|
+
return target.set(target, propKey, value);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
class CustomMethods {
|
|
568
|
+
constructor(editor2) {
|
|
569
|
+
this.editor = editor2;
|
|
570
|
+
}
|
|
571
|
+
focus() {
|
|
572
|
+
import_slate_react2.ReactEditor.focus(this.editor);
|
|
573
|
+
}
|
|
574
|
+
blur() {
|
|
575
|
+
import_slate_react2.ReactEditor.blur(this.editor);
|
|
576
|
+
}
|
|
577
|
+
get value() {
|
|
578
|
+
return getFullEditorTextWithNewlines(this.editor);
|
|
579
|
+
}
|
|
580
|
+
set value(value) {
|
|
581
|
+
replaceEditorText(this.editor, value);
|
|
582
|
+
}
|
|
580
583
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
584
|
+
const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
|
|
585
|
+
const customMethods = new CustomMethods(editor);
|
|
586
|
+
const combined = new Combined(customMethods, editorHtmlElement);
|
|
587
|
+
return new Proxy(combined, handler);
|
|
588
|
+
},
|
|
589
|
+
[editor]
|
|
590
|
+
);
|
|
587
591
|
}
|
|
588
592
|
|
|
589
593
|
// src/lib/slatejs-edits/add-autocompletions.ts
|
|
@@ -1337,7 +1341,6 @@ var HoveringToolbar = (props) => {
|
|
|
1337
1341
|
left = window.innerWidth - el.offsetWidth - minGapFromEdge;
|
|
1338
1342
|
}
|
|
1339
1343
|
el.style.opacity = "1";
|
|
1340
|
-
el.style.position = "absolute";
|
|
1341
1344
|
el.style.top = `${top}px`;
|
|
1342
1345
|
el.style.left = `${left}px`;
|
|
1343
1346
|
});
|