@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
package/dist/components/index.js
CHANGED
|
@@ -85,7 +85,7 @@ __export(components_exports, {
|
|
|
85
85
|
module.exports = __toCommonJS(components_exports);
|
|
86
86
|
|
|
87
87
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
88
|
-
var
|
|
88
|
+
var import_react12 = __toESM(require("react"));
|
|
89
89
|
var import_slate10 = require("slate");
|
|
90
90
|
var import_slate_react5 = require("slate-react");
|
|
91
91
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
@@ -662,7 +662,7 @@ var defaultBaseAutosuggestionsConfig = {
|
|
|
662
662
|
};
|
|
663
663
|
|
|
664
664
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
665
|
-
var
|
|
665
|
+
var import_react9 = require("react");
|
|
666
666
|
var import_slate7 = require("slate");
|
|
667
667
|
var import_slate_react3 = require("slate-react");
|
|
668
668
|
|
|
@@ -898,7 +898,7 @@ var Label = React4.forwardRef((_a, ref) => {
|
|
|
898
898
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
899
899
|
|
|
900
900
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
901
|
-
var
|
|
901
|
+
var import_react7 = require("react");
|
|
902
902
|
|
|
903
903
|
// src/lib/stream-promise-flatten.ts
|
|
904
904
|
function streamPromiseFlatten(promise) {
|
|
@@ -928,7 +928,8 @@ function streamPromiseFlatten(promise) {
|
|
|
928
928
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
929
929
|
|
|
930
930
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
931
|
-
var
|
|
931
|
+
var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
|
|
932
|
+
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
932
933
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
933
934
|
var IncludedFilesPreview = ({
|
|
934
935
|
includedFiles,
|
|
@@ -950,88 +951,37 @@ var IncludedFilesPreview = ({
|
|
|
950
951
|
}) })
|
|
951
952
|
] });
|
|
952
953
|
};
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}) {
|
|
957
|
-
const CLOSE_BUTTON_COLOR = "rgba(0, 0, 0, 0.26)";
|
|
958
|
-
const [color, setColor] = import_react6.default.useState(CLOSE_BUTTON_COLOR);
|
|
959
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
960
|
-
"button",
|
|
954
|
+
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
956
|
+
import_Chip.default,
|
|
961
957
|
{
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
boxSizing: "border-box",
|
|
973
|
-
border: 0,
|
|
974
|
-
verticalAlign: "middle",
|
|
975
|
-
outline: 0,
|
|
976
|
-
cursor: "default"
|
|
977
|
-
},
|
|
978
|
-
children: [
|
|
979
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
980
|
-
"img",
|
|
981
|
-
{
|
|
982
|
-
style: {
|
|
983
|
-
marginLeft: "5px",
|
|
984
|
-
width: "24px",
|
|
985
|
-
height: "24px",
|
|
986
|
-
backgroundColor: "transparent",
|
|
987
|
-
borderRadius: "50%"
|
|
988
|
-
},
|
|
989
|
-
src: filePointer.iconImageUri,
|
|
990
|
-
alt: filePointer.sourceApplication
|
|
991
|
-
}
|
|
992
|
-
),
|
|
993
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { marginLeft: "5px" }, children: filePointer.name }),
|
|
994
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
995
|
-
"svg",
|
|
996
|
-
{
|
|
997
|
-
style: {
|
|
998
|
-
color,
|
|
999
|
-
fontSize: "22px",
|
|
1000
|
-
cursor: "pointer",
|
|
1001
|
-
margin: "0 5px 0 5px",
|
|
1002
|
-
userSelect: "none",
|
|
1003
|
-
width: "1em",
|
|
1004
|
-
height: "1em",
|
|
1005
|
-
display: "inline-block",
|
|
1006
|
-
fill: "currentColor",
|
|
1007
|
-
flexShrink: 0
|
|
1008
|
-
},
|
|
1009
|
-
viewBox: "0 0 24 24",
|
|
1010
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
1011
|
-
onClick: onDelete,
|
|
1012
|
-
onMouseOver: () => setColor("rgba(0, 0, 0, 0.54)"),
|
|
1013
|
-
onMouseOut: () => setColor(CLOSE_BUTTON_COLOR),
|
|
1014
|
-
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" })
|
|
1015
|
-
}
|
|
1016
|
-
)
|
|
1017
|
-
]
|
|
958
|
+
label: filePointer.name,
|
|
959
|
+
onDelete,
|
|
960
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
961
|
+
import_Avatar.default,
|
|
962
|
+
{
|
|
963
|
+
src: filePointer.iconImageUri,
|
|
964
|
+
alt: filePointer.sourceApplication,
|
|
965
|
+
sx: { backgroundColor: "transparent" }
|
|
966
|
+
}
|
|
967
|
+
)
|
|
1018
968
|
}
|
|
1019
|
-
)
|
|
1020
|
-
}
|
|
969
|
+
);
|
|
970
|
+
};
|
|
1021
971
|
|
|
1022
972
|
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1023
|
-
var
|
|
973
|
+
var import_react6 = require("react");
|
|
1024
974
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1025
|
-
var HoveringEditorContext = (0,
|
|
975
|
+
var HoveringEditorContext = (0, import_react6.createContext)({
|
|
1026
976
|
isDisplayed: false,
|
|
1027
977
|
setIsDisplayed: () => {
|
|
1028
978
|
}
|
|
1029
979
|
});
|
|
1030
980
|
var HoveringEditorProvider = ({ children }) => {
|
|
1031
|
-
const [isDisplayed, setIsDisplayed] = (0,
|
|
981
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react6.useState)(false);
|
|
1032
982
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1033
983
|
};
|
|
1034
|
-
var useHoveringEditorContext = () => (0,
|
|
984
|
+
var useHoveringEditorContext = () => (0, import_react6.useContext)(HoveringEditorContext);
|
|
1035
985
|
|
|
1036
986
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1037
987
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -1041,27 +991,27 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1041
991
|
insertionOrEditingFunction,
|
|
1042
992
|
contextCategories
|
|
1043
993
|
}) => {
|
|
1044
|
-
const { getDocumentsContext } = (0,
|
|
1045
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
1046
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
1047
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
1048
|
-
const [generatingSuggestion, setGeneratingSuggestion] = (0,
|
|
994
|
+
const { getDocumentsContext } = (0, import_react7.useContext)(import_react_core2.CopilotContext);
|
|
995
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react7.useState)("");
|
|
996
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react7.useState)(false);
|
|
997
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react7.useState)("");
|
|
998
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react7.useState)(
|
|
1049
999
|
null
|
|
1050
1000
|
);
|
|
1051
|
-
const adjustmentTextAreaRef = (0,
|
|
1052
|
-
const suggestionTextAreaRef = (0,
|
|
1053
|
-
const [filePointers, setFilePointers] = (0,
|
|
1054
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1055
|
-
(0,
|
|
1001
|
+
const adjustmentTextAreaRef = (0, import_react7.useRef)(null);
|
|
1002
|
+
const suggestionTextAreaRef = (0, import_react7.useRef)(null);
|
|
1003
|
+
const [filePointers, setFilePointers] = (0, import_react7.useState)([]);
|
|
1004
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react7.useState)([]);
|
|
1005
|
+
(0, import_react7.useEffect)(() => {
|
|
1056
1006
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1057
1007
|
}, [contextCategories, getDocumentsContext]);
|
|
1058
1008
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1059
1009
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1060
|
-
(0,
|
|
1010
|
+
(0, import_react7.useEffect)(() => {
|
|
1061
1011
|
var _a;
|
|
1062
1012
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1063
1013
|
}, []);
|
|
1064
|
-
(0,
|
|
1014
|
+
(0, import_react7.useEffect)(() => {
|
|
1065
1015
|
if (!generatingSuggestion) {
|
|
1066
1016
|
return;
|
|
1067
1017
|
}
|
|
@@ -1099,7 +1049,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1099
1049
|
releaseLockIfNotClosed();
|
|
1100
1050
|
};
|
|
1101
1051
|
}, [generatingSuggestion]);
|
|
1102
|
-
const beginGeneratingAdjustment = (0,
|
|
1052
|
+
const beginGeneratingAdjustment = (0, import_react7.useCallback)(() => __async(void 0, null, function* () {
|
|
1103
1053
|
if (!adjustmentPrompt.trim()) {
|
|
1104
1054
|
return;
|
|
1105
1055
|
}
|
|
@@ -1252,10 +1202,10 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1252
1202
|
|
|
1253
1203
|
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1254
1204
|
var import_css = require("@emotion/css");
|
|
1255
|
-
var
|
|
1205
|
+
var import_react8 = __toESM(require("react"));
|
|
1256
1206
|
var import_react_dom = __toESM(require("react-dom"));
|
|
1257
1207
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1258
|
-
var Button2 =
|
|
1208
|
+
var Button2 = import_react8.default.forwardRef(
|
|
1259
1209
|
(_a, ref) => {
|
|
1260
1210
|
var _b = _a, {
|
|
1261
1211
|
className,
|
|
@@ -1281,7 +1231,7 @@ var Button2 = import_react9.default.forwardRef(
|
|
|
1281
1231
|
);
|
|
1282
1232
|
}
|
|
1283
1233
|
);
|
|
1284
|
-
var Icon =
|
|
1234
|
+
var Icon = import_react8.default.forwardRef(
|
|
1285
1235
|
(_a, ref) => {
|
|
1286
1236
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1287
1237
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1300,7 +1250,7 @@ var Icon = import_react9.default.forwardRef(
|
|
|
1300
1250
|
);
|
|
1301
1251
|
}
|
|
1302
1252
|
);
|
|
1303
|
-
var Menu =
|
|
1253
|
+
var Menu = import_react8.default.forwardRef(
|
|
1304
1254
|
(_a, ref) => {
|
|
1305
1255
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1306
1256
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1327,7 +1277,7 @@ var Menu = import_react9.default.forwardRef(
|
|
|
1327
1277
|
var Portal = ({ children }) => {
|
|
1328
1278
|
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1329
1279
|
};
|
|
1330
|
-
var Toolbar =
|
|
1280
|
+
var Toolbar = import_react8.default.forwardRef(
|
|
1331
1281
|
(_a, ref) => {
|
|
1332
1282
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1333
1283
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1352,15 +1302,15 @@ var Toolbar = import_react9.default.forwardRef(
|
|
|
1352
1302
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1353
1303
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1354
1304
|
var HoveringToolbar = (props) => {
|
|
1355
|
-
const ref = (0,
|
|
1305
|
+
const ref = (0, import_react9.useRef)(null);
|
|
1356
1306
|
const editor = (0, import_slate_react3.useSlate)();
|
|
1357
1307
|
const selection = (0, import_slate_react3.useSlateSelection)();
|
|
1358
1308
|
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
1359
|
-
const [isClient, setIsClient] = (0,
|
|
1360
|
-
(0,
|
|
1309
|
+
const [isClient, setIsClient] = (0, import_react9.useState)(false);
|
|
1310
|
+
(0, import_react9.useEffect)(() => {
|
|
1361
1311
|
setIsClient(true);
|
|
1362
1312
|
}, []);
|
|
1363
|
-
(0,
|
|
1313
|
+
(0, import_react9.useEffect)(() => {
|
|
1364
1314
|
const el = ref.current;
|
|
1365
1315
|
const { selection: selection2 } = editor;
|
|
1366
1316
|
if (!el) {
|
|
@@ -1398,7 +1348,7 @@ var HoveringToolbar = (props) => {
|
|
|
1398
1348
|
el.style.top = `${top}px`;
|
|
1399
1349
|
el.style.left = `${left}px`;
|
|
1400
1350
|
});
|
|
1401
|
-
(0,
|
|
1351
|
+
(0, import_react9.useEffect)(() => {
|
|
1402
1352
|
const handleClickOutside = (event) => {
|
|
1403
1353
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1404
1354
|
setIsDisplayed(false);
|
|
@@ -1496,10 +1446,10 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
|
1496
1446
|
}
|
|
1497
1447
|
|
|
1498
1448
|
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
1499
|
-
var
|
|
1449
|
+
var import_react10 = require("react");
|
|
1500
1450
|
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
1501
1451
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
1502
|
-
(0,
|
|
1452
|
+
(0, import_react10.useEffect)(() => {
|
|
1503
1453
|
if (disableBranding) {
|
|
1504
1454
|
return;
|
|
1505
1455
|
}
|
|
@@ -1551,7 +1501,7 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
|
1551
1501
|
}
|
|
1552
1502
|
|
|
1553
1503
|
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1554
|
-
var
|
|
1504
|
+
var import_react11 = require("react");
|
|
1555
1505
|
var import_slate_react4 = require("slate-react");
|
|
1556
1506
|
var import_slate9 = require("slate");
|
|
1557
1507
|
|
|
@@ -1604,7 +1554,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
|
1604
1554
|
text: editorToText(state)
|
|
1605
1555
|
}));
|
|
1606
1556
|
const previousState = usePrevious(cursorState);
|
|
1607
|
-
(0,
|
|
1557
|
+
(0, import_react11.useEffect)(() => {
|
|
1608
1558
|
if (!previousState) {
|
|
1609
1559
|
return;
|
|
1610
1560
|
}
|
|
@@ -1627,8 +1577,8 @@ var isSelectionEqual = (a, b) => {
|
|
|
1627
1577
|
return import_slate9.Range.equals(a, b);
|
|
1628
1578
|
};
|
|
1629
1579
|
function usePrevious(value) {
|
|
1630
|
-
const ref = (0,
|
|
1631
|
-
(0,
|
|
1580
|
+
const ref = (0, import_react11.useRef)();
|
|
1581
|
+
(0, import_react11.useEffect)(() => {
|
|
1632
1582
|
ref.current = value;
|
|
1633
1583
|
});
|
|
1634
1584
|
return ref.current;
|
|
@@ -1636,21 +1586,21 @@ function usePrevious(value) {
|
|
|
1636
1586
|
|
|
1637
1587
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
1638
1588
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1639
|
-
var BaseCopilotTextarea =
|
|
1589
|
+
var BaseCopilotTextarea = import_react12.default.forwardRef(
|
|
1640
1590
|
(props, ref) => {
|
|
1641
1591
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
1642
1592
|
}
|
|
1643
1593
|
);
|
|
1644
|
-
var BaseCopilotTextareaWithHoveringContext =
|
|
1594
|
+
var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
1645
1595
|
(props, ref) => {
|
|
1646
1596
|
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
1647
|
-
const valueOnInitialRender = (0,
|
|
1597
|
+
const valueOnInitialRender = (0, import_react12.useMemo)(() => {
|
|
1648
1598
|
var _a2;
|
|
1649
1599
|
return (_a2 = props.value) != null ? _a2 : "";
|
|
1650
1600
|
}, []);
|
|
1651
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0,
|
|
1652
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0,
|
|
1653
|
-
const initialValue = (0,
|
|
1601
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
|
|
1602
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
|
|
1603
|
+
const initialValue = (0, import_react12.useMemo)(() => {
|
|
1654
1604
|
return [
|
|
1655
1605
|
{
|
|
1656
1606
|
type: "paragraph",
|
|
@@ -1660,7 +1610,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1660
1610
|
}, [valueOnInitialRender]);
|
|
1661
1611
|
const editor = useCopilotTextareaEditor();
|
|
1662
1612
|
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
1663
|
-
const insertText = (0,
|
|
1613
|
+
const insertText = (0, import_react12.useCallback)(
|
|
1664
1614
|
(autosuggestion) => {
|
|
1665
1615
|
import_slate10.Editor.insertText(editor, autosuggestion.text, {
|
|
1666
1616
|
at: autosuggestion.point
|
|
@@ -1686,7 +1636,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1686
1636
|
autosuggestionsConfig.disableWhenEmpty,
|
|
1687
1637
|
shouldDisableAutosuggestions
|
|
1688
1638
|
);
|
|
1689
|
-
const onKeyDownHandlerForHoveringEditor = (0,
|
|
1639
|
+
const onKeyDownHandlerForHoveringEditor = (0, import_react12.useCallback)(
|
|
1690
1640
|
(event) => {
|
|
1691
1641
|
var _a2;
|
|
1692
1642
|
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, (_a2 = props.shortcut) != null ? _a2 : "k")) {
|
|
@@ -1700,7 +1650,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1700
1650
|
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
1701
1651
|
]
|
|
1702
1652
|
);
|
|
1703
|
-
(0,
|
|
1653
|
+
(0, import_react12.useEffect)(() => {
|
|
1704
1654
|
clearAutocompletionsFromEditor(editor);
|
|
1705
1655
|
if (currentAutocompleteSuggestion) {
|
|
1706
1656
|
addAutocompletionsToEditor(
|
|
@@ -1710,23 +1660,23 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1710
1660
|
);
|
|
1711
1661
|
}
|
|
1712
1662
|
}, [currentAutocompleteSuggestion]);
|
|
1713
|
-
const suggestionStyleAugmented = (0,
|
|
1663
|
+
const suggestionStyleAugmented = (0, import_react12.useMemo)(() => {
|
|
1714
1664
|
return __spreadValues({
|
|
1715
1665
|
fontStyle: "italic",
|
|
1716
1666
|
color: "gray"
|
|
1717
1667
|
}, props.suggestionsStyle);
|
|
1718
1668
|
}, [props.suggestionsStyle]);
|
|
1719
|
-
const renderElementMemoized = (0,
|
|
1669
|
+
const renderElementMemoized = (0, import_react12.useMemo)(() => {
|
|
1720
1670
|
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
1721
1671
|
}, [suggestionStyleAugmented]);
|
|
1722
|
-
const renderPlaceholderMemoized = (0,
|
|
1672
|
+
const renderPlaceholderMemoized = (0, import_react12.useMemo)(() => {
|
|
1723
1673
|
const placeholderStyleSlatejsOverrides = {
|
|
1724
1674
|
top: void 0
|
|
1725
1675
|
};
|
|
1726
1676
|
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
1727
1677
|
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
1728
1678
|
}, [props.placeholderStyle]);
|
|
1729
|
-
(0,
|
|
1679
|
+
(0, import_react12.useEffect)(() => {
|
|
1730
1680
|
var _a2, _b;
|
|
1731
1681
|
if (props.value === lastKnownFullEditorText) {
|
|
1732
1682
|
return;
|
|
@@ -1836,12 +1786,12 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
1836
1786
|
}
|
|
1837
1787
|
|
|
1838
1788
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
1839
|
-
var
|
|
1789
|
+
var import_react15 = __toESM(require("react"));
|
|
1840
1790
|
|
|
1841
1791
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
1842
1792
|
var import_shared = require("@copilotkit/shared");
|
|
1843
1793
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1844
|
-
var
|
|
1794
|
+
var import_react13 = require("react");
|
|
1845
1795
|
|
|
1846
1796
|
// src/lib/retry.tsx
|
|
1847
1797
|
function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
@@ -1861,10 +1811,10 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
|
1861
1811
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
1862
1812
|
var import_react_core4 = require("@copilotkit/react-core");
|
|
1863
1813
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
1864
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
1814
|
+
const { getContextString, copilotApiConfig } = (0, import_react13.useContext)(import_react_core3.CopilotContext);
|
|
1865
1815
|
const publicApiKey = copilotApiConfig.publicApiKey;
|
|
1866
1816
|
const headers = __spreadValues({}, publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
1867
|
-
return (0,
|
|
1817
|
+
return (0, import_react13.useCallback)(
|
|
1868
1818
|
(editorState2, abortSignal) => __async(this, null, function* () {
|
|
1869
1819
|
const res = yield retry(() => __async(this, null, function* () {
|
|
1870
1820
|
const messages = [
|
|
@@ -2144,11 +2094,11 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
|
|
|
2144
2094
|
|
|
2145
2095
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2146
2096
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
2147
|
-
var
|
|
2097
|
+
var import_react14 = require("react");
|
|
2148
2098
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2149
2099
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2150
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
2151
|
-
const insertionFunction = (0,
|
|
2100
|
+
const { getContextString, copilotApiConfig } = (0, import_react14.useContext)(import_react_core6.CopilotContext);
|
|
2101
|
+
const insertionFunction = (0, import_react14.useCallback)(
|
|
2152
2102
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2153
2103
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2154
2104
|
const messages = [
|
|
@@ -2188,7 +2138,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2188
2138
|
}),
|
|
2189
2139
|
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2190
2140
|
);
|
|
2191
|
-
const editingFunction = (0,
|
|
2141
|
+
const editingFunction = (0, import_react14.useCallback)(
|
|
2192
2142
|
(editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2193
2143
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2194
2144
|
const messages = [
|
|
@@ -2233,7 +2183,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2233
2183
|
}),
|
|
2234
2184
|
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2235
2185
|
);
|
|
2236
|
-
const insertionOrEditingFunction = (0,
|
|
2186
|
+
const insertionOrEditingFunction = (0, import_react14.useCallback)(
|
|
2237
2187
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2238
2188
|
if (editorState2.selectedText === "") {
|
|
2239
2189
|
return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
|
|
@@ -2249,7 +2199,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2249
2199
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
2250
2200
|
var import_lodash = __toESM(require("lodash.merge"));
|
|
2251
2201
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2252
|
-
var CopilotTextarea =
|
|
2202
|
+
var CopilotTextarea = import_react15.default.forwardRef(
|
|
2253
2203
|
(props, ref) => {
|
|
2254
2204
|
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
2255
2205
|
const autosuggestionsConfig = (0, import_lodash.default)(
|