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