@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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseCopilotTextarea
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-O3QC2FT5.mjs";
|
|
4
4
|
import "../../chunk-DRV2FOHZ.mjs";
|
|
5
5
|
import "../../chunk-4NHVQZ67.mjs";
|
|
6
6
|
import "../../chunk-FMQG2ZM3.mjs";
|
|
@@ -11,11 +11,11 @@ import "../../chunk-QKS2IOUH.mjs";
|
|
|
11
11
|
import "../../chunk-JJLQVT7S.mjs";
|
|
12
12
|
import "../../chunk-LQ2OWQU7.mjs";
|
|
13
13
|
import "../../chunk-7LSRNPNI.mjs";
|
|
14
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-GZPRBYKA.mjs";
|
|
15
15
|
import "../../chunk-L7VVZH4Q.mjs";
|
|
16
|
-
import "../../chunk-
|
|
17
|
-
import "../../chunk-
|
|
18
|
-
import "../../chunk-
|
|
16
|
+
import "../../chunk-7R7KMN2G.mjs";
|
|
17
|
+
import "../../chunk-P4EI4H6Y.mjs";
|
|
18
|
+
import "../../chunk-JC6NGPO4.mjs";
|
|
19
19
|
import "../../chunk-3PQ7GSFE.mjs";
|
|
20
20
|
import "../../chunk-WFTAAA7R.mjs";
|
|
21
21
|
import "../../chunk-YFK5BFEI.mjs";
|
|
@@ -82,7 +82,7 @@ __export(copilot_textarea_exports, {
|
|
|
82
82
|
CopilotTextarea: () => CopilotTextarea
|
|
83
83
|
});
|
|
84
84
|
module.exports = __toCommonJS(copilot_textarea_exports);
|
|
85
|
-
var
|
|
85
|
+
var import_react16 = __toESM(require("react"));
|
|
86
86
|
|
|
87
87
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
88
88
|
var import_shared = require("@copilotkit/shared");
|
|
@@ -413,7 +413,7 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
|
|
|
413
413
|
});
|
|
414
414
|
|
|
415
415
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
416
|
-
var
|
|
416
|
+
var import_react14 = __toESM(require("react"));
|
|
417
417
|
var import_slate10 = require("slate");
|
|
418
418
|
var import_slate_react5 = require("slate-react");
|
|
419
419
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
@@ -966,7 +966,7 @@ function clearAutocompletionsFromEditor(editor) {
|
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
969
|
-
var
|
|
969
|
+
var import_react11 = require("react");
|
|
970
970
|
var import_slate7 = require("slate");
|
|
971
971
|
var import_slate_react3 = require("slate-react");
|
|
972
972
|
|
|
@@ -1202,7 +1202,7 @@ var Label = React4.forwardRef((_a, ref) => {
|
|
|
1202
1202
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1203
1203
|
|
|
1204
1204
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1205
|
-
var
|
|
1205
|
+
var import_react9 = require("react");
|
|
1206
1206
|
|
|
1207
1207
|
// src/lib/stream-promise-flatten.ts
|
|
1208
1208
|
function streamPromiseFlatten(promise) {
|
|
@@ -1232,8 +1232,7 @@ function streamPromiseFlatten(promise) {
|
|
|
1232
1232
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1233
1233
|
|
|
1234
1234
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
1235
|
-
var
|
|
1236
|
-
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
1235
|
+
var import_react7 = __toESM(require("react"));
|
|
1237
1236
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1238
1237
|
var IncludedFilesPreview = ({
|
|
1239
1238
|
includedFiles,
|
|
@@ -1255,37 +1254,88 @@ var IncludedFilesPreview = ({
|
|
|
1255
1254
|
}) })
|
|
1256
1255
|
] });
|
|
1257
1256
|
};
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1257
|
+
function FileChipPreview({
|
|
1258
|
+
filePointer,
|
|
1259
|
+
onDelete
|
|
1260
|
+
}) {
|
|
1261
|
+
const CLOSE_BUTTON_COLOR = "rgba(0, 0, 0, 0.26)";
|
|
1262
|
+
const [color, setColor] = import_react7.default.useState(CLOSE_BUTTON_COLOR);
|
|
1263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1264
|
+
"button",
|
|
1261
1265
|
{
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1266
|
+
style: {
|
|
1267
|
+
fontSize: "0.8125rem",
|
|
1268
|
+
display: "inline-flex",
|
|
1269
|
+
justifyContent: "center",
|
|
1270
|
+
alignItems: "center",
|
|
1271
|
+
height: "32px",
|
|
1272
|
+
color: "rgba(0, 0, 0, 0.87)",
|
|
1273
|
+
backgroundColor: "rgba(0, 0, 0, 0.08)",
|
|
1274
|
+
borderRadius: "16px",
|
|
1275
|
+
whiteSpace: "nowrap",
|
|
1276
|
+
boxSizing: "border-box",
|
|
1277
|
+
border: 0,
|
|
1278
|
+
verticalAlign: "middle",
|
|
1279
|
+
outline: 0,
|
|
1280
|
+
cursor: "default"
|
|
1281
|
+
},
|
|
1282
|
+
children: [
|
|
1283
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1284
|
+
"img",
|
|
1285
|
+
{
|
|
1286
|
+
style: {
|
|
1287
|
+
marginLeft: "5px",
|
|
1288
|
+
width: "24px",
|
|
1289
|
+
height: "24px",
|
|
1290
|
+
backgroundColor: "transparent",
|
|
1291
|
+
borderRadius: "50%"
|
|
1292
|
+
},
|
|
1293
|
+
src: filePointer.iconImageUri,
|
|
1294
|
+
alt: filePointer.sourceApplication
|
|
1295
|
+
}
|
|
1296
|
+
),
|
|
1297
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { marginLeft: "5px" }, children: filePointer.name }),
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1299
|
+
"svg",
|
|
1300
|
+
{
|
|
1301
|
+
style: {
|
|
1302
|
+
color,
|
|
1303
|
+
fontSize: "22px",
|
|
1304
|
+
cursor: "pointer",
|
|
1305
|
+
margin: "0 5px 0 5px",
|
|
1306
|
+
userSelect: "none",
|
|
1307
|
+
width: "1em",
|
|
1308
|
+
height: "1em",
|
|
1309
|
+
display: "inline-block",
|
|
1310
|
+
fill: "currentColor",
|
|
1311
|
+
flexShrink: 0
|
|
1312
|
+
},
|
|
1313
|
+
viewBox: "0 0 24 24",
|
|
1314
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
1315
|
+
onClick: onDelete,
|
|
1316
|
+
onMouseOver: () => setColor("rgba(0, 0, 0, 0.54)"),
|
|
1317
|
+
onMouseOut: () => setColor(CLOSE_BUTTON_COLOR),
|
|
1318
|
+
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" })
|
|
1319
|
+
}
|
|
1320
|
+
)
|
|
1321
|
+
]
|
|
1272
1322
|
}
|
|
1273
|
-
);
|
|
1274
|
-
}
|
|
1323
|
+
) });
|
|
1324
|
+
}
|
|
1275
1325
|
|
|
1276
1326
|
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1277
|
-
var
|
|
1327
|
+
var import_react8 = require("react");
|
|
1278
1328
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1279
|
-
var HoveringEditorContext = (0,
|
|
1329
|
+
var HoveringEditorContext = (0, import_react8.createContext)({
|
|
1280
1330
|
isDisplayed: false,
|
|
1281
1331
|
setIsDisplayed: () => {
|
|
1282
1332
|
}
|
|
1283
1333
|
});
|
|
1284
1334
|
var HoveringEditorProvider = ({ children }) => {
|
|
1285
|
-
const [isDisplayed, setIsDisplayed] = (0,
|
|
1335
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react8.useState)(false);
|
|
1286
1336
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1287
1337
|
};
|
|
1288
|
-
var useHoveringEditorContext = () => (0,
|
|
1338
|
+
var useHoveringEditorContext = () => (0, import_react8.useContext)(HoveringEditorContext);
|
|
1289
1339
|
|
|
1290
1340
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1291
1341
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -1295,27 +1345,27 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1295
1345
|
insertionOrEditingFunction,
|
|
1296
1346
|
contextCategories
|
|
1297
1347
|
}) => {
|
|
1298
|
-
const { getDocumentsContext } = (0,
|
|
1299
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
1300
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
1301
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
1302
|
-
const [generatingSuggestion, setGeneratingSuggestion] = (0,
|
|
1348
|
+
const { getDocumentsContext } = (0, import_react9.useContext)(import_react_core5.CopilotContext);
|
|
1349
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react9.useState)("");
|
|
1350
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react9.useState)(false);
|
|
1351
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react9.useState)("");
|
|
1352
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react9.useState)(
|
|
1303
1353
|
null
|
|
1304
1354
|
);
|
|
1305
|
-
const adjustmentTextAreaRef = (0,
|
|
1306
|
-
const suggestionTextAreaRef = (0,
|
|
1307
|
-
const [filePointers, setFilePointers] = (0,
|
|
1308
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1309
|
-
(0,
|
|
1355
|
+
const adjustmentTextAreaRef = (0, import_react9.useRef)(null);
|
|
1356
|
+
const suggestionTextAreaRef = (0, import_react9.useRef)(null);
|
|
1357
|
+
const [filePointers, setFilePointers] = (0, import_react9.useState)([]);
|
|
1358
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react9.useState)([]);
|
|
1359
|
+
(0, import_react9.useEffect)(() => {
|
|
1310
1360
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1311
1361
|
}, [contextCategories, getDocumentsContext]);
|
|
1312
1362
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1313
1363
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1314
|
-
(0,
|
|
1364
|
+
(0, import_react9.useEffect)(() => {
|
|
1315
1365
|
var _a;
|
|
1316
1366
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1317
1367
|
}, []);
|
|
1318
|
-
(0,
|
|
1368
|
+
(0, import_react9.useEffect)(() => {
|
|
1319
1369
|
if (!generatingSuggestion) {
|
|
1320
1370
|
return;
|
|
1321
1371
|
}
|
|
@@ -1353,7 +1403,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1353
1403
|
releaseLockIfNotClosed();
|
|
1354
1404
|
};
|
|
1355
1405
|
}, [generatingSuggestion]);
|
|
1356
|
-
const beginGeneratingAdjustment = (0,
|
|
1406
|
+
const beginGeneratingAdjustment = (0, import_react9.useCallback)(() => __async(void 0, null, function* () {
|
|
1357
1407
|
if (!adjustmentPrompt.trim()) {
|
|
1358
1408
|
return;
|
|
1359
1409
|
}
|
|
@@ -1506,10 +1556,10 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1506
1556
|
|
|
1507
1557
|
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1508
1558
|
var import_css = require("@emotion/css");
|
|
1509
|
-
var
|
|
1559
|
+
var import_react10 = __toESM(require("react"));
|
|
1510
1560
|
var import_react_dom = __toESM(require("react-dom"));
|
|
1511
1561
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1512
|
-
var Button2 =
|
|
1562
|
+
var Button2 = import_react10.default.forwardRef(
|
|
1513
1563
|
(_a, ref) => {
|
|
1514
1564
|
var _b = _a, {
|
|
1515
1565
|
className,
|
|
@@ -1535,7 +1585,7 @@ var Button2 = import_react9.default.forwardRef(
|
|
|
1535
1585
|
);
|
|
1536
1586
|
}
|
|
1537
1587
|
);
|
|
1538
|
-
var Icon =
|
|
1588
|
+
var Icon = import_react10.default.forwardRef(
|
|
1539
1589
|
(_a, ref) => {
|
|
1540
1590
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1541
1591
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1554,7 +1604,7 @@ var Icon = import_react9.default.forwardRef(
|
|
|
1554
1604
|
);
|
|
1555
1605
|
}
|
|
1556
1606
|
);
|
|
1557
|
-
var Menu =
|
|
1607
|
+
var Menu = import_react10.default.forwardRef(
|
|
1558
1608
|
(_a, ref) => {
|
|
1559
1609
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1560
1610
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1581,7 +1631,7 @@ var Menu = import_react9.default.forwardRef(
|
|
|
1581
1631
|
var Portal = ({ children }) => {
|
|
1582
1632
|
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1583
1633
|
};
|
|
1584
|
-
var Toolbar =
|
|
1634
|
+
var Toolbar = import_react10.default.forwardRef(
|
|
1585
1635
|
(_a, ref) => {
|
|
1586
1636
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1587
1637
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1606,15 +1656,15 @@ var Toolbar = import_react9.default.forwardRef(
|
|
|
1606
1656
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1607
1657
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1608
1658
|
var HoveringToolbar = (props) => {
|
|
1609
|
-
const ref = (0,
|
|
1659
|
+
const ref = (0, import_react11.useRef)(null);
|
|
1610
1660
|
const editor = (0, import_slate_react3.useSlate)();
|
|
1611
1661
|
const selection = (0, import_slate_react3.useSlateSelection)();
|
|
1612
1662
|
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
1613
|
-
const [isClient, setIsClient] = (0,
|
|
1614
|
-
(0,
|
|
1663
|
+
const [isClient, setIsClient] = (0, import_react11.useState)(false);
|
|
1664
|
+
(0, import_react11.useEffect)(() => {
|
|
1615
1665
|
setIsClient(true);
|
|
1616
1666
|
}, []);
|
|
1617
|
-
(0,
|
|
1667
|
+
(0, import_react11.useEffect)(() => {
|
|
1618
1668
|
const el = ref.current;
|
|
1619
1669
|
const { selection: selection2 } = editor;
|
|
1620
1670
|
if (!el) {
|
|
@@ -1652,7 +1702,7 @@ var HoveringToolbar = (props) => {
|
|
|
1652
1702
|
el.style.top = `${top}px`;
|
|
1653
1703
|
el.style.left = `${left}px`;
|
|
1654
1704
|
});
|
|
1655
|
-
(0,
|
|
1705
|
+
(0, import_react11.useEffect)(() => {
|
|
1656
1706
|
const handleClickOutside = (event) => {
|
|
1657
1707
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1658
1708
|
setIsDisplayed(false);
|
|
@@ -1750,10 +1800,10 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
|
1750
1800
|
}
|
|
1751
1801
|
|
|
1752
1802
|
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
1753
|
-
var
|
|
1803
|
+
var import_react12 = require("react");
|
|
1754
1804
|
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
1755
1805
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
1756
|
-
(0,
|
|
1806
|
+
(0, import_react12.useEffect)(() => {
|
|
1757
1807
|
if (disableBranding) {
|
|
1758
1808
|
return;
|
|
1759
1809
|
}
|
|
@@ -1805,7 +1855,7 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
|
1805
1855
|
}
|
|
1806
1856
|
|
|
1807
1857
|
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1808
|
-
var
|
|
1858
|
+
var import_react13 = require("react");
|
|
1809
1859
|
var import_slate_react4 = require("slate-react");
|
|
1810
1860
|
var import_slate9 = require("slate");
|
|
1811
1861
|
|
|
@@ -1858,7 +1908,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
|
1858
1908
|
text: editorToText(state)
|
|
1859
1909
|
}));
|
|
1860
1910
|
const previousState = usePrevious(cursorState);
|
|
1861
|
-
(0,
|
|
1911
|
+
(0, import_react13.useEffect)(() => {
|
|
1862
1912
|
if (!previousState) {
|
|
1863
1913
|
return;
|
|
1864
1914
|
}
|
|
@@ -1881,8 +1931,8 @@ var isSelectionEqual = (a, b) => {
|
|
|
1881
1931
|
return import_slate9.Range.equals(a, b);
|
|
1882
1932
|
};
|
|
1883
1933
|
function usePrevious(value) {
|
|
1884
|
-
const ref = (0,
|
|
1885
|
-
(0,
|
|
1934
|
+
const ref = (0, import_react13.useRef)();
|
|
1935
|
+
(0, import_react13.useEffect)(() => {
|
|
1886
1936
|
ref.current = value;
|
|
1887
1937
|
});
|
|
1888
1938
|
return ref.current;
|
|
@@ -1890,21 +1940,21 @@ function usePrevious(value) {
|
|
|
1890
1940
|
|
|
1891
1941
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
1892
1942
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1893
|
-
var BaseCopilotTextarea =
|
|
1943
|
+
var BaseCopilotTextarea = import_react14.default.forwardRef(
|
|
1894
1944
|
(props, ref) => {
|
|
1895
1945
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
1896
1946
|
}
|
|
1897
1947
|
);
|
|
1898
|
-
var BaseCopilotTextareaWithHoveringContext =
|
|
1948
|
+
var BaseCopilotTextareaWithHoveringContext = import_react14.default.forwardRef(
|
|
1899
1949
|
(props, ref) => {
|
|
1900
1950
|
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
1901
|
-
const valueOnInitialRender = (0,
|
|
1951
|
+
const valueOnInitialRender = (0, import_react14.useMemo)(() => {
|
|
1902
1952
|
var _a2;
|
|
1903
1953
|
return (_a2 = props.value) != null ? _a2 : "";
|
|
1904
1954
|
}, []);
|
|
1905
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0,
|
|
1906
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0,
|
|
1907
|
-
const initialValue = (0,
|
|
1955
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react14.useState)(valueOnInitialRender);
|
|
1956
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react14.useState)(false);
|
|
1957
|
+
const initialValue = (0, import_react14.useMemo)(() => {
|
|
1908
1958
|
return [
|
|
1909
1959
|
{
|
|
1910
1960
|
type: "paragraph",
|
|
@@ -1914,7 +1964,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1914
1964
|
}, [valueOnInitialRender]);
|
|
1915
1965
|
const editor = useCopilotTextareaEditor();
|
|
1916
1966
|
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
1917
|
-
const insertText = (0,
|
|
1967
|
+
const insertText = (0, import_react14.useCallback)(
|
|
1918
1968
|
(autosuggestion) => {
|
|
1919
1969
|
import_slate10.Editor.insertText(editor, autosuggestion.text, {
|
|
1920
1970
|
at: autosuggestion.point
|
|
@@ -1940,7 +1990,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1940
1990
|
autosuggestionsConfig.disableWhenEmpty,
|
|
1941
1991
|
shouldDisableAutosuggestions
|
|
1942
1992
|
);
|
|
1943
|
-
const onKeyDownHandlerForHoveringEditor = (0,
|
|
1993
|
+
const onKeyDownHandlerForHoveringEditor = (0, import_react14.useCallback)(
|
|
1944
1994
|
(event) => {
|
|
1945
1995
|
var _a2;
|
|
1946
1996
|
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, (_a2 = props.shortcut) != null ? _a2 : "k")) {
|
|
@@ -1954,7 +2004,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1954
2004
|
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
1955
2005
|
]
|
|
1956
2006
|
);
|
|
1957
|
-
(0,
|
|
2007
|
+
(0, import_react14.useEffect)(() => {
|
|
1958
2008
|
clearAutocompletionsFromEditor(editor);
|
|
1959
2009
|
if (currentAutocompleteSuggestion) {
|
|
1960
2010
|
addAutocompletionsToEditor(
|
|
@@ -1964,23 +2014,23 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1964
2014
|
);
|
|
1965
2015
|
}
|
|
1966
2016
|
}, [currentAutocompleteSuggestion]);
|
|
1967
|
-
const suggestionStyleAugmented = (0,
|
|
2017
|
+
const suggestionStyleAugmented = (0, import_react14.useMemo)(() => {
|
|
1968
2018
|
return __spreadValues({
|
|
1969
2019
|
fontStyle: "italic",
|
|
1970
2020
|
color: "gray"
|
|
1971
2021
|
}, props.suggestionsStyle);
|
|
1972
2022
|
}, [props.suggestionsStyle]);
|
|
1973
|
-
const renderElementMemoized = (0,
|
|
2023
|
+
const renderElementMemoized = (0, import_react14.useMemo)(() => {
|
|
1974
2024
|
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
1975
2025
|
}, [suggestionStyleAugmented]);
|
|
1976
|
-
const renderPlaceholderMemoized = (0,
|
|
2026
|
+
const renderPlaceholderMemoized = (0, import_react14.useMemo)(() => {
|
|
1977
2027
|
const placeholderStyleSlatejsOverrides = {
|
|
1978
2028
|
top: void 0
|
|
1979
2029
|
};
|
|
1980
2030
|
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
1981
2031
|
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
1982
2032
|
}, [props.placeholderStyle]);
|
|
1983
|
-
(0,
|
|
2033
|
+
(0, import_react14.useEffect)(() => {
|
|
1984
2034
|
var _a2, _b;
|
|
1985
2035
|
if (props.value === lastKnownFullEditorText) {
|
|
1986
2036
|
return;
|
|
@@ -2091,11 +2141,11 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
2091
2141
|
|
|
2092
2142
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2093
2143
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
2094
|
-
var
|
|
2144
|
+
var import_react15 = require("react");
|
|
2095
2145
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2096
2146
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2097
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
2098
|
-
const insertionFunction = (0,
|
|
2147
|
+
const { getContextString, copilotApiConfig } = (0, import_react15.useContext)(import_react_core6.CopilotContext);
|
|
2148
|
+
const insertionFunction = (0, import_react15.useCallback)(
|
|
2099
2149
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2100
2150
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2101
2151
|
const messages = [
|
|
@@ -2135,7 +2185,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2135
2185
|
}),
|
|
2136
2186
|
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2137
2187
|
);
|
|
2138
|
-
const editingFunction = (0,
|
|
2188
|
+
const editingFunction = (0, import_react15.useCallback)(
|
|
2139
2189
|
(editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2140
2190
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2141
2191
|
const messages = [
|
|
@@ -2180,7 +2230,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2180
2230
|
}),
|
|
2181
2231
|
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2182
2232
|
);
|
|
2183
|
-
const insertionOrEditingFunction = (0,
|
|
2233
|
+
const insertionOrEditingFunction = (0, import_react15.useCallback)(
|
|
2184
2234
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2185
2235
|
if (editorState2.selectedText === "") {
|
|
2186
2236
|
return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
|
|
@@ -2196,7 +2246,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2196
2246
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
2197
2247
|
var import_lodash = __toESM(require("lodash.merge"));
|
|
2198
2248
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2199
|
-
var CopilotTextarea =
|
|
2249
|
+
var CopilotTextarea = import_react16.default.forwardRef(
|
|
2200
2250
|
(props, ref) => {
|
|
2201
2251
|
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
2202
2252
|
const autosuggestionsConfig = (0, import_lodash.default)(
|