@copilotkit/react-textarea 1.8.14-next.0 → 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 +9 -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 +22 -22
- 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
|
@@ -177,11 +177,10 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
177
177
|
|
|
178
178
|
// src/types/base/base-autosuggestions-config.tsx
|
|
179
179
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
180
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
180
181
|
var defaultShouldToggleHoveringEditorOnKeyPress = (event, shortcut) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
182
|
+
const isMetaKey = (0, import_shared2.isMacOS)() ? event.metaKey : event.ctrlKey;
|
|
183
|
+
return event.key === shortcut && isMetaKey;
|
|
185
184
|
};
|
|
186
185
|
var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
|
|
187
186
|
if (event.key === "Tab") {
|
|
@@ -196,6 +195,7 @@ var defaultBaseAutosuggestionsConfig = {
|
|
|
196
195
|
disableWhenEmpty: true,
|
|
197
196
|
disabled: false,
|
|
198
197
|
temporarilyDisableWhenMovingCursorWithoutChangingText: true,
|
|
198
|
+
temporarilyDisableNotTrustedEvents: true,
|
|
199
199
|
shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
|
|
200
200
|
shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,
|
|
201
201
|
shouldAcceptAutosuggestionOnTouch: defaultShouldAcceptAutosuggestionOnTouch
|
|
@@ -966,10 +966,123 @@ var import_react10 = require("react");
|
|
|
966
966
|
var import_slate7 = require("slate");
|
|
967
967
|
var import_slate_react3 = require("slate-react");
|
|
968
968
|
|
|
969
|
-
// src/
|
|
969
|
+
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
970
970
|
var import_react5 = require("react");
|
|
971
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
972
|
+
var HoveringEditorContext = (0, import_react5.createContext)({
|
|
973
|
+
isDisplayed: false,
|
|
974
|
+
setIsDisplayed: () => {
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
var HoveringEditorProvider = ({ children }) => {
|
|
978
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react5.useState)(false);
|
|
979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
980
|
+
};
|
|
981
|
+
var useHoveringEditorContext = () => (0, import_react5.useContext)(HoveringEditorContext);
|
|
982
|
+
|
|
983
|
+
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
984
|
+
var import_css = require("@emotion/css");
|
|
985
|
+
var import_react6 = __toESM(require("react"));
|
|
986
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
987
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
988
|
+
var Button = import_react6.default.forwardRef(
|
|
989
|
+
(_a, ref) => {
|
|
990
|
+
var _b = _a, {
|
|
991
|
+
className,
|
|
992
|
+
active,
|
|
993
|
+
reversed
|
|
994
|
+
} = _b, props = __objRest(_b, [
|
|
995
|
+
"className",
|
|
996
|
+
"active",
|
|
997
|
+
"reversed"
|
|
998
|
+
]);
|
|
999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1000
|
+
"span",
|
|
1001
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1002
|
+
ref,
|
|
1003
|
+
className: (0, import_css.cx)(
|
|
1004
|
+
className,
|
|
1005
|
+
import_css.css`
|
|
1006
|
+
cursor: pointer;
|
|
1007
|
+
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
1008
|
+
`
|
|
1009
|
+
)
|
|
1010
|
+
})
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
);
|
|
1014
|
+
var Icon = import_react6.default.forwardRef(
|
|
1015
|
+
(_a, ref) => {
|
|
1016
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1018
|
+
"span",
|
|
1019
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1020
|
+
ref,
|
|
1021
|
+
className: (0, import_css.cx)(
|
|
1022
|
+
"material-icons",
|
|
1023
|
+
className,
|
|
1024
|
+
import_css.css`
|
|
1025
|
+
font-size: 18px;
|
|
1026
|
+
vertical-align: text-bottom;
|
|
1027
|
+
`
|
|
1028
|
+
)
|
|
1029
|
+
})
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1033
|
+
var Menu = import_react6.default.forwardRef(
|
|
1034
|
+
(_a, ref) => {
|
|
1035
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1037
|
+
"div",
|
|
1038
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1039
|
+
"data-testid": "menu",
|
|
1040
|
+
ref,
|
|
1041
|
+
className: (0, import_css.cx)(
|
|
1042
|
+
className,
|
|
1043
|
+
import_css.css`
|
|
1044
|
+
& > * {
|
|
1045
|
+
display: inline-block;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
& > * + * {
|
|
1049
|
+
margin-left: 15px;
|
|
1050
|
+
}
|
|
1051
|
+
`
|
|
1052
|
+
)
|
|
1053
|
+
})
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
);
|
|
1057
|
+
var Portal = ({ children }) => {
|
|
1058
|
+
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1059
|
+
};
|
|
1060
|
+
var Toolbar = import_react6.default.forwardRef(
|
|
1061
|
+
(_a, ref) => {
|
|
1062
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1064
|
+
Menu,
|
|
1065
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1066
|
+
ref,
|
|
1067
|
+
className: (0, import_css.cx)(
|
|
1068
|
+
className,
|
|
1069
|
+
import_css.css`
|
|
1070
|
+
position: relative;
|
|
1071
|
+
padding: 1px 18px 17px;
|
|
1072
|
+
margin: 0 -20px;
|
|
1073
|
+
border-bottom: 2px solid #eee;
|
|
1074
|
+
margin-bottom: 20px;
|
|
1075
|
+
`
|
|
1076
|
+
)
|
|
1077
|
+
})
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
);
|
|
1081
|
+
|
|
1082
|
+
// src/hooks/misc/use-autosize-textarea.tsx
|
|
1083
|
+
var import_react7 = require("react");
|
|
971
1084
|
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
972
|
-
(0,
|
|
1085
|
+
(0, import_react7.useEffect)(() => {
|
|
973
1086
|
if (textAreaRef.current !== null) {
|
|
974
1087
|
textAreaRef.current.style.height = "0px";
|
|
975
1088
|
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
@@ -980,15 +1093,15 @@ var useAutosizeTextArea = (textAreaRef, value) => {
|
|
|
980
1093
|
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
981
1094
|
|
|
982
1095
|
// src/components/source-search-box/source-search-box.tsx
|
|
983
|
-
var
|
|
1096
|
+
var import_react8 = require("react");
|
|
984
1097
|
|
|
985
1098
|
// src/components/ui/command.tsx
|
|
986
|
-
var
|
|
1099
|
+
var React3 = __toESM(require("react"));
|
|
987
1100
|
var import_cmdk = require("cmdk");
|
|
988
|
-
var
|
|
989
|
-
var Command =
|
|
1101
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1102
|
+
var Command = React3.forwardRef((_a, ref) => {
|
|
990
1103
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
991
|
-
return /* @__PURE__ */ (0,
|
|
1104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
992
1105
|
import_cmdk.Command,
|
|
993
1106
|
__spreadValues({
|
|
994
1107
|
ref,
|
|
@@ -1000,9 +1113,9 @@ var Command = React2.forwardRef((_a, ref) => {
|
|
|
1000
1113
|
);
|
|
1001
1114
|
});
|
|
1002
1115
|
Command.displayName = import_cmdk.Command.displayName;
|
|
1003
|
-
var CommandInput =
|
|
1116
|
+
var CommandInput = React3.forwardRef((_a, ref) => {
|
|
1004
1117
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1005
|
-
return /* @__PURE__ */ (0,
|
|
1118
|
+
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)(
|
|
1006
1119
|
import_cmdk.Command.Input,
|
|
1007
1120
|
__spreadValues({
|
|
1008
1121
|
ref,
|
|
@@ -1014,9 +1127,9 @@ var CommandInput = React2.forwardRef((_a, ref) => {
|
|
|
1014
1127
|
) });
|
|
1015
1128
|
});
|
|
1016
1129
|
CommandInput.displayName = import_cmdk.Command.Input.displayName;
|
|
1017
|
-
var CommandList =
|
|
1130
|
+
var CommandList = React3.forwardRef((_a, ref) => {
|
|
1018
1131
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1019
|
-
return /* @__PURE__ */ (0,
|
|
1132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1020
1133
|
import_cmdk.Command.List,
|
|
1021
1134
|
__spreadValues({
|
|
1022
1135
|
ref,
|
|
@@ -1025,11 +1138,11 @@ var CommandList = React2.forwardRef((_a, ref) => {
|
|
|
1025
1138
|
);
|
|
1026
1139
|
});
|
|
1027
1140
|
CommandList.displayName = import_cmdk.Command.List.displayName;
|
|
1028
|
-
var CommandEmpty =
|
|
1141
|
+
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)));
|
|
1029
1142
|
CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
|
|
1030
|
-
var CommandGroup =
|
|
1143
|
+
var CommandGroup = React3.forwardRef((_a, ref) => {
|
|
1031
1144
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1032
|
-
return /* @__PURE__ */ (0,
|
|
1145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1033
1146
|
import_cmdk.Command.Group,
|
|
1034
1147
|
__spreadValues({
|
|
1035
1148
|
ref,
|
|
@@ -1041,9 +1154,9 @@ var CommandGroup = React2.forwardRef((_a, ref) => {
|
|
|
1041
1154
|
);
|
|
1042
1155
|
});
|
|
1043
1156
|
CommandGroup.displayName = import_cmdk.Command.Group.displayName;
|
|
1044
|
-
var CommandSeparator =
|
|
1157
|
+
var CommandSeparator = React3.forwardRef((_a, ref) => {
|
|
1045
1158
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1046
|
-
return /* @__PURE__ */ (0,
|
|
1159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1047
1160
|
import_cmdk.Command.Separator,
|
|
1048
1161
|
__spreadValues({
|
|
1049
1162
|
ref,
|
|
@@ -1052,9 +1165,9 @@ var CommandSeparator = React2.forwardRef((_a, ref) => {
|
|
|
1052
1165
|
);
|
|
1053
1166
|
});
|
|
1054
1167
|
CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
|
|
1055
|
-
var CommandItem =
|
|
1168
|
+
var CommandItem = React3.forwardRef((_a, ref) => {
|
|
1056
1169
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1057
|
-
return /* @__PURE__ */ (0,
|
|
1170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1058
1171
|
import_cmdk.Command.Item,
|
|
1059
1172
|
__spreadValues({
|
|
1060
1173
|
ref,
|
|
@@ -1068,7 +1181,7 @@ var CommandItem = React2.forwardRef((_a, ref) => {
|
|
|
1068
1181
|
CommandItem.displayName = import_cmdk.Command.Item.displayName;
|
|
1069
1182
|
var CommandShortcut = (_a) => {
|
|
1070
1183
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1071
|
-
return /* @__PURE__ */ (0,
|
|
1184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1072
1185
|
"span",
|
|
1073
1186
|
__spreadValues({
|
|
1074
1187
|
className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
|
|
@@ -1078,10 +1191,10 @@ var CommandShortcut = (_a) => {
|
|
|
1078
1191
|
CommandShortcut.displayName = "CommandShortcut";
|
|
1079
1192
|
|
|
1080
1193
|
// src/components/source-search-box/source-search-box.tsx
|
|
1081
|
-
var
|
|
1194
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1082
1195
|
function SourceSearchBox(props) {
|
|
1083
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
1084
|
-
return /* @__PURE__ */ (0,
|
|
1196
|
+
const [selectedValue, setSelectedValue] = (0, import_react8.useState)("");
|
|
1197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1085
1198
|
Command,
|
|
1086
1199
|
{
|
|
1087
1200
|
className: "rounded-lg border shadow-md",
|
|
@@ -1097,7 +1210,7 @@ function SourceSearchBox(props) {
|
|
|
1097
1210
|
return 0;
|
|
1098
1211
|
},
|
|
1099
1212
|
children: [
|
|
1100
|
-
/* @__PURE__ */ (0,
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1101
1214
|
CommandInput,
|
|
1102
1215
|
{
|
|
1103
1216
|
value: props.searchTerm,
|
|
@@ -1105,18 +1218,18 @@ function SourceSearchBox(props) {
|
|
|
1105
1218
|
placeholder: "Search for a command..."
|
|
1106
1219
|
}
|
|
1107
1220
|
),
|
|
1108
|
-
/* @__PURE__ */ (0,
|
|
1109
|
-
/* @__PURE__ */ (0,
|
|
1110
|
-
/* @__PURE__ */ (0,
|
|
1111
|
-
return /* @__PURE__ */ (0,
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(CommandList, { children: [
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandEmpty, { children: "No results found." }),
|
|
1223
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
|
|
1224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1112
1225
|
CommandItem,
|
|
1113
1226
|
{
|
|
1114
1227
|
value: filePointer.name,
|
|
1115
1228
|
onSelect: (value) => {
|
|
1116
1229
|
props.onSelectedFile(filePointer);
|
|
1117
1230
|
},
|
|
1118
|
-
children: /* @__PURE__ */ (0,
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1231
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1120
1233
|
"img",
|
|
1121
1234
|
{
|
|
1122
1235
|
src: filePointer.iconImageUri,
|
|
@@ -1130,7 +1243,7 @@ function SourceSearchBox(props) {
|
|
|
1130
1243
|
`word-${filePointer.sourceApplication}.${filePointer.name}`
|
|
1131
1244
|
);
|
|
1132
1245
|
}) }),
|
|
1133
|
-
/* @__PURE__ */ (0,
|
|
1246
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CommandSeparator, {})
|
|
1134
1247
|
] })
|
|
1135
1248
|
]
|
|
1136
1249
|
}
|
|
@@ -1141,17 +1254,17 @@ function Logo({
|
|
|
1141
1254
|
width,
|
|
1142
1255
|
height
|
|
1143
1256
|
}) {
|
|
1144
|
-
return /* @__PURE__ */ (0,
|
|
1257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center justify-center", style: { width, height }, children });
|
|
1145
1258
|
}
|
|
1146
1259
|
|
|
1147
1260
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1148
1261
|
var import_react_core4 = require("@copilotkit/react-core");
|
|
1149
1262
|
|
|
1150
1263
|
// src/components/ui/button.tsx
|
|
1151
|
-
var
|
|
1264
|
+
var React4 = __toESM(require("react"));
|
|
1152
1265
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
1153
1266
|
var import_class_variance_authority = require("class-variance-authority");
|
|
1154
|
-
var
|
|
1267
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1155
1268
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
1156
1269
|
"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",
|
|
1157
1270
|
{
|
|
@@ -1177,31 +1290,31 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
1177
1290
|
}
|
|
1178
1291
|
}
|
|
1179
1292
|
);
|
|
1180
|
-
var
|
|
1293
|
+
var Button2 = React4.forwardRef(
|
|
1181
1294
|
(_a, ref) => {
|
|
1182
1295
|
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
1183
1296
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1184
|
-
return /* @__PURE__ */ (0,
|
|
1297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
|
|
1185
1298
|
}
|
|
1186
1299
|
);
|
|
1187
|
-
|
|
1300
|
+
Button2.displayName = "Button";
|
|
1188
1301
|
|
|
1189
1302
|
// src/components/ui/label.tsx
|
|
1190
|
-
var
|
|
1303
|
+
var React5 = __toESM(require("react"));
|
|
1191
1304
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
1192
1305
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1193
|
-
var
|
|
1306
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1194
1307
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
1195
1308
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
1196
1309
|
);
|
|
1197
|
-
var Label =
|
|
1310
|
+
var Label = React5.forwardRef((_a, ref) => {
|
|
1198
1311
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1199
|
-
return /* @__PURE__ */ (0,
|
|
1312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
|
|
1200
1313
|
});
|
|
1201
1314
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1202
1315
|
|
|
1203
1316
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1204
|
-
var
|
|
1317
|
+
var import_react9 = require("react");
|
|
1205
1318
|
|
|
1206
1319
|
// src/lib/stream-promise-flatten.ts
|
|
1207
1320
|
function streamPromiseFlatten(promise) {
|
|
@@ -1230,15 +1343,15 @@ function streamPromiseFlatten(promise) {
|
|
|
1230
1343
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
1231
1344
|
var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
|
|
1232
1345
|
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
1233
|
-
var
|
|
1346
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1234
1347
|
var IncludedFilesPreview = ({
|
|
1235
1348
|
includedFiles,
|
|
1236
1349
|
setIncludedFiles
|
|
1237
1350
|
}) => {
|
|
1238
|
-
return /* @__PURE__ */ (0,
|
|
1239
|
-
/* @__PURE__ */ (0,
|
|
1240
|
-
/* @__PURE__ */ (0,
|
|
1241
|
-
return /* @__PURE__ */ (0,
|
|
1351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-2 mt-2", children: [
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { className: "", children: "Included context:" }),
|
|
1353
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
|
|
1354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1242
1355
|
FileChipPreview,
|
|
1243
1356
|
{
|
|
1244
1357
|
filePointer,
|
|
@@ -1252,12 +1365,12 @@ var IncludedFilesPreview = ({
|
|
|
1252
1365
|
] });
|
|
1253
1366
|
};
|
|
1254
1367
|
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
1255
|
-
return /* @__PURE__ */ (0,
|
|
1368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1256
1369
|
import_Chip.default,
|
|
1257
1370
|
{
|
|
1258
1371
|
label: filePointer.name,
|
|
1259
1372
|
onDelete,
|
|
1260
|
-
avatar: /* @__PURE__ */ (0,
|
|
1373
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1261
1374
|
import_Avatar.default,
|
|
1262
1375
|
{
|
|
1263
1376
|
src: filePointer.iconImageUri,
|
|
@@ -1269,22 +1382,8 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
|
1269
1382
|
);
|
|
1270
1383
|
};
|
|
1271
1384
|
|
|
1272
|
-
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1273
|
-
var import_react7 = require("react");
|
|
1274
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1275
|
-
var HoveringEditorContext = (0, import_react7.createContext)({
|
|
1276
|
-
isDisplayed: false,
|
|
1277
|
-
setIsDisplayed: () => {
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
var HoveringEditorProvider = ({ children }) => {
|
|
1281
|
-
const [isDisplayed, setIsDisplayed] = (0, import_react7.useState)(false);
|
|
1282
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1283
|
-
};
|
|
1284
|
-
var useHoveringEditorContext = () => (0, import_react7.useContext)(HoveringEditorContext);
|
|
1285
|
-
|
|
1286
1385
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1287
|
-
var
|
|
1386
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1288
1387
|
var HoveringInsertionPromptBoxCore = ({
|
|
1289
1388
|
performInsertion,
|
|
1290
1389
|
state,
|
|
@@ -1292,26 +1391,26 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1292
1391
|
contextCategories
|
|
1293
1392
|
}) => {
|
|
1294
1393
|
const { getDocumentsContext } = (0, import_react_core4.useCopilotContext)();
|
|
1295
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
1296
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
1297
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
1298
|
-
const [generatingSuggestion, setGeneratingSuggestion] = (0,
|
|
1394
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react9.useState)("");
|
|
1395
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react9.useState)(false);
|
|
1396
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react9.useState)("");
|
|
1397
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react9.useState)(
|
|
1299
1398
|
null
|
|
1300
1399
|
);
|
|
1301
|
-
const adjustmentTextAreaRef = (0,
|
|
1302
|
-
const suggestionTextAreaRef = (0,
|
|
1303
|
-
const [filePointers, setFilePointers] = (0,
|
|
1304
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1305
|
-
(0,
|
|
1400
|
+
const adjustmentTextAreaRef = (0, import_react9.useRef)(null);
|
|
1401
|
+
const suggestionTextAreaRef = (0, import_react9.useRef)(null);
|
|
1402
|
+
const [filePointers, setFilePointers] = (0, import_react9.useState)([]);
|
|
1403
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react9.useState)([]);
|
|
1404
|
+
(0, import_react9.useEffect)(() => {
|
|
1306
1405
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1307
1406
|
}, [contextCategories, getDocumentsContext]);
|
|
1308
1407
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1309
1408
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1310
|
-
(0,
|
|
1409
|
+
(0, import_react9.useEffect)(() => {
|
|
1311
1410
|
var _a;
|
|
1312
1411
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1313
1412
|
}, []);
|
|
1314
|
-
(0,
|
|
1413
|
+
(0, import_react9.useEffect)(() => {
|
|
1315
1414
|
if (!generatingSuggestion) {
|
|
1316
1415
|
return;
|
|
1317
1416
|
}
|
|
@@ -1349,7 +1448,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1349
1448
|
releaseLockIfNotClosed();
|
|
1350
1449
|
};
|
|
1351
1450
|
}, [generatingSuggestion]);
|
|
1352
|
-
const beginGeneratingAdjustment = (0,
|
|
1451
|
+
const beginGeneratingAdjustment = (0, import_react9.useCallback)(() => __async(void 0, null, function* () {
|
|
1353
1452
|
if (!adjustmentPrompt.trim()) {
|
|
1354
1453
|
return;
|
|
1355
1454
|
}
|
|
@@ -1379,10 +1478,10 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1379
1478
|
const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
|
|
1380
1479
|
const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
|
|
1381
1480
|
const { setIsDisplayed } = useHoveringEditorContext();
|
|
1382
|
-
const AdjustmentPromptComponent = /* @__PURE__ */ (0,
|
|
1383
|
-
/* @__PURE__ */ (0,
|
|
1384
|
-
/* @__PURE__ */ (0,
|
|
1385
|
-
/* @__PURE__ */ (0,
|
|
1481
|
+
const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { className: "", children: adjustmentLabel }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative w-full flex items-center", children: [
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1386
1485
|
"textarea",
|
|
1387
1486
|
{
|
|
1388
1487
|
"data-testid": "adjustment-prompt",
|
|
@@ -1397,9 +1496,6 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1397
1496
|
} else if (e.key === "Enter") {
|
|
1398
1497
|
e.preventDefault();
|
|
1399
1498
|
beginGeneratingAdjustment();
|
|
1400
|
-
} else if (e.key == "Escape") {
|
|
1401
|
-
e.preventDefault();
|
|
1402
|
-
setIsDisplayed(false);
|
|
1403
1499
|
}
|
|
1404
1500
|
},
|
|
1405
1501
|
placeholder,
|
|
@@ -1408,30 +1504,30 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1408
1504
|
rows: 1
|
|
1409
1505
|
}
|
|
1410
1506
|
),
|
|
1411
|
-
/* @__PURE__ */ (0,
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1412
1508
|
"button",
|
|
1413
1509
|
{
|
|
1414
1510
|
onClick: beginGeneratingAdjustment,
|
|
1415
1511
|
className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
|
|
1416
1512
|
"data-testid": "generate-button",
|
|
1417
|
-
children: /* @__PURE__ */ (0,
|
|
1513
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "material-icons", children: "arrow_forward" })
|
|
1418
1514
|
}
|
|
1419
1515
|
)
|
|
1420
1516
|
] })
|
|
1421
1517
|
] });
|
|
1422
|
-
const SuggestionComponent = /* @__PURE__ */ (0,
|
|
1423
|
-
/* @__PURE__ */ (0,
|
|
1424
|
-
/* @__PURE__ */ (0,
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1518
|
+
const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
|
|
1520
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
|
|
1521
|
+
/* @__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)(
|
|
1426
1522
|
"div",
|
|
1427
1523
|
{
|
|
1428
1524
|
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]",
|
|
1429
1525
|
role: "status",
|
|
1430
|
-
children: /* @__PURE__ */ (0,
|
|
1526
|
+
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..." })
|
|
1431
1527
|
}
|
|
1432
1528
|
) }) })
|
|
1433
1529
|
] }),
|
|
1434
|
-
/* @__PURE__ */ (0,
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1435
1531
|
"textarea",
|
|
1436
1532
|
{
|
|
1437
1533
|
"data-testid": "suggestion-result",
|
|
@@ -1444,8 +1540,8 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1444
1540
|
}
|
|
1445
1541
|
)
|
|
1446
1542
|
] });
|
|
1447
|
-
const SubmitComponent = /* @__PURE__ */ (0,
|
|
1448
|
-
|
|
1543
|
+
const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1544
|
+
Button2,
|
|
1449
1545
|
{
|
|
1450
1546
|
"data-testid": "insert-button",
|
|
1451
1547
|
className: " bg-green-700 text-white",
|
|
@@ -1454,16 +1550,16 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1454
1550
|
},
|
|
1455
1551
|
children: [
|
|
1456
1552
|
"Insert ",
|
|
1457
|
-
/* @__PURE__ */ (0,
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "material-icons", children: "check" })
|
|
1458
1554
|
]
|
|
1459
1555
|
}
|
|
1460
1556
|
) });
|
|
1461
1557
|
const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
|
|
1462
1558
|
const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
|
|
1463
|
-
return /* @__PURE__ */ (0,
|
|
1559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
|
|
1464
1560
|
AdjustmentPromptComponent,
|
|
1465
|
-
filePointers.length > 0 && /* @__PURE__ */ (0,
|
|
1466
|
-
sourceSearchWord !== void 0 && /* @__PURE__ */ (0,
|
|
1561
|
+
filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
|
|
1562
|
+
sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1467
1563
|
SourceSearchBox,
|
|
1468
1564
|
{
|
|
1469
1565
|
searchTerm: sourceSearchWord,
|
|
@@ -1482,14 +1578,14 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1482
1578
|
};
|
|
1483
1579
|
|
|
1484
1580
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
1485
|
-
var
|
|
1581
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1486
1582
|
var HoveringInsertionPromptBox = (props) => {
|
|
1487
|
-
return /* @__PURE__ */ (0,
|
|
1583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1488
1584
|
"div",
|
|
1489
1585
|
{
|
|
1490
1586
|
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
1491
1587
|
style: { width: "35rem" },
|
|
1492
|
-
children: /* @__PURE__ */ (0,
|
|
1588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1493
1589
|
HoveringInsertionPromptBoxCore,
|
|
1494
1590
|
{
|
|
1495
1591
|
state: {
|
|
@@ -1504,105 +1600,6 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1504
1600
|
);
|
|
1505
1601
|
};
|
|
1506
1602
|
|
|
1507
|
-
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1508
|
-
var import_css = require("@emotion/css");
|
|
1509
|
-
var import_react9 = __toESM(require("react"));
|
|
1510
|
-
var import_react_dom = __toESM(require("react-dom"));
|
|
1511
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1512
|
-
var Button2 = import_react9.default.forwardRef(
|
|
1513
|
-
(_a, ref) => {
|
|
1514
|
-
var _b = _a, {
|
|
1515
|
-
className,
|
|
1516
|
-
active,
|
|
1517
|
-
reversed
|
|
1518
|
-
} = _b, props = __objRest(_b, [
|
|
1519
|
-
"className",
|
|
1520
|
-
"active",
|
|
1521
|
-
"reversed"
|
|
1522
|
-
]);
|
|
1523
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1524
|
-
"span",
|
|
1525
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1526
|
-
ref,
|
|
1527
|
-
className: (0, import_css.cx)(
|
|
1528
|
-
className,
|
|
1529
|
-
import_css.css`
|
|
1530
|
-
cursor: pointer;
|
|
1531
|
-
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
1532
|
-
`
|
|
1533
|
-
)
|
|
1534
|
-
})
|
|
1535
|
-
);
|
|
1536
|
-
}
|
|
1537
|
-
);
|
|
1538
|
-
var Icon = import_react9.default.forwardRef(
|
|
1539
|
-
(_a, ref) => {
|
|
1540
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1541
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1542
|
-
"span",
|
|
1543
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1544
|
-
ref,
|
|
1545
|
-
className: (0, import_css.cx)(
|
|
1546
|
-
"material-icons",
|
|
1547
|
-
className,
|
|
1548
|
-
import_css.css`
|
|
1549
|
-
font-size: 18px;
|
|
1550
|
-
vertical-align: text-bottom;
|
|
1551
|
-
`
|
|
1552
|
-
)
|
|
1553
|
-
})
|
|
1554
|
-
);
|
|
1555
|
-
}
|
|
1556
|
-
);
|
|
1557
|
-
var Menu = import_react9.default.forwardRef(
|
|
1558
|
-
(_a, ref) => {
|
|
1559
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1561
|
-
"div",
|
|
1562
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1563
|
-
"data-testid": "menu",
|
|
1564
|
-
ref,
|
|
1565
|
-
className: (0, import_css.cx)(
|
|
1566
|
-
className,
|
|
1567
|
-
import_css.css`
|
|
1568
|
-
& > * {
|
|
1569
|
-
display: inline-block;
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
& > * + * {
|
|
1573
|
-
margin-left: 15px;
|
|
1574
|
-
}
|
|
1575
|
-
`
|
|
1576
|
-
)
|
|
1577
|
-
})
|
|
1578
|
-
);
|
|
1579
|
-
}
|
|
1580
|
-
);
|
|
1581
|
-
var Portal = ({ children }) => {
|
|
1582
|
-
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1583
|
-
};
|
|
1584
|
-
var Toolbar = import_react9.default.forwardRef(
|
|
1585
|
-
(_a, ref) => {
|
|
1586
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1587
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1588
|
-
Menu,
|
|
1589
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1590
|
-
ref,
|
|
1591
|
-
className: (0, import_css.cx)(
|
|
1592
|
-
className,
|
|
1593
|
-
import_css.css`
|
|
1594
|
-
position: relative;
|
|
1595
|
-
padding: 1px 18px 17px;
|
|
1596
|
-
margin: 0 -20px;
|
|
1597
|
-
border-bottom: 2px solid #eee;
|
|
1598
|
-
margin-bottom: 20px;
|
|
1599
|
-
`
|
|
1600
|
-
)
|
|
1601
|
-
})
|
|
1602
|
-
);
|
|
1603
|
-
}
|
|
1604
|
-
);
|
|
1605
|
-
|
|
1606
1603
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1607
1604
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1608
1605
|
var HoveringToolbar = (props) => {
|
|
@@ -1614,10 +1611,11 @@ var HoveringToolbar = (props) => {
|
|
|
1614
1611
|
(0, import_react10.useEffect)(() => {
|
|
1615
1612
|
setIsClient(true);
|
|
1616
1613
|
}, []);
|
|
1617
|
-
|
|
1614
|
+
const isShown = isClient && isDisplayed && selection;
|
|
1615
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1618
1616
|
const el = ref.current;
|
|
1619
1617
|
const { selection: selection2 } = editor;
|
|
1620
|
-
if (!el) {
|
|
1618
|
+
if (!el || !isShown) {
|
|
1621
1619
|
return;
|
|
1622
1620
|
}
|
|
1623
1621
|
if (!selection2) {
|
|
@@ -1633,26 +1631,23 @@ var HoveringToolbar = (props) => {
|
|
|
1633
1631
|
if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {
|
|
1634
1632
|
return;
|
|
1635
1633
|
}
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
top = rect.bottom + window.scrollY + minGapFromEdge;
|
|
1642
|
-
} else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {
|
|
1643
|
-
top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;
|
|
1634
|
+
const verticalOffsetFromCorner = 0;
|
|
1635
|
+
const horizontalOffsetFromCorner = 0;
|
|
1636
|
+
let top = rect.bottom + window.scrollY + verticalOffsetFromCorner;
|
|
1637
|
+
if (rect.bottom + el.offsetHeight > window.innerHeight - verticalOffsetFromCorner) {
|
|
1638
|
+
top = rect.top + window.scrollY - el.offsetHeight - verticalOffsetFromCorner;
|
|
1644
1639
|
}
|
|
1645
1640
|
let left = rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;
|
|
1646
|
-
if (left <
|
|
1647
|
-
left =
|
|
1648
|
-
} else if (left + el.offsetWidth > window.innerWidth -
|
|
1649
|
-
left = window.innerWidth - el.offsetWidth -
|
|
1641
|
+
if (left < horizontalOffsetFromCorner) {
|
|
1642
|
+
left = horizontalOffsetFromCorner;
|
|
1643
|
+
} else if (left + el.offsetWidth > window.innerWidth - horizontalOffsetFromCorner) {
|
|
1644
|
+
left = window.innerWidth - el.offsetWidth - horizontalOffsetFromCorner;
|
|
1650
1645
|
}
|
|
1651
1646
|
el.style.opacity = "1";
|
|
1652
1647
|
el.style.position = "absolute";
|
|
1653
1648
|
el.style.top = `${top}px`;
|
|
1654
1649
|
el.style.left = `${left}px`;
|
|
1655
|
-
});
|
|
1650
|
+
}, [isShown]);
|
|
1656
1651
|
(0, import_react10.useEffect)(() => {
|
|
1657
1652
|
const handleClickOutside = (event) => {
|
|
1658
1653
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
@@ -1664,7 +1659,7 @@ var HoveringToolbar = (props) => {
|
|
|
1664
1659
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1665
1660
|
};
|
|
1666
1661
|
}, [ref, setIsDisplayed]);
|
|
1667
|
-
if (!
|
|
1662
|
+
if (!isShown) {
|
|
1668
1663
|
return null;
|
|
1669
1664
|
}
|
|
1670
1665
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1673,14 +1668,11 @@ var HoveringToolbar = (props) => {
|
|
|
1673
1668
|
ref,
|
|
1674
1669
|
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"),
|
|
1675
1670
|
"data-testid": "hovering-toolbar",
|
|
1676
|
-
children:
|
|
1671
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1677
1672
|
HoveringInsertionPromptBox,
|
|
1678
1673
|
{
|
|
1679
1674
|
editorState: editorState(editor, selection),
|
|
1680
1675
|
apiConfig: props.apiConfig,
|
|
1681
|
-
closeWindow: () => {
|
|
1682
|
-
setIsDisplayed(false);
|
|
1683
|
-
},
|
|
1684
1676
|
performInsertion: (insertedText) => {
|
|
1685
1677
|
import_slate7.Transforms.delete(editor, { at: selection });
|
|
1686
1678
|
import_slate7.Transforms.insertText(editor, insertedText, {
|
|
@@ -1906,6 +1898,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1906
1898
|
}, []);
|
|
1907
1899
|
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react13.useState)(valueOnInitialRender);
|
|
1908
1900
|
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react13.useState)(false);
|
|
1901
|
+
const [isUserInputActive, setIsUserInputActive] = (0, import_react13.useState)(false);
|
|
1909
1902
|
const initialValue = (0, import_react13.useMemo)(() => {
|
|
1910
1903
|
return [
|
|
1911
1904
|
{
|
|
@@ -1928,7 +1921,8 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1928
1921
|
// textarea is manually disabled:
|
|
1929
1922
|
autosuggestionsConfig.disabled || // hovering editor is displayed:
|
|
1930
1923
|
hoveringEditorIsDisplayed || // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:
|
|
1931
|
-
cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText
|
|
1924
|
+
cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText || // not user input and we want to disable non-trusted events (like text insertion from autocomplete plugins):
|
|
1925
|
+
!isUserInputActive && autosuggestionsConfig.temporarilyDisableNotTrustedEvents
|
|
1932
1926
|
);
|
|
1933
1927
|
const {
|
|
1934
1928
|
currentAutocompleteSuggestion,
|
|
@@ -2063,6 +2057,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
2063
2057
|
renderPlaceholder: renderPlaceholderMemoized,
|
|
2064
2058
|
onKeyDown: (event) => {
|
|
2065
2059
|
var _a2;
|
|
2060
|
+
setIsUserInputActive(true);
|
|
2066
2061
|
onKeyDownHandlerForHoveringEditor(event);
|
|
2067
2062
|
onKeyDownHandlerForAutocomplete(event);
|
|
2068
2063
|
(_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
|
|
@@ -2076,6 +2071,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
2076
2071
|
var _a2;
|
|
2077
2072
|
(_a2 = props.onBlur) == null ? void 0 : _a2.call(props, ev);
|
|
2078
2073
|
clearAutocompletionsFromEditor(editor);
|
|
2074
|
+
setIsUserInputActive(false);
|
|
2079
2075
|
}
|
|
2080
2076
|
}, propsToForward)
|
|
2081
2077
|
)
|
|
@@ -2098,13 +2094,13 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
2098
2094
|
}
|
|
2099
2095
|
|
|
2100
2096
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2101
|
-
var
|
|
2097
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
2102
2098
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
2103
2099
|
var import_react14 = require("react");
|
|
2104
2100
|
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
2105
2101
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2106
2102
|
const { getContextString, copilotApiConfig, runtimeClient } = (0, import_react_core5.useCopilotContext)();
|
|
2107
|
-
const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [
|
|
2103
|
+
const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
|
|
2108
2104
|
function runtimeClientResponseToStringStream(responsePromise) {
|
|
2109
2105
|
return __async(this, null, function* () {
|
|
2110
2106
|
const messagesStream = runtimeClient.asStream(responsePromise);
|