@copilotkit/react-textarea 1.1.1-athena-preview.1 → 1.1.1-athena-preview.2
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 +19 -10
- package/dist/{chunk-P774SJMD.mjs → chunk-2PEBAJRK.mjs} +2 -2
- package/dist/chunk-2PEBAJRK.mjs.map +1 -0
- package/dist/{chunk-5EDG5WL3.mjs → chunk-32Q3LXX3.mjs} +3 -3
- package/dist/{chunk-6QIA4FWK.mjs → chunk-6HH3NECQ.mjs} +3 -2
- package/dist/chunk-6HH3NECQ.mjs.map +1 -0
- package/dist/{chunk-2RGJ6YD6.mjs → chunk-GXU6UYHI.mjs} +2 -2
- package/dist/{chunk-QQLDM3AI.mjs → chunk-I72DKFHD.mjs} +9 -3
- package/dist/chunk-I72DKFHD.mjs.map +1 -0
- package/dist/chunk-QJNFNPWH.mjs +85 -0
- package/dist/chunk-QJNFNPWH.mjs.map +1 -0
- package/dist/{chunk-Q5KJBZUF.mjs → chunk-VSVQZUPW.mjs} +2 -2
- package/dist/{chunk-5G7N3XVC.mjs → chunk-WGWQRALG.mjs} +2 -2
- package/dist/{chunk-UNLOFAW7.mjs → chunk-WPOOZJ3W.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 +63 -66
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +8 -8
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +3 -1
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +72 -25
- package/dist/components/copilot-textarea/copilot-textarea.js +63 -66
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +9 -9
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +2 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +2 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js +1 -0
- 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 +2 -1
- 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 +2 -1
- 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 +3 -2
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.ts +1 -0
- 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 +63 -66
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/components/manual-ui/chip-with-icon.d.ts +3 -1
- package/dist/components/source-search-box/source-search-box.d.ts +3 -2
- package/dist/components/source-search-box/source-search-box.mjs +3 -3
- package/dist/components/ui/command.d.ts +20 -15
- package/dist/components/ui/command.js +8 -2
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/command.mjs +2 -2
- package/dist/components/ui/dialog.d.ts +3 -2
- package/dist/components/ui/dialog.js +8 -2
- 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 +62 -66
- 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 +0 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/lib/slatejs-edits/with-partial-history.d.ts +2 -4
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +1 -1
- package/dist/types/base/base-copilot-textarea-props.d.ts +4 -51
- package/dist/types/base/index.d.ts +52 -3
- package/dist/types/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/copilot-textarea/copilot-textarea.tsx +71 -24
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +2 -1
- package/src/components/ui/dialog.tsx +9 -2
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +63 -67
- package/dist/chunk-6QIA4FWK.mjs.map +0 -1
- package/dist/chunk-FMQG2ZM3.mjs +0 -89
- package/dist/chunk-FMQG2ZM3.mjs.map +0 -1
- package/dist/chunk-P774SJMD.mjs.map +0 -1
- package/dist/chunk-QQLDM3AI.mjs.map +0 -1
- /package/dist/{chunk-5EDG5WL3.mjs.map → chunk-32Q3LXX3.mjs.map} +0 -0
- /package/dist/{chunk-2RGJ6YD6.mjs.map → chunk-GXU6UYHI.mjs.map} +0 -0
- /package/dist/{chunk-Q5KJBZUF.mjs.map → chunk-VSVQZUPW.mjs.map} +0 -0
- /package/dist/{chunk-5G7N3XVC.mjs.map → chunk-WGWQRALG.mjs.map} +0 -0
- /package/dist/{chunk-UNLOFAW7.mjs.map → chunk-WPOOZJ3W.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 1.1.1-athena-preview.
|
|
3
|
+
## 1.1.1-athena-preview.2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 638d51d9: appendMessage fix 1
|
|
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]
|
|
8
14
|
- Updated dependencies
|
|
9
|
-
- @copilotkit/
|
|
10
|
-
- @copilotkit/
|
|
11
|
-
- @copilotkit/shared@1.1.1-athena-preview.
|
|
15
|
+
- @copilotkit/react-core@1.1.1-athena-preview.2
|
|
16
|
+
- @copilotkit/runtime-client-gql@1.1.1-athena-preview.2
|
|
17
|
+
- @copilotkit/shared@1.1.1-athena-preview.2
|
|
12
18
|
|
|
13
|
-
## 1.1.1
|
|
19
|
+
## 1.1.1
|
|
14
20
|
|
|
15
21
|
### Patch Changes
|
|
16
22
|
|
|
17
|
-
-
|
|
23
|
+
- - improved documentation
|
|
24
|
+
- center textarea popup
|
|
25
|
+
- show/hide dev console
|
|
26
|
+
- forward maxTokens, stop and force function calling
|
|
18
27
|
- Updated dependencies
|
|
19
|
-
- @copilotkit/
|
|
20
|
-
- @copilotkit/
|
|
21
|
-
- @copilotkit/shared@1.1.1
|
|
28
|
+
- @copilotkit/react-core@1.1.1
|
|
29
|
+
- @copilotkit/runtime-client-gql@1.1.1
|
|
30
|
+
- @copilotkit/shared@1.1.1
|
|
22
31
|
|
|
23
32
|
## 1.1.0
|
|
24
33
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-HL7EF7KA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
BaseCopilotTextarea
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-32Q3LXX3.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-2PEBAJRK.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 * ## 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 *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx fileName=\"YourRootComponent.tsx\" {2}\n * ...\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.\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 * For full reference, [check the interface on GitHub](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/base/base-copilot-textarea-props.tsx#L8).\n *\n * <PropertyReference name=\"textareaPurpose\" type=\"string\" required={true} >\n * The purpose of the text area in plain text.\n *\n * Example: *\"The body of the email response\"*\n * </PropertyReference>\n *\n * <PropertyReference name=\"chatApiConfigs\" type=\"ChatApiConfigs\" >\n * The chat API configurations.\n *\n * <strong>NOTE:</strong> You must provide specify at least one of `suggestionsApiConfig` or `insertionApiConfig`.\n *\n * <PropertyReference name=\"suggestionsApiConfig\" type=\"SuggestionsApiConfig\">\n * For full reference, please [click here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/autosuggestions-config/suggestions-api-config.tsx#L4).\n * </PropertyReference>\n * <PropertyReference name=\"insertionApiConfig\" type=\"InsertionApiConfig\">\n * For full reference, please [click here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/autosuggestions-config/insertions-api-config.tsx#L4).\n * </PropertyReference>\n * </PropertyReference>\n *\n * <PropertyReference name=\"disabled\" type=\"boolean\" >\n * Whether the textarea is disabled.\n * </PropertyReference>\n *\n * <PropertyReference name=\"disableBranding\" type=\"boolean\" >\n * Whether to disable the CopilotKit branding.\n * </PropertyReference>\n *\n * <PropertyReference name=\"placeholderStyle\" type=\"React.CSSProperties\" >\n * Specifies the CSS styles to apply to the placeholder text.\n * </PropertyReference>\n *\n * <PropertyReference name=\"suggestionsStyle\" type=\"React.CSSProperties\" >\n * Specifies the CSS styles to apply to the suggestions list.\n * </PropertyReference>\n *\n * <PropertyReference name=\"hoverMenuClassname\" type=\"string\" >\n * A class name to apply to the editor popover window.\n * </PropertyReference>\n *\n * <PropertyReference name=\"value\" type=\"string\" >\n * The initial value of the textarea. Can be controlled via `onValueChange`.\n * </PropertyReference>\n *\n * <PropertyReference name=\"onValueChange\" type=\"(value: string) => void\" >\n * Callback invoked when the value of the textarea changes.\n * </PropertyReference>\n *\n * <PropertyReference name=\"onChange\" type=\"(event: React.ChangeEvent<HTMLTextAreaElement>) => void\" >\n * Callback invoked when a `change` event is triggered on the textarea element.\n * </PropertyReference>\n *\n * <PropertyReference name=\"shortcut\" type=\"string\" >\n * The shortcut to use to open the editor popover window. Default is `\"Cmd-k\"`.\n * </PropertyReference>\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":";;;;;;;;;;;;;;;;;;;AAsFA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAgGZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA+C;AAE3E,UAAyF,YAAjF,yBAAuB,mCA3KnC,IA2K6F,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":[]}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-DRV2FOHZ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
usePopulateCopilotTextareaRef
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QJNFNPWH.mjs";
|
|
16
16
|
import {
|
|
17
17
|
replaceEditorText
|
|
18
18
|
} from "./chunk-5UNJXFUO.mjs";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-7LSRNPNI.mjs";
|
|
25
25
|
import {
|
|
26
26
|
HoveringToolbar
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6HH3NECQ.mjs";
|
|
28
28
|
import {
|
|
29
29
|
HoveringEditorProvider,
|
|
30
30
|
useHoveringEditorContext
|
|
@@ -261,4 +261,4 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
261
261
|
export {
|
|
262
262
|
BaseCopilotTextarea
|
|
263
263
|
};
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
264
|
+
//# sourceMappingURL=chunk-32Q3LXX3.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBox
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GXU6UYHI.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useHoveringEditorContext
|
|
6
6
|
} from "./chunk-LYB4B6MK.mjs";
|
|
@@ -62,6 +62,7 @@ var HoveringToolbar = (props) => {
|
|
|
62
62
|
left = window.innerWidth - el.offsetWidth - minGapFromEdge;
|
|
63
63
|
}
|
|
64
64
|
el.style.opacity = "1";
|
|
65
|
+
el.style.position = "absolute";
|
|
65
66
|
el.style.top = `${top}px`;
|
|
66
67
|
el.style.left = `${left}px`;
|
|
67
68
|
});
|
|
@@ -120,4 +121,4 @@ function editorState(editor, selection) {
|
|
|
120
121
|
export {
|
|
121
122
|
HoveringToolbar
|
|
122
123
|
};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-6HH3NECQ.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 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.position = \"absolute\";\n\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":";;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAA2B,kBAAkB;AAC7C,SAAS,UAAU,yBAAyB;AAkHlC;AA/FH,IAAM,kBAAkB,CAAC,UAAgC;AAC9D,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,SAAS,SAAS;AACxB,QAAM,YAAY,kBAAkB;AACpC,QAAM,EAAE,aAAa,eAAe,IAAI,yBAAyB;AAGjE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,YAAU,MAAM;AACd,gBAAY,IAAI;AAAA,EAClB,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,UAAM,KAAK,IAAI;AACf,UAAM,EAAE,WAAAA,WAAU,IAAI;AAEtB,QAAI,CAAC,IAAI;AACP;AAAA,IACF;AAEA,QAAI,CAACA,YAAW;AACd,SAAG,gBAAgB,OAAO;AAC1B;AAAA,IACF;AAEA,UAAM,eAAe,OAAO,aAAa;AACzC,QAAI,CAAC,gBAAgB,aAAa,eAAe,GAAG;AAClD;AAAA,IACF;AAEA,UAAM,WAAW,aAAa,WAAW,CAAC;AAC1C,UAAM,OAAO,SAAS,sBAAsB;AAM5C,QAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,KAAK,KAAK,UAAU,KAAK,KAAK,WAAW,GAAG;AAC9E;AAAA,IACF;AACA,UAAM,iBAAiB;AACvB,UAAM,2BAA2B;AACjC,UAAM,6BAA6B;AACnC,QAAI,MAAM,KAAK,MAAM,OAAO,UAAU,GAAG,eAAe;AAExD,QAAI,MAAM,gBAAgB;AACxB,YAAM,KAAK,SAAS,OAAO,UAAU;AAAA,IACvC,WAAW,MAAM,GAAG,eAAe,OAAO,cAAc,gBAAgB;AACtE,YAAM,KAAK,MAAM,OAAO,UAAU,GAAG,eAAe;AAAA,IACtD;AAEA,QAAI,OACF,KAAK,OAAO,OAAO,UAAU,GAAG,cAAc,IAAI,KAAK,QAAQ,IAAI;AAErE,QAAI,OAAO,gBAAgB;AACzB,aAAO;AAAA,IACT,WAAW,OAAO,GAAG,cAAc,OAAO,aAAa,gBAAgB;AACrE,aAAO,OAAO,aAAa,GAAG,cAAc;AAAA,IAC9C;AAEA,OAAG,MAAM,UAAU;AACnB,OAAG,MAAM,WAAW;AAEpB,OAAG,MAAM,MAAM,GAAG;AAClB,OAAG,MAAM,OAAO,GAAG;AAAA,EACrB,CAAC;AAED,YAAU,MAAM;AACd,UAAM,qBAAqB,CAAC,UAAsB;AAChD,UAAI,IAAI,WAAW,CAAC,IAAI,QAAQ,SAAS,MAAM,MAAc,GAAG;AAC9D,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAEA,aAAS,iBAAiB,aAAa,kBAAkB;AACzD,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SACE,oBAAC,UACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WACE,qCACC,MAAM,sBACL;AAAA,MAGH,yBAAe,aACd;AAAA,QAAC;AAAA;AAAA,UACC,aAAa,YAAY,QAAQ,SAAS;AAAA,UAC1C,WAAW,MAAM;AAAA,UACjB,aAAa,MAAM;AACjB,2BAAe,KAAK;AAAA,UACtB;AAAA,UACA,kBAAkB,CAAC,iBAAiB;AAElC,uBAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,uBAAW,WAAW,QAAQ,cAAc;AAAA,cAC1C,IAAI;AAAA,YACN,CAAC;AACD,2BAAe,KAAK;AAAA,UACtB;AAAA,UACA,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EAEJ,GACF;AAEJ;AAEA,SAAS,YAAY,QAAgB,WAAyC;AAC5E,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,kBAAkB,8BAA8B,MAAM;AAAA,IACtD,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAChB;AACF;","names":["selection"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBoxCore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WPOOZJ3W.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-GXU6UYHI.mjs.map
|
|
@@ -15,8 +15,14 @@ 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
|
-
|
|
18
|
+
var _b = _a, {
|
|
19
|
+
className,
|
|
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 }) }));
|
|
20
26
|
};
|
|
21
27
|
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
22
28
|
var DialogOverlay = React.forwardRef((_a, ref) => {
|
|
@@ -105,4 +111,4 @@ export {
|
|
|
105
111
|
DialogTitle,
|
|
106
112
|
DialogDescription
|
|
107
113
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-I72DKFHD.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 = ({\n className,\n children,\n ...props\n}: DialogPrimitive.DialogPortalProps & { className?: string }) => (\n <DialogPrimitive.Portal {...props}>\n <div className={cn(className)}>{children}</div>\n </DialogPrimitive.Portal>\n);\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;AAcd,cAoCE,YApCF;AAVJ,IAAM,SAAyB;AAE/B,IAAM,gBAAgC;AAEtC,IAAM,eAAe,CAAC,OAIyC;AAJzC,eACpB;AAAA;AAAA,IACA;AAAA,EAZF,IAUsB,IAGjB,kBAHiB,IAGjB;AAAA,IAFH;AAAA,IACA;AAAA;AAGA,6BAAiB,wBAAhB,iCAA2B,QAA3B,EACC,8BAAC,SAAI,WAAW,GAAG,SAAS,GAAI,UAAS,IAC3C;AAAA;AAGF,aAAa,cAA8B,uBAAO;AAElD,IAAM,gBAAsB,iBAG1B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAzBL,IAyBG,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,SAxChB,IAwCG,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,YA7DxB,IA6DsB,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,YAlExB,IAkEsB,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,YA7EL,IA6EG,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,YAzFL,IAyFG,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":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
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(ref, () => {
|
|
13
|
+
class Combined {
|
|
14
|
+
constructor(customMethods2, editorHtmlElement2) {
|
|
15
|
+
this.customMethods = customMethods2;
|
|
16
|
+
this.editorHtmlElement = editorHtmlElement2;
|
|
17
|
+
}
|
|
18
|
+
get(target, propKey) {
|
|
19
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
20
|
+
const value = this.customMethods[propKey];
|
|
21
|
+
if (typeof value === "function") {
|
|
22
|
+
return value.bind(this.customMethods);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
26
|
+
const value = this.editorHtmlElement[propKey];
|
|
27
|
+
if (typeof value === "function") {
|
|
28
|
+
return value.bind(this.editorHtmlElement);
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
set(target, propKey, value) {
|
|
34
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
35
|
+
this.customMethods[propKey] = value;
|
|
36
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
37
|
+
this.editorHtmlElement[propKey] = value;
|
|
38
|
+
} else {
|
|
39
|
+
target[propKey] = value;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
isKeyOfCustomMethods(key) {
|
|
44
|
+
return key in this.customMethods;
|
|
45
|
+
}
|
|
46
|
+
isKeyOfHTMLElement(key) {
|
|
47
|
+
return key in this.editorHtmlElement;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const handler = {
|
|
51
|
+
get(target, propKey) {
|
|
52
|
+
return target.get(target, propKey);
|
|
53
|
+
},
|
|
54
|
+
set(target, propKey, value) {
|
|
55
|
+
return target.set(target, propKey, value);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
class CustomMethods {
|
|
59
|
+
constructor(editor2) {
|
|
60
|
+
this.editor = editor2;
|
|
61
|
+
}
|
|
62
|
+
focus() {
|
|
63
|
+
ReactEditor.focus(this.editor);
|
|
64
|
+
}
|
|
65
|
+
blur() {
|
|
66
|
+
ReactEditor.blur(this.editor);
|
|
67
|
+
}
|
|
68
|
+
get value() {
|
|
69
|
+
return getFullEditorTextWithNewlines(this.editor);
|
|
70
|
+
}
|
|
71
|
+
set value(value) {
|
|
72
|
+
replaceEditorText(this.editor, value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);
|
|
76
|
+
const customMethods = new CustomMethods(editor);
|
|
77
|
+
const combined = new Combined(customMethods, editorHtmlElement);
|
|
78
|
+
return new Proxy(combined, handler);
|
|
79
|
+
}, [editor]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
usePopulateCopilotTextareaRef
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=chunk-QJNFNPWH.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(ref, () => {\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 }, [editor]);\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAS,mBAAmB;AAMrB,SAAS,8BACd,QACA,KACA;AACA,QAAM,oBAAoB,KAAK,MAAM;AACnC,UAAM,SAAS;AAAA,MACb,YACUA,gBACAC,oBACR;AAFQ,6BAAAD;AACA,iCAAAC;AAAA,MACP;AAAA,MAIH,IAAI,QAAa,SAAsB;AACrC,YAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,gBAAM,QAAQ,KAAK,cAAc,OAAO;AACxC,cAAI,OAAO,UAAU,YAAY;AAC/B,mBAAO,MAAM,KAAK,KAAK,aAAa;AAAA,UACtC;AACA,iBAAO;AAAA,QACT,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,gBAAM,QAAQ,KAAK,kBAAkB,OAAO;AAC5C,cAAI,OAAO,UAAU,YAAY;AAC/B,mBAAO,MAAM,KAAK,KAAK,iBAAiB;AAAA,UAC1C;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MAEA,IAAI,QAAa,SAAiB,OAAqB;AACrD,YAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,UAAC,KAAK,cAAsB,OAAO,IAAI;AAAA,QACzC,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,UAAC,KAAK,kBAA0B,OAAO,IAAI;AAAA,QAC7C,OAAO;AAEL,iBAAO,OAAO,IAAI;AAAA,QACpB;AACA,eAAO;AAAA,MACT;AAAA,MAEQ,qBAAqB,KAAyC;AACpE,eAAO,OAAO,KAAK;AAAA,MACrB;AAAA,MAEQ,mBAAmB,KAAuC;AAChE,eAAO,OAAO,KAAK;AAAA,MACrB;AAAA,IACF;AAEA,UAAM,UAAU;AAAA,MACd,IAAI,QAAa,SAAkD;AACjE,eAAO,OAAO,IAAI,QAAQ,OAAO;AAAA,MACnC;AAAA,MACA,IAAI,QAAa,SAAkD,OAAY;AAC7E,eAAO,OAAO,IAAI,QAAQ,SAAS,KAAK;AAAA,MAC1C;AAAA,IACF;AAEA,UAAM,cAAc;AAAA,MAClB,YAAoBC,SAAsB;AAAtB,sBAAAA;AAAA,MAAuB;AAAA,MAE3C,QAAQ;AACN,oBAAY,MAAM,KAAK,MAAM;AAAA,MAC/B;AAAA,MAEA,OAAO;AACL,oBAAY,KAAK,KAAK,MAAM;AAAA,MAC9B;AAAA,MAEA,IAAI,QAAQ;AACV,eAAO,8BAA8B,KAAK,MAAM;AAAA,MAClD;AAAA,MACA,IAAI,MAAM,OAAe;AACvB,0BAAkB,KAAK,QAAQ,KAAK;AAAA,MACtC;AAAA,IACF;AAEA,UAAM,oBAAoB,YAAY,UAAU,QAAQ,MAAM;AAC9D,UAAM,gBAAgB,IAAI,cAAc,MAAM;AAE9C,UAAM,WAAW,IAAI,SAAS,eAAe,iBAAiB;AAC9D,WAAO,IAAI,MAAM,UAAU,OAAO;AAAA,EACpC,GAAG,CAAC,MAAM,CAAC;AACb;","names":["customMethods","editorHtmlElement","editor"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Dialog,
|
|
3
3
|
DialogContent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-I72DKFHD.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-VSVQZUPW.mjs.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
CommandItem,
|
|
7
7
|
CommandList,
|
|
8
8
|
CommandSeparator
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VSVQZUPW.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-WGWQRALG.mjs.map
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-LYB4B6MK.mjs";
|
|
16
16
|
import {
|
|
17
17
|
SourceSearchBox
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WGWQRALG.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-WPOOZJ3W.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/index.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,78 +516,74 @@ 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
|
-
|
|
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;
|
|
519
|
+
import_react3.default.useImperativeHandle(ref, () => {
|
|
520
|
+
class Combined {
|
|
521
|
+
constructor(customMethods2, editorHtmlElement2) {
|
|
522
|
+
this.customMethods = customMethods2;
|
|
523
|
+
this.editorHtmlElement = editorHtmlElement2;
|
|
524
|
+
}
|
|
525
|
+
get(target, propKey) {
|
|
526
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
527
|
+
const value = this.customMethods[propKey];
|
|
528
|
+
if (typeof value === "function") {
|
|
529
|
+
return value.bind(this.customMethods);
|
|
540
530
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
this.editorHtmlElement[propKey] = value;
|
|
547
|
-
} else {
|
|
548
|
-
target[propKey] = value;
|
|
531
|
+
return value;
|
|
532
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
533
|
+
const value = this.editorHtmlElement[propKey];
|
|
534
|
+
if (typeof value === "function") {
|
|
535
|
+
return value.bind(this.editorHtmlElement);
|
|
549
536
|
}
|
|
550
|
-
return
|
|
551
|
-
}
|
|
552
|
-
isKeyOfCustomMethods(key) {
|
|
553
|
-
return key in this.customMethods;
|
|
554
|
-
}
|
|
555
|
-
isKeyOfHTMLElement(key) {
|
|
556
|
-
return key in this.editorHtmlElement;
|
|
537
|
+
return value;
|
|
557
538
|
}
|
|
558
539
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
|
|
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);
|
|
540
|
+
set(target, propKey, value) {
|
|
541
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
542
|
+
this.customMethods[propKey] = value;
|
|
543
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
544
|
+
this.editorHtmlElement[propKey] = value;
|
|
545
|
+
} else {
|
|
546
|
+
target[propKey] = value;
|
|
582
547
|
}
|
|
548
|
+
return true;
|
|
583
549
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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
|
+
}
|
|
578
|
+
set value(value) {
|
|
579
|
+
replaceEditorText(this.editor, value);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
|
|
583
|
+
const customMethods = new CustomMethods(editor);
|
|
584
|
+
const combined = new Combined(customMethods, editorHtmlElement);
|
|
585
|
+
return new Proxy(combined, handler);
|
|
586
|
+
}, [editor]);
|
|
591
587
|
}
|
|
592
588
|
|
|
593
589
|
// src/lib/slatejs-edits/add-autocompletions.ts
|
|
@@ -1341,6 +1337,7 @@ var HoveringToolbar = (props) => {
|
|
|
1341
1337
|
left = window.innerWidth - el.offsetWidth - minGapFromEdge;
|
|
1342
1338
|
}
|
|
1343
1339
|
el.style.opacity = "1";
|
|
1340
|
+
el.style.position = "absolute";
|
|
1344
1341
|
el.style.top = `${top}px`;
|
|
1345
1342
|
el.style.left = `${left}px`;
|
|
1346
1343
|
});
|