@copilotkit/react-textarea 1.8.13 → 1.8.14-next.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 +19 -0
- package/dist/{chunk-MGYT7RNL.mjs → chunk-4ECCCOFV.mjs} +2 -2
- package/dist/{chunk-4XXU5BSA.mjs → chunk-B7WYSFPJ.mjs} +18 -23
- package/dist/chunk-B7WYSFPJ.mjs.map +1 -0
- package/dist/{chunk-4CVSOOJY.mjs → chunk-F6RLSVG3.mjs} +5 -5
- package/dist/chunk-F6RLSVG3.mjs.map +1 -0
- package/dist/{chunk-PZYM7K4Y.mjs → chunk-FQHMDD6N.mjs} +15 -11
- package/dist/chunk-FQHMDD6N.mjs.map +1 -0
- package/dist/{chunk-BNBGJBBM.mjs → chunk-KNH7OQAM.mjs} +5 -5
- package/dist/{chunk-2VMZ5ZWT.mjs → chunk-YHMWPA3C.mjs} +1 -4
- package/dist/chunk-YHMWPA3C.mjs.map +1 -0
- package/dist/{chunk-ABYCGF77.mjs → chunk-YNYXWS2H.mjs} +2 -2
- package/dist/chunk-YNYXWS2H.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +219 -223
- 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/copilot-textarea/copilot-textarea.js +221 -225
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +15 -15
- package/dist/components/hovering-toolbar/hovering-toolbar.js +281 -289
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +4 -4
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +0 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +0 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +0 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +2 -2
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +0 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +2 -2
- package/dist/components/index.js +223 -227
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -15
- package/dist/index.js +223 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/types/autosuggestions-config/autosuggestions-config.js +4 -4
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +2 -2
- package/dist/types/autosuggestions-config/index.js +4 -4
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +2 -2
- package/dist/types/base/base-autosuggestions-config.d.ts +4 -0
- package/dist/types/base/base-autosuggestions-config.js +4 -4
- package/dist/types/base/base-autosuggestions-config.js.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +1 -1
- package/dist/types/base/index.js +4 -4
- package/dist/types/base/index.js.map +1 -1
- package/dist/types/base/index.mjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +3 -3
- package/package.json +4 -4
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +7 -1
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +43 -40
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +0 -3
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx +0 -1
- package/src/types/base/base-autosuggestions-config.tsx +9 -4
- package/dist/chunk-2VMZ5ZWT.mjs.map +0 -1
- package/dist/chunk-4CVSOOJY.mjs.map +0 -1
- package/dist/chunk-4XXU5BSA.mjs.map +0 -1
- package/dist/chunk-ABYCGF77.mjs.map +0 -1
- package/dist/chunk-PZYM7K4Y.mjs.map +0 -1
- /package/dist/{chunk-MGYT7RNL.mjs.map → chunk-4ECCCOFV.mjs.map} +0 -0
- /package/dist/{chunk-BNBGJBBM.mjs.map → chunk-KNH7OQAM.mjs.map} +0 -0
package/dist/components/index.js
CHANGED
|
@@ -632,11 +632,10 @@ function clearAutocompletionsFromEditor(editor) {
|
|
|
632
632
|
|
|
633
633
|
// src/types/base/base-autosuggestions-config.tsx
|
|
634
634
|
var import_react_core = require("@copilotkit/react-core");
|
|
635
|
+
var import_shared = require("@copilotkit/shared");
|
|
635
636
|
var defaultShouldToggleHoveringEditorOnKeyPress = (event, shortcut) => {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
return false;
|
|
637
|
+
const isMetaKey = (0, import_shared.isMacOS)() ? event.metaKey : event.ctrlKey;
|
|
638
|
+
return event.key === shortcut && isMetaKey;
|
|
640
639
|
};
|
|
641
640
|
var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
|
|
642
641
|
if (event.key === "Tab") {
|
|
@@ -651,6 +650,7 @@ var defaultBaseAutosuggestionsConfig = {
|
|
|
651
650
|
disableWhenEmpty: true,
|
|
652
651
|
disabled: false,
|
|
653
652
|
temporarilyDisableWhenMovingCursorWithoutChangingText: true,
|
|
653
|
+
temporarilyDisableNotTrustedEvents: true,
|
|
654
654
|
shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
|
|
655
655
|
shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,
|
|
656
656
|
shouldAcceptAutosuggestionOnTouch: defaultShouldAcceptAutosuggestionOnTouch
|
|
@@ -661,10 +661,123 @@ var import_react9 = require("react");
|
|
|
661
661
|
var import_slate7 = require("slate");
|
|
662
662
|
var import_slate_react3 = require("slate-react");
|
|
663
663
|
|
|
664
|
-
// src/
|
|
664
|
+
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
665
665
|
var import_react4 = require("react");
|
|
666
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
667
|
+
var HoveringEditorContext = (0, import_react4.createContext)({
|
|
668
|
+
isDisplayed: false,
|
|
669
|
+
setIsDisplayed: () => {
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
var HoveringEditorProvider = ({ children }) => {
|
|
673
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react4.useState)(false);
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
675
|
+
};
|
|
676
|
+
var useHoveringEditorContext = () => (0, import_react4.useContext)(HoveringEditorContext);
|
|
677
|
+
|
|
678
|
+
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
679
|
+
var import_css = require("@emotion/css");
|
|
680
|
+
var import_react5 = __toESM(require("react"));
|
|
681
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
682
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
683
|
+
var Button = import_react5.default.forwardRef(
|
|
684
|
+
(_a, ref) => {
|
|
685
|
+
var _b = _a, {
|
|
686
|
+
className,
|
|
687
|
+
active,
|
|
688
|
+
reversed
|
|
689
|
+
} = _b, props = __objRest(_b, [
|
|
690
|
+
"className",
|
|
691
|
+
"active",
|
|
692
|
+
"reversed"
|
|
693
|
+
]);
|
|
694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
695
|
+
"span",
|
|
696
|
+
__spreadProps(__spreadValues({}, props), {
|
|
697
|
+
ref,
|
|
698
|
+
className: (0, import_css.cx)(
|
|
699
|
+
className,
|
|
700
|
+
import_css.css`
|
|
701
|
+
cursor: pointer;
|
|
702
|
+
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
703
|
+
`
|
|
704
|
+
)
|
|
705
|
+
})
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
var Icon = import_react5.default.forwardRef(
|
|
710
|
+
(_a, ref) => {
|
|
711
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
713
|
+
"span",
|
|
714
|
+
__spreadProps(__spreadValues({}, props), {
|
|
715
|
+
ref,
|
|
716
|
+
className: (0, import_css.cx)(
|
|
717
|
+
"material-icons",
|
|
718
|
+
className,
|
|
719
|
+
import_css.css`
|
|
720
|
+
font-size: 18px;
|
|
721
|
+
vertical-align: text-bottom;
|
|
722
|
+
`
|
|
723
|
+
)
|
|
724
|
+
})
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
);
|
|
728
|
+
var Menu = import_react5.default.forwardRef(
|
|
729
|
+
(_a, ref) => {
|
|
730
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
732
|
+
"div",
|
|
733
|
+
__spreadProps(__spreadValues({}, props), {
|
|
734
|
+
"data-testid": "menu",
|
|
735
|
+
ref,
|
|
736
|
+
className: (0, import_css.cx)(
|
|
737
|
+
className,
|
|
738
|
+
import_css.css`
|
|
739
|
+
& > * {
|
|
740
|
+
display: inline-block;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
& > * + * {
|
|
744
|
+
margin-left: 15px;
|
|
745
|
+
}
|
|
746
|
+
`
|
|
747
|
+
)
|
|
748
|
+
})
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
var Portal = ({ children }) => {
|
|
753
|
+
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
754
|
+
};
|
|
755
|
+
var Toolbar = import_react5.default.forwardRef(
|
|
756
|
+
(_a, ref) => {
|
|
757
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
759
|
+
Menu,
|
|
760
|
+
__spreadProps(__spreadValues({}, props), {
|
|
761
|
+
ref,
|
|
762
|
+
className: (0, import_css.cx)(
|
|
763
|
+
className,
|
|
764
|
+
import_css.css`
|
|
765
|
+
position: relative;
|
|
766
|
+
padding: 1px 18px 17px;
|
|
767
|
+
margin: 0 -20px;
|
|
768
|
+
border-bottom: 2px solid #eee;
|
|
769
|
+
margin-bottom: 20px;
|
|
770
|
+
`
|
|
771
|
+
)
|
|
772
|
+
})
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
// src/hooks/misc/use-autosize-textarea.tsx
|
|
778
|
+
var import_react6 = require("react");
|
|
666
779
|
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
667
|
-
(0,
|
|
780
|
+
(0, import_react6.useEffect)(() => {
|
|
668
781
|
if (textAreaRef.current !== null) {
|
|
669
782
|
textAreaRef.current.style.height = "0px";
|
|
670
783
|
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
@@ -675,15 +788,15 @@ var useAutosizeTextArea = (textAreaRef, value) => {
|
|
|
675
788
|
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
676
789
|
|
|
677
790
|
// src/components/source-search-box/source-search-box.tsx
|
|
678
|
-
var
|
|
791
|
+
var import_react7 = require("react");
|
|
679
792
|
|
|
680
793
|
// src/components/ui/command.tsx
|
|
681
|
-
var
|
|
794
|
+
var React3 = __toESM(require("react"));
|
|
682
795
|
var import_cmdk = require("cmdk");
|
|
683
|
-
var
|
|
684
|
-
var Command =
|
|
796
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
797
|
+
var Command = React3.forwardRef((_a, ref) => {
|
|
685
798
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
686
|
-
return /* @__PURE__ */ (0,
|
|
799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
687
800
|
import_cmdk.Command,
|
|
688
801
|
__spreadValues({
|
|
689
802
|
ref,
|
|
@@ -695,9 +808,9 @@ var Command = React2.forwardRef((_a, ref) => {
|
|
|
695
808
|
);
|
|
696
809
|
});
|
|
697
810
|
Command.displayName = import_cmdk.Command.displayName;
|
|
698
|
-
var CommandInput =
|
|
811
|
+
var CommandInput = React3.forwardRef((_a, ref) => {
|
|
699
812
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
700
|
-
return /* @__PURE__ */ (0,
|
|
813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
701
814
|
import_cmdk.Command.Input,
|
|
702
815
|
__spreadValues({
|
|
703
816
|
ref,
|
|
@@ -709,9 +822,9 @@ var CommandInput = React2.forwardRef((_a, ref) => {
|
|
|
709
822
|
) });
|
|
710
823
|
});
|
|
711
824
|
CommandInput.displayName = import_cmdk.Command.Input.displayName;
|
|
712
|
-
var CommandList =
|
|
825
|
+
var CommandList = React3.forwardRef((_a, ref) => {
|
|
713
826
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
714
|
-
return /* @__PURE__ */ (0,
|
|
827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
715
828
|
import_cmdk.Command.List,
|
|
716
829
|
__spreadValues({
|
|
717
830
|
ref,
|
|
@@ -720,11 +833,11 @@ var CommandList = React2.forwardRef((_a, ref) => {
|
|
|
720
833
|
);
|
|
721
834
|
});
|
|
722
835
|
CommandList.displayName = import_cmdk.Command.List.displayName;
|
|
723
|
-
var CommandEmpty =
|
|
836
|
+
var CommandEmpty = React3.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_cmdk.Command.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
|
|
724
837
|
CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
|
|
725
|
-
var CommandGroup =
|
|
838
|
+
var CommandGroup = React3.forwardRef((_a, ref) => {
|
|
726
839
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
727
|
-
return /* @__PURE__ */ (0,
|
|
840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
728
841
|
import_cmdk.Command.Group,
|
|
729
842
|
__spreadValues({
|
|
730
843
|
ref,
|
|
@@ -736,9 +849,9 @@ var CommandGroup = React2.forwardRef((_a, ref) => {
|
|
|
736
849
|
);
|
|
737
850
|
});
|
|
738
851
|
CommandGroup.displayName = import_cmdk.Command.Group.displayName;
|
|
739
|
-
var CommandSeparator =
|
|
852
|
+
var CommandSeparator = React3.forwardRef((_a, ref) => {
|
|
740
853
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
741
|
-
return /* @__PURE__ */ (0,
|
|
854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
742
855
|
import_cmdk.Command.Separator,
|
|
743
856
|
__spreadValues({
|
|
744
857
|
ref,
|
|
@@ -747,9 +860,9 @@ var CommandSeparator = React2.forwardRef((_a, ref) => {
|
|
|
747
860
|
);
|
|
748
861
|
});
|
|
749
862
|
CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
|
|
750
|
-
var CommandItem =
|
|
863
|
+
var CommandItem = React3.forwardRef((_a, ref) => {
|
|
751
864
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
752
|
-
return /* @__PURE__ */ (0,
|
|
865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
753
866
|
import_cmdk.Command.Item,
|
|
754
867
|
__spreadValues({
|
|
755
868
|
ref,
|
|
@@ -763,7 +876,7 @@ var CommandItem = React2.forwardRef((_a, ref) => {
|
|
|
763
876
|
CommandItem.displayName = import_cmdk.Command.Item.displayName;
|
|
764
877
|
var CommandShortcut = (_a) => {
|
|
765
878
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
766
|
-
return /* @__PURE__ */ (0,
|
|
879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
767
880
|
"span",
|
|
768
881
|
__spreadValues({
|
|
769
882
|
className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
|
|
@@ -773,10 +886,10 @@ var CommandShortcut = (_a) => {
|
|
|
773
886
|
CommandShortcut.displayName = "CommandShortcut";
|
|
774
887
|
|
|
775
888
|
// src/components/source-search-box/source-search-box.tsx
|
|
776
|
-
var
|
|
889
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
777
890
|
function SourceSearchBox(props) {
|
|
778
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
779
|
-
return /* @__PURE__ */ (0,
|
|
891
|
+
const [selectedValue, setSelectedValue] = (0, import_react7.useState)("");
|
|
892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
780
893
|
Command,
|
|
781
894
|
{
|
|
782
895
|
className: "rounded-lg border shadow-md",
|
|
@@ -792,7 +905,7 @@ function SourceSearchBox(props) {
|
|
|
792
905
|
return 0;
|
|
793
906
|
},
|
|
794
907
|
children: [
|
|
795
|
-
/* @__PURE__ */ (0,
|
|
908
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
796
909
|
CommandInput,
|
|
797
910
|
{
|
|
798
911
|
value: props.searchTerm,
|
|
@@ -800,18 +913,18 @@ function SourceSearchBox(props) {
|
|
|
800
913
|
placeholder: "Search for a command..."
|
|
801
914
|
}
|
|
802
915
|
),
|
|
803
|
-
/* @__PURE__ */ (0,
|
|
804
|
-
/* @__PURE__ */ (0,
|
|
805
|
-
/* @__PURE__ */ (0,
|
|
806
|
-
return /* @__PURE__ */ (0,
|
|
916
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(CommandList, { children: [
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandEmpty, { children: "No results found." }),
|
|
918
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
|
|
919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
807
920
|
CommandItem,
|
|
808
921
|
{
|
|
809
922
|
value: filePointer.name,
|
|
810
923
|
onSelect: (value) => {
|
|
811
924
|
props.onSelectedFile(filePointer);
|
|
812
925
|
},
|
|
813
|
-
children: /* @__PURE__ */ (0,
|
|
814
|
-
/* @__PURE__ */ (0,
|
|
926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
815
928
|
"img",
|
|
816
929
|
{
|
|
817
930
|
src: filePointer.iconImageUri,
|
|
@@ -825,7 +938,7 @@ function SourceSearchBox(props) {
|
|
|
825
938
|
`word-${filePointer.sourceApplication}.${filePointer.name}`
|
|
826
939
|
);
|
|
827
940
|
}) }),
|
|
828
|
-
/* @__PURE__ */ (0,
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandSeparator, {})
|
|
829
942
|
] })
|
|
830
943
|
]
|
|
831
944
|
}
|
|
@@ -836,17 +949,17 @@ function Logo({
|
|
|
836
949
|
width,
|
|
837
950
|
height
|
|
838
951
|
}) {
|
|
839
|
-
return /* @__PURE__ */ (0,
|
|
952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center justify-center", style: { width, height }, children });
|
|
840
953
|
}
|
|
841
954
|
|
|
842
955
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
843
956
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
844
957
|
|
|
845
958
|
// src/components/ui/button.tsx
|
|
846
|
-
var
|
|
959
|
+
var React4 = __toESM(require("react"));
|
|
847
960
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
848
961
|
var import_class_variance_authority = require("class-variance-authority");
|
|
849
|
-
var
|
|
962
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
850
963
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
851
964
|
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
852
965
|
{
|
|
@@ -872,31 +985,31 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
872
985
|
}
|
|
873
986
|
}
|
|
874
987
|
);
|
|
875
|
-
var
|
|
988
|
+
var Button2 = React4.forwardRef(
|
|
876
989
|
(_a, ref) => {
|
|
877
990
|
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
878
991
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
879
|
-
return /* @__PURE__ */ (0,
|
|
992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
|
|
880
993
|
}
|
|
881
994
|
);
|
|
882
|
-
|
|
995
|
+
Button2.displayName = "Button";
|
|
883
996
|
|
|
884
997
|
// src/components/ui/label.tsx
|
|
885
|
-
var
|
|
998
|
+
var React5 = __toESM(require("react"));
|
|
886
999
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
887
1000
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
888
|
-
var
|
|
1001
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
889
1002
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
890
1003
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
891
1004
|
);
|
|
892
|
-
var Label =
|
|
1005
|
+
var Label = React5.forwardRef((_a, ref) => {
|
|
893
1006
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
894
|
-
return /* @__PURE__ */ (0,
|
|
1007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
|
|
895
1008
|
});
|
|
896
1009
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
897
1010
|
|
|
898
1011
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
899
|
-
var
|
|
1012
|
+
var import_react8 = require("react");
|
|
900
1013
|
|
|
901
1014
|
// src/lib/stream-promise-flatten.ts
|
|
902
1015
|
function streamPromiseFlatten(promise) {
|
|
@@ -925,15 +1038,15 @@ function streamPromiseFlatten(promise) {
|
|
|
925
1038
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
926
1039
|
var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
|
|
927
1040
|
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
928
|
-
var
|
|
1041
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
929
1042
|
var IncludedFilesPreview = ({
|
|
930
1043
|
includedFiles,
|
|
931
1044
|
setIncludedFiles
|
|
932
1045
|
}) => {
|
|
933
|
-
return /* @__PURE__ */ (0,
|
|
934
|
-
/* @__PURE__ */ (0,
|
|
935
|
-
/* @__PURE__ */ (0,
|
|
936
|
-
return /* @__PURE__ */ (0,
|
|
1046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-2 mt-2", children: [
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { className: "", children: "Included context:" }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
|
|
1049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
937
1050
|
FileChipPreview,
|
|
938
1051
|
{
|
|
939
1052
|
filePointer,
|
|
@@ -947,12 +1060,12 @@ var IncludedFilesPreview = ({
|
|
|
947
1060
|
] });
|
|
948
1061
|
};
|
|
949
1062
|
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
950
|
-
return /* @__PURE__ */ (0,
|
|
1063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
951
1064
|
import_Chip.default,
|
|
952
1065
|
{
|
|
953
1066
|
label: filePointer.name,
|
|
954
1067
|
onDelete,
|
|
955
|
-
avatar: /* @__PURE__ */ (0,
|
|
1068
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
956
1069
|
import_Avatar.default,
|
|
957
1070
|
{
|
|
958
1071
|
src: filePointer.iconImageUri,
|
|
@@ -964,22 +1077,8 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
|
964
1077
|
);
|
|
965
1078
|
};
|
|
966
1079
|
|
|
967
|
-
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
968
|
-
var import_react6 = require("react");
|
|
969
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
970
|
-
var HoveringEditorContext = (0, import_react6.createContext)({
|
|
971
|
-
isDisplayed: false,
|
|
972
|
-
setIsDisplayed: () => {
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
var HoveringEditorProvider = ({ children }) => {
|
|
976
|
-
const [isDisplayed, setIsDisplayed] = (0, import_react6.useState)(false);
|
|
977
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
978
|
-
};
|
|
979
|
-
var useHoveringEditorContext = () => (0, import_react6.useContext)(HoveringEditorContext);
|
|
980
|
-
|
|
981
1080
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
982
|
-
var
|
|
1081
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
983
1082
|
var HoveringInsertionPromptBoxCore = ({
|
|
984
1083
|
performInsertion,
|
|
985
1084
|
state,
|
|
@@ -987,26 +1086,26 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
987
1086
|
contextCategories
|
|
988
1087
|
}) => {
|
|
989
1088
|
const { getDocumentsContext } = (0, import_react_core2.useCopilotContext)();
|
|
990
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
991
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
992
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
993
|
-
const [generatingSuggestion, setGeneratingSuggestion] = (0,
|
|
1089
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react8.useState)("");
|
|
1090
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react8.useState)(false);
|
|
1091
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react8.useState)("");
|
|
1092
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react8.useState)(
|
|
994
1093
|
null
|
|
995
1094
|
);
|
|
996
|
-
const adjustmentTextAreaRef = (0,
|
|
997
|
-
const suggestionTextAreaRef = (0,
|
|
998
|
-
const [filePointers, setFilePointers] = (0,
|
|
999
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1000
|
-
(0,
|
|
1095
|
+
const adjustmentTextAreaRef = (0, import_react8.useRef)(null);
|
|
1096
|
+
const suggestionTextAreaRef = (0, import_react8.useRef)(null);
|
|
1097
|
+
const [filePointers, setFilePointers] = (0, import_react8.useState)([]);
|
|
1098
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react8.useState)([]);
|
|
1099
|
+
(0, import_react8.useEffect)(() => {
|
|
1001
1100
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1002
1101
|
}, [contextCategories, getDocumentsContext]);
|
|
1003
1102
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1004
1103
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1005
|
-
(0,
|
|
1104
|
+
(0, import_react8.useEffect)(() => {
|
|
1006
1105
|
var _a;
|
|
1007
1106
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1008
1107
|
}, []);
|
|
1009
|
-
(0,
|
|
1108
|
+
(0, import_react8.useEffect)(() => {
|
|
1010
1109
|
if (!generatingSuggestion) {
|
|
1011
1110
|
return;
|
|
1012
1111
|
}
|
|
@@ -1044,7 +1143,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1044
1143
|
releaseLockIfNotClosed();
|
|
1045
1144
|
};
|
|
1046
1145
|
}, [generatingSuggestion]);
|
|
1047
|
-
const beginGeneratingAdjustment = (0,
|
|
1146
|
+
const beginGeneratingAdjustment = (0, import_react8.useCallback)(() => __async(void 0, null, function* () {
|
|
1048
1147
|
if (!adjustmentPrompt.trim()) {
|
|
1049
1148
|
return;
|
|
1050
1149
|
}
|
|
@@ -1074,10 +1173,10 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1074
1173
|
const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
|
|
1075
1174
|
const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
|
|
1076
1175
|
const { setIsDisplayed } = useHoveringEditorContext();
|
|
1077
|
-
const AdjustmentPromptComponent = /* @__PURE__ */ (0,
|
|
1078
|
-
/* @__PURE__ */ (0,
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1080
|
-
/* @__PURE__ */ (0,
|
|
1176
|
+
const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { className: "", children: adjustmentLabel }),
|
|
1178
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative w-full flex items-center", children: [
|
|
1179
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1081
1180
|
"textarea",
|
|
1082
1181
|
{
|
|
1083
1182
|
"data-testid": "adjustment-prompt",
|
|
@@ -1092,9 +1191,6 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1092
1191
|
} else if (e.key === "Enter") {
|
|
1093
1192
|
e.preventDefault();
|
|
1094
1193
|
beginGeneratingAdjustment();
|
|
1095
|
-
} else if (e.key == "Escape") {
|
|
1096
|
-
e.preventDefault();
|
|
1097
|
-
setIsDisplayed(false);
|
|
1098
1194
|
}
|
|
1099
1195
|
},
|
|
1100
1196
|
placeholder,
|
|
@@ -1103,30 +1199,30 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1103
1199
|
rows: 1
|
|
1104
1200
|
}
|
|
1105
1201
|
),
|
|
1106
|
-
/* @__PURE__ */ (0,
|
|
1202
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1107
1203
|
"button",
|
|
1108
1204
|
{
|
|
1109
1205
|
onClick: beginGeneratingAdjustment,
|
|
1110
1206
|
className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
|
|
1111
1207
|
"data-testid": "generate-button",
|
|
1112
|
-
children: /* @__PURE__ */ (0,
|
|
1208
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "material-icons", children: "arrow_forward" })
|
|
1113
1209
|
}
|
|
1114
1210
|
)
|
|
1115
1211
|
] })
|
|
1116
1212
|
] });
|
|
1117
|
-
const SuggestionComponent = /* @__PURE__ */ (0,
|
|
1118
|
-
/* @__PURE__ */ (0,
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1120
|
-
/* @__PURE__ */ (0,
|
|
1213
|
+
const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
|
|
1216
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1121
1217
|
"div",
|
|
1122
1218
|
{
|
|
1123
1219
|
className: "inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
|
|
1124
1220
|
role: "status",
|
|
1125
|
-
children: /* @__PURE__ */ (0,
|
|
1221
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
|
|
1126
1222
|
}
|
|
1127
1223
|
) }) })
|
|
1128
1224
|
] }),
|
|
1129
|
-
/* @__PURE__ */ (0,
|
|
1225
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1130
1226
|
"textarea",
|
|
1131
1227
|
{
|
|
1132
1228
|
"data-testid": "suggestion-result",
|
|
@@ -1139,8 +1235,8 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1139
1235
|
}
|
|
1140
1236
|
)
|
|
1141
1237
|
] });
|
|
1142
|
-
const SubmitComponent = /* @__PURE__ */ (0,
|
|
1143
|
-
|
|
1238
|
+
const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1239
|
+
Button2,
|
|
1144
1240
|
{
|
|
1145
1241
|
"data-testid": "insert-button",
|
|
1146
1242
|
className: " bg-green-700 text-white",
|
|
@@ -1149,16 +1245,16 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1149
1245
|
},
|
|
1150
1246
|
children: [
|
|
1151
1247
|
"Insert ",
|
|
1152
|
-
/* @__PURE__ */ (0,
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "material-icons", children: "check" })
|
|
1153
1249
|
]
|
|
1154
1250
|
}
|
|
1155
1251
|
) });
|
|
1156
1252
|
const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
|
|
1157
1253
|
const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
|
|
1158
|
-
return /* @__PURE__ */ (0,
|
|
1254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
|
|
1159
1255
|
AdjustmentPromptComponent,
|
|
1160
|
-
filePointers.length > 0 && /* @__PURE__ */ (0,
|
|
1161
|
-
sourceSearchWord !== void 0 && /* @__PURE__ */ (0,
|
|
1256
|
+
filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
|
|
1257
|
+
sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1162
1258
|
SourceSearchBox,
|
|
1163
1259
|
{
|
|
1164
1260
|
searchTerm: sourceSearchWord,
|
|
@@ -1177,14 +1273,14 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1177
1273
|
};
|
|
1178
1274
|
|
|
1179
1275
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
1180
|
-
var
|
|
1276
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1181
1277
|
var HoveringInsertionPromptBox = (props) => {
|
|
1182
|
-
return /* @__PURE__ */ (0,
|
|
1278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1183
1279
|
"div",
|
|
1184
1280
|
{
|
|
1185
1281
|
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
1186
1282
|
style: { width: "35rem" },
|
|
1187
|
-
children: /* @__PURE__ */ (0,
|
|
1283
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1188
1284
|
HoveringInsertionPromptBoxCore,
|
|
1189
1285
|
{
|
|
1190
1286
|
state: {
|
|
@@ -1199,105 +1295,6 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1199
1295
|
);
|
|
1200
1296
|
};
|
|
1201
1297
|
|
|
1202
|
-
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1203
|
-
var import_css = require("@emotion/css");
|
|
1204
|
-
var import_react8 = __toESM(require("react"));
|
|
1205
|
-
var import_react_dom = __toESM(require("react-dom"));
|
|
1206
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1207
|
-
var Button2 = import_react8.default.forwardRef(
|
|
1208
|
-
(_a, ref) => {
|
|
1209
|
-
var _b = _a, {
|
|
1210
|
-
className,
|
|
1211
|
-
active,
|
|
1212
|
-
reversed
|
|
1213
|
-
} = _b, props = __objRest(_b, [
|
|
1214
|
-
"className",
|
|
1215
|
-
"active",
|
|
1216
|
-
"reversed"
|
|
1217
|
-
]);
|
|
1218
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1219
|
-
"span",
|
|
1220
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1221
|
-
ref,
|
|
1222
|
-
className: (0, import_css.cx)(
|
|
1223
|
-
className,
|
|
1224
|
-
import_css.css`
|
|
1225
|
-
cursor: pointer;
|
|
1226
|
-
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
1227
|
-
`
|
|
1228
|
-
)
|
|
1229
|
-
})
|
|
1230
|
-
);
|
|
1231
|
-
}
|
|
1232
|
-
);
|
|
1233
|
-
var Icon = import_react8.default.forwardRef(
|
|
1234
|
-
(_a, ref) => {
|
|
1235
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1237
|
-
"span",
|
|
1238
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1239
|
-
ref,
|
|
1240
|
-
className: (0, import_css.cx)(
|
|
1241
|
-
"material-icons",
|
|
1242
|
-
className,
|
|
1243
|
-
import_css.css`
|
|
1244
|
-
font-size: 18px;
|
|
1245
|
-
vertical-align: text-bottom;
|
|
1246
|
-
`
|
|
1247
|
-
)
|
|
1248
|
-
})
|
|
1249
|
-
);
|
|
1250
|
-
}
|
|
1251
|
-
);
|
|
1252
|
-
var Menu = import_react8.default.forwardRef(
|
|
1253
|
-
(_a, ref) => {
|
|
1254
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1256
|
-
"div",
|
|
1257
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1258
|
-
"data-testid": "menu",
|
|
1259
|
-
ref,
|
|
1260
|
-
className: (0, import_css.cx)(
|
|
1261
|
-
className,
|
|
1262
|
-
import_css.css`
|
|
1263
|
-
& > * {
|
|
1264
|
-
display: inline-block;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
& > * + * {
|
|
1268
|
-
margin-left: 15px;
|
|
1269
|
-
}
|
|
1270
|
-
`
|
|
1271
|
-
)
|
|
1272
|
-
})
|
|
1273
|
-
);
|
|
1274
|
-
}
|
|
1275
|
-
);
|
|
1276
|
-
var Portal = ({ children }) => {
|
|
1277
|
-
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1278
|
-
};
|
|
1279
|
-
var Toolbar = import_react8.default.forwardRef(
|
|
1280
|
-
(_a, ref) => {
|
|
1281
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1282
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1283
|
-
Menu,
|
|
1284
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1285
|
-
ref,
|
|
1286
|
-
className: (0, import_css.cx)(
|
|
1287
|
-
className,
|
|
1288
|
-
import_css.css`
|
|
1289
|
-
position: relative;
|
|
1290
|
-
padding: 1px 18px 17px;
|
|
1291
|
-
margin: 0 -20px;
|
|
1292
|
-
border-bottom: 2px solid #eee;
|
|
1293
|
-
margin-bottom: 20px;
|
|
1294
|
-
`
|
|
1295
|
-
)
|
|
1296
|
-
})
|
|
1297
|
-
);
|
|
1298
|
-
}
|
|
1299
|
-
);
|
|
1300
|
-
|
|
1301
1298
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1302
1299
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1303
1300
|
var HoveringToolbar = (props) => {
|
|
@@ -1309,10 +1306,11 @@ var HoveringToolbar = (props) => {
|
|
|
1309
1306
|
(0, import_react9.useEffect)(() => {
|
|
1310
1307
|
setIsClient(true);
|
|
1311
1308
|
}, []);
|
|
1312
|
-
|
|
1309
|
+
const isShown = isClient && isDisplayed && selection;
|
|
1310
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
1313
1311
|
const el = ref.current;
|
|
1314
1312
|
const { selection: selection2 } = editor;
|
|
1315
|
-
if (!el) {
|
|
1313
|
+
if (!el || !isShown) {
|
|
1316
1314
|
return;
|
|
1317
1315
|
}
|
|
1318
1316
|
if (!selection2) {
|
|
@@ -1328,26 +1326,23 @@ var HoveringToolbar = (props) => {
|
|
|
1328
1326
|
if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {
|
|
1329
1327
|
return;
|
|
1330
1328
|
}
|
|
1331
|
-
const
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
top = rect.bottom + window.scrollY + minGapFromEdge;
|
|
1337
|
-
} else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {
|
|
1338
|
-
top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;
|
|
1329
|
+
const verticalOffsetFromCorner = 0;
|
|
1330
|
+
const horizontalOffsetFromCorner = 0;
|
|
1331
|
+
let top = rect.bottom + window.scrollY + verticalOffsetFromCorner;
|
|
1332
|
+
if (rect.bottom + el.offsetHeight > window.innerHeight - verticalOffsetFromCorner) {
|
|
1333
|
+
top = rect.top + window.scrollY - el.offsetHeight - verticalOffsetFromCorner;
|
|
1339
1334
|
}
|
|
1340
1335
|
let left = rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;
|
|
1341
|
-
if (left <
|
|
1342
|
-
left =
|
|
1343
|
-
} else if (left + el.offsetWidth > window.innerWidth -
|
|
1344
|
-
left = window.innerWidth - el.offsetWidth -
|
|
1336
|
+
if (left < horizontalOffsetFromCorner) {
|
|
1337
|
+
left = horizontalOffsetFromCorner;
|
|
1338
|
+
} else if (left + el.offsetWidth > window.innerWidth - horizontalOffsetFromCorner) {
|
|
1339
|
+
left = window.innerWidth - el.offsetWidth - horizontalOffsetFromCorner;
|
|
1345
1340
|
}
|
|
1346
1341
|
el.style.opacity = "1";
|
|
1347
1342
|
el.style.position = "absolute";
|
|
1348
1343
|
el.style.top = `${top}px`;
|
|
1349
1344
|
el.style.left = `${left}px`;
|
|
1350
|
-
});
|
|
1345
|
+
}, [isShown]);
|
|
1351
1346
|
(0, import_react9.useEffect)(() => {
|
|
1352
1347
|
const handleClickOutside = (event) => {
|
|
1353
1348
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
@@ -1359,7 +1354,7 @@ var HoveringToolbar = (props) => {
|
|
|
1359
1354
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1360
1355
|
};
|
|
1361
1356
|
}, [ref, setIsDisplayed]);
|
|
1362
|
-
if (!
|
|
1357
|
+
if (!isShown) {
|
|
1363
1358
|
return null;
|
|
1364
1359
|
}
|
|
1365
1360
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1368,14 +1363,11 @@ var HoveringToolbar = (props) => {
|
|
|
1368
1363
|
ref,
|
|
1369
1364
|
className: "copilot-kit-textarea-css-scope " + (props.hoverMenuClassname || "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700"),
|
|
1370
1365
|
"data-testid": "hovering-toolbar",
|
|
1371
|
-
children:
|
|
1366
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1372
1367
|
HoveringInsertionPromptBox,
|
|
1373
1368
|
{
|
|
1374
1369
|
editorState: editorState(editor, selection),
|
|
1375
1370
|
apiConfig: props.apiConfig,
|
|
1376
|
-
closeWindow: () => {
|
|
1377
|
-
setIsDisplayed(false);
|
|
1378
|
-
},
|
|
1379
1371
|
performInsertion: (insertedText) => {
|
|
1380
1372
|
import_slate7.Transforms.delete(editor, { at: selection });
|
|
1381
1373
|
import_slate7.Transforms.insertText(editor, insertedText, {
|
|
@@ -1601,6 +1593,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
|
1601
1593
|
}, []);
|
|
1602
1594
|
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
|
|
1603
1595
|
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
|
|
1596
|
+
const [isUserInputActive, setIsUserInputActive] = (0, import_react12.useState)(false);
|
|
1604
1597
|
const initialValue = (0, import_react12.useMemo)(() => {
|
|
1605
1598
|
return [
|
|
1606
1599
|
{
|
|
@@ -1623,7 +1616,8 @@ var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
|
1623
1616
|
// textarea is manually disabled:
|
|
1624
1617
|
autosuggestionsConfig.disabled || // hovering editor is displayed:
|
|
1625
1618
|
hoveringEditorIsDisplayed || // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:
|
|
1626
|
-
cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText
|
|
1619
|
+
cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText || // not user input and we want to disable non-trusted events (like text insertion from autocomplete plugins):
|
|
1620
|
+
!isUserInputActive && autosuggestionsConfig.temporarilyDisableNotTrustedEvents
|
|
1627
1621
|
);
|
|
1628
1622
|
const {
|
|
1629
1623
|
currentAutocompleteSuggestion,
|
|
@@ -1758,6 +1752,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
|
1758
1752
|
renderPlaceholder: renderPlaceholderMemoized,
|
|
1759
1753
|
onKeyDown: (event) => {
|
|
1760
1754
|
var _a2;
|
|
1755
|
+
setIsUserInputActive(true);
|
|
1761
1756
|
onKeyDownHandlerForHoveringEditor(event);
|
|
1762
1757
|
onKeyDownHandlerForAutocomplete(event);
|
|
1763
1758
|
(_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
|
|
@@ -1771,6 +1766,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
|
1771
1766
|
var _a2;
|
|
1772
1767
|
(_a2 = props.onBlur) == null ? void 0 : _a2.call(props, ev);
|
|
1773
1768
|
clearAutocompletionsFromEditor(editor);
|
|
1769
|
+
setIsUserInputActive(false);
|
|
1774
1770
|
}
|
|
1775
1771
|
}, propsToForward)
|
|
1776
1772
|
)
|
|
@@ -1796,7 +1792,7 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
1796
1792
|
var import_react15 = __toESM(require("react"));
|
|
1797
1793
|
|
|
1798
1794
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
1799
|
-
var
|
|
1795
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1800
1796
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1801
1797
|
var import_react13 = require("react");
|
|
1802
1798
|
|
|
@@ -1820,7 +1816,7 @@ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
|
1820
1816
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
1821
1817
|
const { getContextString, copilotApiConfig, runtimeClient } = (0, import_react_core3.useCopilotContext)();
|
|
1822
1818
|
const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;
|
|
1823
|
-
const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers), publicApiKey ? { [
|
|
1819
|
+
const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers), publicApiKey ? { [import_shared2.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
1824
1820
|
const { maxTokens, stop, temperature = 0 } = apiConfig;
|
|
1825
1821
|
return (0, import_react13.useCallback)(
|
|
1826
1822
|
(editorState2, abortSignal) => __async(this, null, function* () {
|
|
@@ -2101,13 +2097,13 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
|
|
|
2101
2097
|
});
|
|
2102
2098
|
|
|
2103
2099
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2104
|
-
var
|
|
2100
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
2105
2101
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
2106
2102
|
var import_react14 = require("react");
|
|
2107
2103
|
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
2108
2104
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2109
2105
|
const { getContextString, copilotApiConfig, runtimeClient } = (0, import_react_core5.useCopilotContext)();
|
|
2110
|
-
const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [
|
|
2106
|
+
const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
|
|
2111
2107
|
function runtimeClientResponseToStringStream(responsePromise) {
|
|
2112
2108
|
return __async(this, null, function* () {
|
|
2113
2109
|
const messagesStream = runtimeClient.asStream(responsePromise);
|