@copilotkit/react-textarea 0.36.0-mme-fix-packaging-issues.0 → 0.36.0-mme-push-to-talk.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +172 -172
- package/CHANGELOG.md +8 -2
- package/dist/{chunk-7R7KMN2G.mjs → chunk-COQISBP2.mjs} +2 -2
- package/dist/{chunk-GZPRBYKA.mjs → chunk-DMLXXOXD.mjs} +2 -2
- package/dist/{chunk-P4EI4H6Y.mjs → chunk-OGLVRSCO.mjs} +2 -2
- package/dist/{chunk-MMVI7IPP.mjs → chunk-PQIOU3E5.mjs} +2 -2
- package/dist/{chunk-O3QC2FT5.mjs → chunk-XU5Z5BWV.mjs} +2 -2
- package/dist/chunk-YNXNMCDX.mjs +51 -0
- package/dist/chunk-YNXNMCDX.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +66 -116
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +5 -5
- package/dist/components/copilot-textarea/copilot-textarea.js +73 -123
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +6 -6
- package/dist/components/hovering-toolbar/hovering-toolbar.js +45 -95
- 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 +34 -84
- 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 +2 -2
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +34 -84
- 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 +3 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +2 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +19 -67
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +3 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +34 -84
- 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 +3 -3
- package/dist/components/index.js +76 -126
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/index.js +76 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/package.json +7 -6
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +13 -62
- package/typedoc.json +4 -0
- package/dist/chunk-JC6NGPO4.mjs +0 -100
- package/dist/chunk-JC6NGPO4.mjs.map +0 -1
- /package/dist/{chunk-7R7KMN2G.mjs.map → chunk-COQISBP2.mjs.map} +0 -0
- /package/dist/{chunk-GZPRBYKA.mjs.map → chunk-DMLXXOXD.mjs.map} +0 -0
- /package/dist/{chunk-P4EI4H6Y.mjs.map → chunk-OGLVRSCO.mjs.map} +0 -0
- /package/dist/{chunk-MMVI7IPP.mjs.map → chunk-PQIOU3E5.mjs.map} +0 -0
- /package/dist/{chunk-O3QC2FT5.mjs.map → chunk-XU5Z5BWV.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../chunk-MMVDU6DF.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotTextarea
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-PQIOU3E5.mjs";
|
|
5
5
|
import "../chunk-SJ2TM5GA.mjs";
|
|
6
6
|
import "../chunk-QCPS6IYI.mjs";
|
|
7
7
|
import "../chunk-RUV6NBIF.mjs";
|
|
@@ -11,7 +11,7 @@ import "../chunk-RKQ6RTZM.mjs";
|
|
|
11
11
|
import "../chunk-KDVMG3XF.mjs";
|
|
12
12
|
import {
|
|
13
13
|
BaseCopilotTextarea
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-XU5Z5BWV.mjs";
|
|
15
15
|
import "../chunk-DRV2FOHZ.mjs";
|
|
16
16
|
import "../chunk-4NHVQZ67.mjs";
|
|
17
17
|
import "../chunk-FMQG2ZM3.mjs";
|
|
@@ -22,11 +22,11 @@ import "../chunk-QKS2IOUH.mjs";
|
|
|
22
22
|
import "../chunk-JJLQVT7S.mjs";
|
|
23
23
|
import "../chunk-LQ2OWQU7.mjs";
|
|
24
24
|
import "../chunk-7LSRNPNI.mjs";
|
|
25
|
-
import "../chunk-
|
|
25
|
+
import "../chunk-DMLXXOXD.mjs";
|
|
26
26
|
import "../chunk-L7VVZH4Q.mjs";
|
|
27
|
-
import "../chunk-
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
27
|
+
import "../chunk-COQISBP2.mjs";
|
|
28
|
+
import "../chunk-OGLVRSCO.mjs";
|
|
29
|
+
import "../chunk-YNXNMCDX.mjs";
|
|
30
30
|
import "../chunk-3PQ7GSFE.mjs";
|
|
31
31
|
import "../chunk-WFTAAA7R.mjs";
|
|
32
32
|
import "../chunk-YFK5BFEI.mjs";
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ __export(src_exports, {
|
|
|
88
88
|
module.exports = __toCommonJS(src_exports);
|
|
89
89
|
|
|
90
90
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
91
|
-
var
|
|
91
|
+
var import_react12 = __toESM(require("react"));
|
|
92
92
|
var import_slate10 = require("slate");
|
|
93
93
|
var import_slate_react5 = require("slate-react");
|
|
94
94
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
@@ -665,7 +665,7 @@ var defaultBaseAutosuggestionsConfig = {
|
|
|
665
665
|
};
|
|
666
666
|
|
|
667
667
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
668
|
-
var
|
|
668
|
+
var import_react9 = require("react");
|
|
669
669
|
var import_slate7 = require("slate");
|
|
670
670
|
var import_slate_react3 = require("slate-react");
|
|
671
671
|
|
|
@@ -901,7 +901,7 @@ var Label = React4.forwardRef((_a, ref) => {
|
|
|
901
901
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
902
902
|
|
|
903
903
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
904
|
-
var
|
|
904
|
+
var import_react7 = require("react");
|
|
905
905
|
|
|
906
906
|
// src/lib/stream-promise-flatten.ts
|
|
907
907
|
function streamPromiseFlatten(promise) {
|
|
@@ -931,7 +931,8 @@ function streamPromiseFlatten(promise) {
|
|
|
931
931
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
932
932
|
|
|
933
933
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
934
|
-
var
|
|
934
|
+
var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
|
|
935
|
+
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
935
936
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
936
937
|
var IncludedFilesPreview = ({
|
|
937
938
|
includedFiles,
|
|
@@ -953,88 +954,37 @@ var IncludedFilesPreview = ({
|
|
|
953
954
|
}) })
|
|
954
955
|
] });
|
|
955
956
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
}) {
|
|
960
|
-
const CLOSE_BUTTON_COLOR = "rgba(0, 0, 0, 0.26)";
|
|
961
|
-
const [color, setColor] = import_react6.default.useState(CLOSE_BUTTON_COLOR);
|
|
962
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
963
|
-
"button",
|
|
957
|
+
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
959
|
+
import_Chip.default,
|
|
964
960
|
{
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
boxSizing: "border-box",
|
|
976
|
-
border: 0,
|
|
977
|
-
verticalAlign: "middle",
|
|
978
|
-
outline: 0,
|
|
979
|
-
cursor: "default"
|
|
980
|
-
},
|
|
981
|
-
children: [
|
|
982
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
983
|
-
"img",
|
|
984
|
-
{
|
|
985
|
-
style: {
|
|
986
|
-
marginLeft: "5px",
|
|
987
|
-
width: "24px",
|
|
988
|
-
height: "24px",
|
|
989
|
-
backgroundColor: "transparent",
|
|
990
|
-
borderRadius: "50%"
|
|
991
|
-
},
|
|
992
|
-
src: filePointer.iconImageUri,
|
|
993
|
-
alt: filePointer.sourceApplication
|
|
994
|
-
}
|
|
995
|
-
),
|
|
996
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { marginLeft: "5px" }, children: filePointer.name }),
|
|
997
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
998
|
-
"svg",
|
|
999
|
-
{
|
|
1000
|
-
style: {
|
|
1001
|
-
color,
|
|
1002
|
-
fontSize: "22px",
|
|
1003
|
-
cursor: "pointer",
|
|
1004
|
-
margin: "0 5px 0 5px",
|
|
1005
|
-
userSelect: "none",
|
|
1006
|
-
width: "1em",
|
|
1007
|
-
height: "1em",
|
|
1008
|
-
display: "inline-block",
|
|
1009
|
-
fill: "currentColor",
|
|
1010
|
-
flexShrink: 0
|
|
1011
|
-
},
|
|
1012
|
-
viewBox: "0 0 24 24",
|
|
1013
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
1014
|
-
onClick: onDelete,
|
|
1015
|
-
onMouseOver: () => setColor("rgba(0, 0, 0, 0.54)"),
|
|
1016
|
-
onMouseOut: () => setColor(CLOSE_BUTTON_COLOR),
|
|
1017
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" })
|
|
1018
|
-
}
|
|
1019
|
-
)
|
|
1020
|
-
]
|
|
961
|
+
label: filePointer.name,
|
|
962
|
+
onDelete,
|
|
963
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
964
|
+
import_Avatar.default,
|
|
965
|
+
{
|
|
966
|
+
src: filePointer.iconImageUri,
|
|
967
|
+
alt: filePointer.sourceApplication,
|
|
968
|
+
sx: { backgroundColor: "transparent" }
|
|
969
|
+
}
|
|
970
|
+
)
|
|
1021
971
|
}
|
|
1022
|
-
)
|
|
1023
|
-
}
|
|
972
|
+
);
|
|
973
|
+
};
|
|
1024
974
|
|
|
1025
975
|
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1026
|
-
var
|
|
976
|
+
var import_react6 = require("react");
|
|
1027
977
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1028
|
-
var HoveringEditorContext = (0,
|
|
978
|
+
var HoveringEditorContext = (0, import_react6.createContext)({
|
|
1029
979
|
isDisplayed: false,
|
|
1030
980
|
setIsDisplayed: () => {
|
|
1031
981
|
}
|
|
1032
982
|
});
|
|
1033
983
|
var HoveringEditorProvider = ({ children }) => {
|
|
1034
|
-
const [isDisplayed, setIsDisplayed] = (0,
|
|
984
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react6.useState)(false);
|
|
1035
985
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1036
986
|
};
|
|
1037
|
-
var useHoveringEditorContext = () => (0,
|
|
987
|
+
var useHoveringEditorContext = () => (0, import_react6.useContext)(HoveringEditorContext);
|
|
1038
988
|
|
|
1039
989
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1040
990
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -1044,27 +994,27 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1044
994
|
insertionOrEditingFunction,
|
|
1045
995
|
contextCategories
|
|
1046
996
|
}) => {
|
|
1047
|
-
const { getDocumentsContext } = (0,
|
|
1048
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
1049
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
1050
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
1051
|
-
const [generatingSuggestion, setGeneratingSuggestion] = (0,
|
|
997
|
+
const { getDocumentsContext } = (0, import_react7.useContext)(import_react_core2.CopilotContext);
|
|
998
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react7.useState)("");
|
|
999
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react7.useState)(false);
|
|
1000
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react7.useState)("");
|
|
1001
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react7.useState)(
|
|
1052
1002
|
null
|
|
1053
1003
|
);
|
|
1054
|
-
const adjustmentTextAreaRef = (0,
|
|
1055
|
-
const suggestionTextAreaRef = (0,
|
|
1056
|
-
const [filePointers, setFilePointers] = (0,
|
|
1057
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1058
|
-
(0,
|
|
1004
|
+
const adjustmentTextAreaRef = (0, import_react7.useRef)(null);
|
|
1005
|
+
const suggestionTextAreaRef = (0, import_react7.useRef)(null);
|
|
1006
|
+
const [filePointers, setFilePointers] = (0, import_react7.useState)([]);
|
|
1007
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react7.useState)([]);
|
|
1008
|
+
(0, import_react7.useEffect)(() => {
|
|
1059
1009
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1060
1010
|
}, [contextCategories, getDocumentsContext]);
|
|
1061
1011
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1062
1012
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1063
|
-
(0,
|
|
1013
|
+
(0, import_react7.useEffect)(() => {
|
|
1064
1014
|
var _a;
|
|
1065
1015
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1066
1016
|
}, []);
|
|
1067
|
-
(0,
|
|
1017
|
+
(0, import_react7.useEffect)(() => {
|
|
1068
1018
|
if (!generatingSuggestion) {
|
|
1069
1019
|
return;
|
|
1070
1020
|
}
|
|
@@ -1102,7 +1052,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1102
1052
|
releaseLockIfNotClosed();
|
|
1103
1053
|
};
|
|
1104
1054
|
}, [generatingSuggestion]);
|
|
1105
|
-
const beginGeneratingAdjustment = (0,
|
|
1055
|
+
const beginGeneratingAdjustment = (0, import_react7.useCallback)(() => __async(void 0, null, function* () {
|
|
1106
1056
|
if (!adjustmentPrompt.trim()) {
|
|
1107
1057
|
return;
|
|
1108
1058
|
}
|
|
@@ -1255,10 +1205,10 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1255
1205
|
|
|
1256
1206
|
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1257
1207
|
var import_css = require("@emotion/css");
|
|
1258
|
-
var
|
|
1208
|
+
var import_react8 = __toESM(require("react"));
|
|
1259
1209
|
var import_react_dom = __toESM(require("react-dom"));
|
|
1260
1210
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1261
|
-
var Button2 =
|
|
1211
|
+
var Button2 = import_react8.default.forwardRef(
|
|
1262
1212
|
(_a, ref) => {
|
|
1263
1213
|
var _b = _a, {
|
|
1264
1214
|
className,
|
|
@@ -1284,7 +1234,7 @@ var Button2 = import_react9.default.forwardRef(
|
|
|
1284
1234
|
);
|
|
1285
1235
|
}
|
|
1286
1236
|
);
|
|
1287
|
-
var Icon =
|
|
1237
|
+
var Icon = import_react8.default.forwardRef(
|
|
1288
1238
|
(_a, ref) => {
|
|
1289
1239
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1290
1240
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1303,7 +1253,7 @@ var Icon = import_react9.default.forwardRef(
|
|
|
1303
1253
|
);
|
|
1304
1254
|
}
|
|
1305
1255
|
);
|
|
1306
|
-
var Menu =
|
|
1256
|
+
var Menu = import_react8.default.forwardRef(
|
|
1307
1257
|
(_a, ref) => {
|
|
1308
1258
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1309
1259
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1330,7 +1280,7 @@ var Menu = import_react9.default.forwardRef(
|
|
|
1330
1280
|
var Portal = ({ children }) => {
|
|
1331
1281
|
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1332
1282
|
};
|
|
1333
|
-
var Toolbar =
|
|
1283
|
+
var Toolbar = import_react8.default.forwardRef(
|
|
1334
1284
|
(_a, ref) => {
|
|
1335
1285
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1336
1286
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1355,15 +1305,15 @@ var Toolbar = import_react9.default.forwardRef(
|
|
|
1355
1305
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1356
1306
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1357
1307
|
var HoveringToolbar = (props) => {
|
|
1358
|
-
const ref = (0,
|
|
1308
|
+
const ref = (0, import_react9.useRef)(null);
|
|
1359
1309
|
const editor = (0, import_slate_react3.useSlate)();
|
|
1360
1310
|
const selection = (0, import_slate_react3.useSlateSelection)();
|
|
1361
1311
|
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
1362
|
-
const [isClient, setIsClient] = (0,
|
|
1363
|
-
(0,
|
|
1312
|
+
const [isClient, setIsClient] = (0, import_react9.useState)(false);
|
|
1313
|
+
(0, import_react9.useEffect)(() => {
|
|
1364
1314
|
setIsClient(true);
|
|
1365
1315
|
}, []);
|
|
1366
|
-
(0,
|
|
1316
|
+
(0, import_react9.useEffect)(() => {
|
|
1367
1317
|
const el = ref.current;
|
|
1368
1318
|
const { selection: selection2 } = editor;
|
|
1369
1319
|
if (!el) {
|
|
@@ -1401,7 +1351,7 @@ var HoveringToolbar = (props) => {
|
|
|
1401
1351
|
el.style.top = `${top}px`;
|
|
1402
1352
|
el.style.left = `${left}px`;
|
|
1403
1353
|
});
|
|
1404
|
-
(0,
|
|
1354
|
+
(0, import_react9.useEffect)(() => {
|
|
1405
1355
|
const handleClickOutside = (event) => {
|
|
1406
1356
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1407
1357
|
setIsDisplayed(false);
|
|
@@ -1499,10 +1449,10 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
|
1499
1449
|
}
|
|
1500
1450
|
|
|
1501
1451
|
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
1502
|
-
var
|
|
1452
|
+
var import_react10 = require("react");
|
|
1503
1453
|
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
1504
1454
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
1505
|
-
(0,
|
|
1455
|
+
(0, import_react10.useEffect)(() => {
|
|
1506
1456
|
if (disableBranding) {
|
|
1507
1457
|
return;
|
|
1508
1458
|
}
|
|
@@ -1554,7 +1504,7 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
|
1554
1504
|
}
|
|
1555
1505
|
|
|
1556
1506
|
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1557
|
-
var
|
|
1507
|
+
var import_react11 = require("react");
|
|
1558
1508
|
var import_slate_react4 = require("slate-react");
|
|
1559
1509
|
var import_slate9 = require("slate");
|
|
1560
1510
|
|
|
@@ -1607,7 +1557,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
|
1607
1557
|
text: editorToText(state)
|
|
1608
1558
|
}));
|
|
1609
1559
|
const previousState = usePrevious(cursorState);
|
|
1610
|
-
(0,
|
|
1560
|
+
(0, import_react11.useEffect)(() => {
|
|
1611
1561
|
if (!previousState) {
|
|
1612
1562
|
return;
|
|
1613
1563
|
}
|
|
@@ -1630,8 +1580,8 @@ var isSelectionEqual = (a, b) => {
|
|
|
1630
1580
|
return import_slate9.Range.equals(a, b);
|
|
1631
1581
|
};
|
|
1632
1582
|
function usePrevious(value) {
|
|
1633
|
-
const ref = (0,
|
|
1634
|
-
(0,
|
|
1583
|
+
const ref = (0, import_react11.useRef)();
|
|
1584
|
+
(0, import_react11.useEffect)(() => {
|
|
1635
1585
|
ref.current = value;
|
|
1636
1586
|
});
|
|
1637
1587
|
return ref.current;
|
|
@@ -1639,21 +1589,21 @@ function usePrevious(value) {
|
|
|
1639
1589
|
|
|
1640
1590
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
1641
1591
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1642
|
-
var BaseCopilotTextarea =
|
|
1592
|
+
var BaseCopilotTextarea = import_react12.default.forwardRef(
|
|
1643
1593
|
(props, ref) => {
|
|
1644
1594
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
1645
1595
|
}
|
|
1646
1596
|
);
|
|
1647
|
-
var BaseCopilotTextareaWithHoveringContext =
|
|
1597
|
+
var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
1648
1598
|
(props, ref) => {
|
|
1649
1599
|
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
1650
|
-
const valueOnInitialRender = (0,
|
|
1600
|
+
const valueOnInitialRender = (0, import_react12.useMemo)(() => {
|
|
1651
1601
|
var _a2;
|
|
1652
1602
|
return (_a2 = props.value) != null ? _a2 : "";
|
|
1653
1603
|
}, []);
|
|
1654
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0,
|
|
1655
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0,
|
|
1656
|
-
const initialValue = (0,
|
|
1604
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
|
|
1605
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
|
|
1606
|
+
const initialValue = (0, import_react12.useMemo)(() => {
|
|
1657
1607
|
return [
|
|
1658
1608
|
{
|
|
1659
1609
|
type: "paragraph",
|
|
@@ -1663,7 +1613,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1663
1613
|
}, [valueOnInitialRender]);
|
|
1664
1614
|
const editor = useCopilotTextareaEditor();
|
|
1665
1615
|
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
1666
|
-
const insertText = (0,
|
|
1616
|
+
const insertText = (0, import_react12.useCallback)(
|
|
1667
1617
|
(autosuggestion) => {
|
|
1668
1618
|
import_slate10.Editor.insertText(editor, autosuggestion.text, {
|
|
1669
1619
|
at: autosuggestion.point
|
|
@@ -1689,7 +1639,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1689
1639
|
autosuggestionsConfig.disableWhenEmpty,
|
|
1690
1640
|
shouldDisableAutosuggestions
|
|
1691
1641
|
);
|
|
1692
|
-
const onKeyDownHandlerForHoveringEditor = (0,
|
|
1642
|
+
const onKeyDownHandlerForHoveringEditor = (0, import_react12.useCallback)(
|
|
1693
1643
|
(event) => {
|
|
1694
1644
|
var _a2;
|
|
1695
1645
|
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, (_a2 = props.shortcut) != null ? _a2 : "k")) {
|
|
@@ -1703,7 +1653,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1703
1653
|
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
1704
1654
|
]
|
|
1705
1655
|
);
|
|
1706
|
-
(0,
|
|
1656
|
+
(0, import_react12.useEffect)(() => {
|
|
1707
1657
|
clearAutocompletionsFromEditor(editor);
|
|
1708
1658
|
if (currentAutocompleteSuggestion) {
|
|
1709
1659
|
addAutocompletionsToEditor(
|
|
@@ -1713,23 +1663,23 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1713
1663
|
);
|
|
1714
1664
|
}
|
|
1715
1665
|
}, [currentAutocompleteSuggestion]);
|
|
1716
|
-
const suggestionStyleAugmented = (0,
|
|
1666
|
+
const suggestionStyleAugmented = (0, import_react12.useMemo)(() => {
|
|
1717
1667
|
return __spreadValues({
|
|
1718
1668
|
fontStyle: "italic",
|
|
1719
1669
|
color: "gray"
|
|
1720
1670
|
}, props.suggestionsStyle);
|
|
1721
1671
|
}, [props.suggestionsStyle]);
|
|
1722
|
-
const renderElementMemoized = (0,
|
|
1672
|
+
const renderElementMemoized = (0, import_react12.useMemo)(() => {
|
|
1723
1673
|
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
1724
1674
|
}, [suggestionStyleAugmented]);
|
|
1725
|
-
const renderPlaceholderMemoized = (0,
|
|
1675
|
+
const renderPlaceholderMemoized = (0, import_react12.useMemo)(() => {
|
|
1726
1676
|
const placeholderStyleSlatejsOverrides = {
|
|
1727
1677
|
top: void 0
|
|
1728
1678
|
};
|
|
1729
1679
|
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
1730
1680
|
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
1731
1681
|
}, [props.placeholderStyle]);
|
|
1732
|
-
(0,
|
|
1682
|
+
(0, import_react12.useEffect)(() => {
|
|
1733
1683
|
var _a2, _b;
|
|
1734
1684
|
if (props.value === lastKnownFullEditorText) {
|
|
1735
1685
|
return;
|
|
@@ -1839,12 +1789,12 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
1839
1789
|
}
|
|
1840
1790
|
|
|
1841
1791
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
1842
|
-
var
|
|
1792
|
+
var import_react15 = __toESM(require("react"));
|
|
1843
1793
|
|
|
1844
1794
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
1845
1795
|
var import_shared = require("@copilotkit/shared");
|
|
1846
1796
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1847
|
-
var
|
|
1797
|
+
var import_react13 = require("react");
|
|
1848
1798
|
|
|
1849
1799
|
// src/lib/retry.tsx
|
|
1850
1800
|
function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
@@ -1864,10 +1814,10 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
|
1864
1814
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
1865
1815
|
var import_react_core4 = require("@copilotkit/react-core");
|
|
1866
1816
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
1867
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
1817
|
+
const { getContextString, copilotApiConfig } = (0, import_react13.useContext)(import_react_core3.CopilotContext);
|
|
1868
1818
|
const publicApiKey = copilotApiConfig.publicApiKey;
|
|
1869
1819
|
const headers = __spreadValues({}, publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
1870
|
-
return (0,
|
|
1820
|
+
return (0, import_react13.useCallback)(
|
|
1871
1821
|
(editorState2, abortSignal) => __async(this, null, function* () {
|
|
1872
1822
|
const res = yield retry(() => __async(this, null, function* () {
|
|
1873
1823
|
const messages = [
|
|
@@ -2147,11 +2097,11 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
|
|
|
2147
2097
|
|
|
2148
2098
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2149
2099
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
2150
|
-
var
|
|
2100
|
+
var import_react14 = require("react");
|
|
2151
2101
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2152
2102
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2153
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
2154
|
-
const insertionFunction = (0,
|
|
2103
|
+
const { getContextString, copilotApiConfig } = (0, import_react14.useContext)(import_react_core6.CopilotContext);
|
|
2104
|
+
const insertionFunction = (0, import_react14.useCallback)(
|
|
2155
2105
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2156
2106
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2157
2107
|
const messages = [
|
|
@@ -2191,7 +2141,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2191
2141
|
}),
|
|
2192
2142
|
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2193
2143
|
);
|
|
2194
|
-
const editingFunction = (0,
|
|
2144
|
+
const editingFunction = (0, import_react14.useCallback)(
|
|
2195
2145
|
(editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2196
2146
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2197
2147
|
const messages = [
|
|
@@ -2236,7 +2186,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2236
2186
|
}),
|
|
2237
2187
|
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2238
2188
|
);
|
|
2239
|
-
const insertionOrEditingFunction = (0,
|
|
2189
|
+
const insertionOrEditingFunction = (0, import_react14.useCallback)(
|
|
2240
2190
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2241
2191
|
if (editorState2.selectedText === "") {
|
|
2242
2192
|
return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
|
|
@@ -2252,7 +2202,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2252
2202
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
2253
2203
|
var import_lodash = __toESM(require("lodash.merge"));
|
|
2254
2204
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2255
|
-
var CopilotTextarea =
|
|
2205
|
+
var CopilotTextarea = import_react15.default.forwardRef(
|
|
2256
2206
|
(props, ref) => {
|
|
2257
2207
|
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
2258
2208
|
const autosuggestionsConfig = (0, import_lodash.default)(
|