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