@copilotkit/react-textarea 0.35.0-multi-feature-usecopilotreadable.4 → 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 +428 -428
- package/CHANGELOG.md +98 -8
- package/dist/{chunk-3B3LGEDJ.mjs → chunk-7R7KMN2G.mjs} +2 -2
- package/dist/{chunk-VPEH6V7T.mjs → chunk-FMQG2ZM3.mjs} +1 -1
- package/dist/chunk-FMQG2ZM3.mjs.map +1 -0
- package/dist/{chunk-FWZ23PN7.mjs → chunk-GZPRBYKA.mjs} +2 -2
- package/dist/chunk-JC6NGPO4.mjs +100 -0
- package/dist/chunk-JC6NGPO4.mjs.map +1 -0
- package/dist/{chunk-HXEH4QQL.mjs → chunk-MMVI7IPP.mjs} +5 -5
- package/dist/{chunk-QFG55HEW.mjs → chunk-O3QC2FT5.mjs} +20 -20
- package/dist/{chunk-Y5LVLSUK.mjs → chunk-P4EI4H6Y.mjs} +8 -8
- package/dist/{chunk-RT4UTBH3.mjs → chunk-SJ2TM5GA.mjs} +6 -2
- package/dist/chunk-SJ2TM5GA.mjs.map +1 -0
- 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 +17 -17
- package/dist/components/copilot-textarea/copilot-textarea.js +128 -74
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +24 -24
- 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 +6 -6
- 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 +4 -4
- 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 +5 -5
- 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 +5 -5
- package/dist/components/index.js +131 -77
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +24 -24
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +5 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
- package/dist/index.js +131 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -28
- package/package.json +6 -7
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +62 -13
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -1
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +6 -1
- package/dist/chunk-RT4UTBH3.mjs.map +0 -1
- package/dist/chunk-VPEH6V7T.mjs.map +0 -1
- package/dist/chunk-YNXNMCDX.mjs +0 -51
- package/dist/chunk-YNXNMCDX.mjs.map +0 -1
- /package/dist/{chunk-3B3LGEDJ.mjs.map → chunk-7R7KMN2G.mjs.map} +0 -0
- /package/dist/{chunk-FWZ23PN7.mjs.map → chunk-GZPRBYKA.mjs.map} +0 -0
- /package/dist/{chunk-HXEH4QQL.mjs.map → chunk-MMVI7IPP.mjs.map} +0 -0
- /package/dist/{chunk-QFG55HEW.mjs.map → chunk-O3QC2FT5.mjs.map} +0 -0
- /package/dist/{chunk-Y5LVLSUK.mjs.map → chunk-P4EI4H6Y.mjs.map} +0 -0
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseCopilotTextarea
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-O3QC2FT5.mjs";
|
|
4
|
+
import "../../chunk-DRV2FOHZ.mjs";
|
|
5
|
+
import "../../chunk-4NHVQZ67.mjs";
|
|
6
|
+
import "../../chunk-FMQG2ZM3.mjs";
|
|
4
7
|
import "../../chunk-2C7O2EVM.mjs";
|
|
5
8
|
import "../../chunk-GQN2HYFJ.mjs";
|
|
9
|
+
import "../../chunk-5UNJXFUO.mjs";
|
|
10
|
+
import "../../chunk-QKS2IOUH.mjs";
|
|
11
|
+
import "../../chunk-JJLQVT7S.mjs";
|
|
12
|
+
import "../../chunk-LQ2OWQU7.mjs";
|
|
6
13
|
import "../../chunk-7LSRNPNI.mjs";
|
|
7
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-GZPRBYKA.mjs";
|
|
8
15
|
import "../../chunk-L7VVZH4Q.mjs";
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
16
|
+
import "../../chunk-7R7KMN2G.mjs";
|
|
17
|
+
import "../../chunk-P4EI4H6Y.mjs";
|
|
18
|
+
import "../../chunk-JC6NGPO4.mjs";
|
|
19
|
+
import "../../chunk-3PQ7GSFE.mjs";
|
|
20
|
+
import "../../chunk-WFTAAA7R.mjs";
|
|
12
21
|
import "../../chunk-YFK5BFEI.mjs";
|
|
13
22
|
import "../../chunk-LYB4B6MK.mjs";
|
|
14
23
|
import "../../chunk-CF5GISTC.mjs";
|
|
15
24
|
import "../../chunk-4OZR65UB.mjs";
|
|
16
25
|
import "../../chunk-FFSICDS5.mjs";
|
|
17
26
|
import "../../chunk-4HBKWUCT.mjs";
|
|
18
|
-
import "../../chunk-WFTAAA7R.mjs";
|
|
19
|
-
import "../../chunk-3PQ7GSFE.mjs";
|
|
20
|
-
import "../../chunk-224UKA7C.mjs";
|
|
21
|
-
import "../../chunk-XW3ICO4S.mjs";
|
|
22
|
-
import "../../chunk-LQ2OWQU7.mjs";
|
|
23
27
|
import "../../chunk-2QDCE7PD.mjs";
|
|
28
|
+
import "../../chunk-7SUZ6CXM.mjs";
|
|
24
29
|
import "../../chunk-WJHSY5T6.mjs";
|
|
25
30
|
import "../../chunk-LCDTIJSD.mjs";
|
|
26
|
-
import "../../chunk-
|
|
27
|
-
import "../../chunk-
|
|
28
|
-
import "../../chunk-7SUZ6CXM.mjs";
|
|
29
|
-
import "../../chunk-DRV2FOHZ.mjs";
|
|
30
|
-
import "../../chunk-4NHVQZ67.mjs";
|
|
31
|
-
import "../../chunk-VPEH6V7T.mjs";
|
|
32
|
-
import "../../chunk-5UNJXFUO.mjs";
|
|
31
|
+
import "../../chunk-224UKA7C.mjs";
|
|
32
|
+
import "../../chunk-XW3ICO4S.mjs";
|
|
33
33
|
import "../../chunk-DFTV4TST.mjs";
|
|
34
34
|
import "../../chunk-T6MTDQZ7.mjs";
|
|
35
35
|
import "../../chunk-ECR45NSD.mjs";
|
|
@@ -82,9 +82,10 @@ __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
|
+
var import_shared = require("@copilotkit/shared");
|
|
88
89
|
var import_react_core = require("@copilotkit/react-core");
|
|
89
90
|
var import_react = require("react");
|
|
90
91
|
|
|
@@ -107,6 +108,8 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
|
107
108
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
108
109
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
109
110
|
const { getContextString, copilotApiConfig } = (0, import_react.useContext)(import_react_core.CopilotContext);
|
|
111
|
+
const publicApiKey = copilotApiConfig.publicApiKey;
|
|
112
|
+
const headers = __spreadValues({}, publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
110
113
|
return (0, import_react.useCallback)(
|
|
111
114
|
(editorState2, abortSignal) => __async(this, null, function* () {
|
|
112
115
|
const res = yield retry(() => __async(this, null, function* () {
|
|
@@ -134,7 +137,8 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
134
137
|
messages
|
|
135
138
|
}, apiConfig.forwardedParams), {
|
|
136
139
|
copilotConfig: copilotApiConfig,
|
|
137
|
-
signal: abortSignal
|
|
140
|
+
signal: abortSignal,
|
|
141
|
+
headers
|
|
138
142
|
}));
|
|
139
143
|
if (!response.events) {
|
|
140
144
|
throw new Error("Failed to fetch chat completion");
|
|
@@ -409,7 +413,7 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
|
|
|
409
413
|
});
|
|
410
414
|
|
|
411
415
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
412
|
-
var
|
|
416
|
+
var import_react14 = __toESM(require("react"));
|
|
413
417
|
var import_slate10 = require("slate");
|
|
414
418
|
var import_slate_react5 = require("slate-react");
|
|
415
419
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
@@ -962,7 +966,7 @@ function clearAutocompletionsFromEditor(editor) {
|
|
|
962
966
|
}
|
|
963
967
|
|
|
964
968
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
965
|
-
var
|
|
969
|
+
var import_react11 = require("react");
|
|
966
970
|
var import_slate7 = require("slate");
|
|
967
971
|
var import_slate_react3 = require("slate-react");
|
|
968
972
|
|
|
@@ -1198,7 +1202,7 @@ var Label = React4.forwardRef((_a, ref) => {
|
|
|
1198
1202
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1199
1203
|
|
|
1200
1204
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1201
|
-
var
|
|
1205
|
+
var import_react9 = require("react");
|
|
1202
1206
|
|
|
1203
1207
|
// src/lib/stream-promise-flatten.ts
|
|
1204
1208
|
function streamPromiseFlatten(promise) {
|
|
@@ -1228,8 +1232,7 @@ function streamPromiseFlatten(promise) {
|
|
|
1228
1232
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1229
1233
|
|
|
1230
1234
|
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
1231
|
-
var
|
|
1232
|
-
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
1235
|
+
var import_react7 = __toESM(require("react"));
|
|
1233
1236
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1234
1237
|
var IncludedFilesPreview = ({
|
|
1235
1238
|
includedFiles,
|
|
@@ -1251,37 +1254,88 @@ var IncludedFilesPreview = ({
|
|
|
1251
1254
|
}) })
|
|
1252
1255
|
] });
|
|
1253
1256
|
};
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
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",
|
|
1257
1265
|
{
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
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
|
+
]
|
|
1268
1322
|
}
|
|
1269
|
-
);
|
|
1270
|
-
}
|
|
1323
|
+
) });
|
|
1324
|
+
}
|
|
1271
1325
|
|
|
1272
1326
|
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1273
|
-
var
|
|
1327
|
+
var import_react8 = require("react");
|
|
1274
1328
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1275
|
-
var HoveringEditorContext = (0,
|
|
1329
|
+
var HoveringEditorContext = (0, import_react8.createContext)({
|
|
1276
1330
|
isDisplayed: false,
|
|
1277
1331
|
setIsDisplayed: () => {
|
|
1278
1332
|
}
|
|
1279
1333
|
});
|
|
1280
1334
|
var HoveringEditorProvider = ({ children }) => {
|
|
1281
|
-
const [isDisplayed, setIsDisplayed] = (0,
|
|
1335
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react8.useState)(false);
|
|
1282
1336
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1283
1337
|
};
|
|
1284
|
-
var useHoveringEditorContext = () => (0,
|
|
1338
|
+
var useHoveringEditorContext = () => (0, import_react8.useContext)(HoveringEditorContext);
|
|
1285
1339
|
|
|
1286
1340
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
1287
1341
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -1291,27 +1345,27 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1291
1345
|
insertionOrEditingFunction,
|
|
1292
1346
|
contextCategories
|
|
1293
1347
|
}) => {
|
|
1294
|
-
const { getDocumentsContext } = (0,
|
|
1295
|
-
const [editSuggestion, setEditSuggestion] = (0,
|
|
1296
|
-
const [suggestionIsLoading, setSuggestionIsLoading] = (0,
|
|
1297
|
-
const [adjustmentPrompt, setAdjustmentPrompt] = (0,
|
|
1298
|
-
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)(
|
|
1299
1353
|
null
|
|
1300
1354
|
);
|
|
1301
|
-
const adjustmentTextAreaRef = (0,
|
|
1302
|
-
const suggestionTextAreaRef = (0,
|
|
1303
|
-
const [filePointers, setFilePointers] = (0,
|
|
1304
|
-
const [suggestedFiles, setSuggestedFiles] = (0,
|
|
1305
|
-
(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)(() => {
|
|
1306
1360
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
1307
1361
|
}, [contextCategories, getDocumentsContext]);
|
|
1308
1362
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
1309
1363
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
1310
|
-
(0,
|
|
1364
|
+
(0, import_react9.useEffect)(() => {
|
|
1311
1365
|
var _a;
|
|
1312
1366
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
1313
1367
|
}, []);
|
|
1314
|
-
(0,
|
|
1368
|
+
(0, import_react9.useEffect)(() => {
|
|
1315
1369
|
if (!generatingSuggestion) {
|
|
1316
1370
|
return;
|
|
1317
1371
|
}
|
|
@@ -1349,7 +1403,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1349
1403
|
releaseLockIfNotClosed();
|
|
1350
1404
|
};
|
|
1351
1405
|
}, [generatingSuggestion]);
|
|
1352
|
-
const beginGeneratingAdjustment = (0,
|
|
1406
|
+
const beginGeneratingAdjustment = (0, import_react9.useCallback)(() => __async(void 0, null, function* () {
|
|
1353
1407
|
if (!adjustmentPrompt.trim()) {
|
|
1354
1408
|
return;
|
|
1355
1409
|
}
|
|
@@ -1502,10 +1556,10 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1502
1556
|
|
|
1503
1557
|
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1504
1558
|
var import_css = require("@emotion/css");
|
|
1505
|
-
var
|
|
1559
|
+
var import_react10 = __toESM(require("react"));
|
|
1506
1560
|
var import_react_dom = __toESM(require("react-dom"));
|
|
1507
1561
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1508
|
-
var Button2 =
|
|
1562
|
+
var Button2 = import_react10.default.forwardRef(
|
|
1509
1563
|
(_a, ref) => {
|
|
1510
1564
|
var _b = _a, {
|
|
1511
1565
|
className,
|
|
@@ -1531,7 +1585,7 @@ var Button2 = import_react9.default.forwardRef(
|
|
|
1531
1585
|
);
|
|
1532
1586
|
}
|
|
1533
1587
|
);
|
|
1534
|
-
var Icon =
|
|
1588
|
+
var Icon = import_react10.default.forwardRef(
|
|
1535
1589
|
(_a, ref) => {
|
|
1536
1590
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1537
1591
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1550,7 +1604,7 @@ var Icon = import_react9.default.forwardRef(
|
|
|
1550
1604
|
);
|
|
1551
1605
|
}
|
|
1552
1606
|
);
|
|
1553
|
-
var Menu =
|
|
1607
|
+
var Menu = import_react10.default.forwardRef(
|
|
1554
1608
|
(_a, ref) => {
|
|
1555
1609
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1556
1610
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1577,7 +1631,7 @@ var Menu = import_react9.default.forwardRef(
|
|
|
1577
1631
|
var Portal = ({ children }) => {
|
|
1578
1632
|
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1579
1633
|
};
|
|
1580
|
-
var Toolbar =
|
|
1634
|
+
var Toolbar = import_react10.default.forwardRef(
|
|
1581
1635
|
(_a, ref) => {
|
|
1582
1636
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1583
1637
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -1602,15 +1656,15 @@ var Toolbar = import_react9.default.forwardRef(
|
|
|
1602
1656
|
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1603
1657
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1604
1658
|
var HoveringToolbar = (props) => {
|
|
1605
|
-
const ref = (0,
|
|
1659
|
+
const ref = (0, import_react11.useRef)(null);
|
|
1606
1660
|
const editor = (0, import_slate_react3.useSlate)();
|
|
1607
1661
|
const selection = (0, import_slate_react3.useSlateSelection)();
|
|
1608
1662
|
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
1609
|
-
const [isClient, setIsClient] = (0,
|
|
1610
|
-
(0,
|
|
1663
|
+
const [isClient, setIsClient] = (0, import_react11.useState)(false);
|
|
1664
|
+
(0, import_react11.useEffect)(() => {
|
|
1611
1665
|
setIsClient(true);
|
|
1612
1666
|
}, []);
|
|
1613
|
-
(0,
|
|
1667
|
+
(0, import_react11.useEffect)(() => {
|
|
1614
1668
|
const el = ref.current;
|
|
1615
1669
|
const { selection: selection2 } = editor;
|
|
1616
1670
|
if (!el) {
|
|
@@ -1648,7 +1702,7 @@ var HoveringToolbar = (props) => {
|
|
|
1648
1702
|
el.style.top = `${top}px`;
|
|
1649
1703
|
el.style.left = `${left}px`;
|
|
1650
1704
|
});
|
|
1651
|
-
(0,
|
|
1705
|
+
(0, import_react11.useEffect)(() => {
|
|
1652
1706
|
const handleClickOutside = (event) => {
|
|
1653
1707
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1654
1708
|
setIsDisplayed(false);
|
|
@@ -1746,10 +1800,10 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
|
1746
1800
|
}
|
|
1747
1801
|
|
|
1748
1802
|
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
1749
|
-
var
|
|
1803
|
+
var import_react12 = require("react");
|
|
1750
1804
|
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
1751
1805
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
1752
|
-
(0,
|
|
1806
|
+
(0, import_react12.useEffect)(() => {
|
|
1753
1807
|
if (disableBranding) {
|
|
1754
1808
|
return;
|
|
1755
1809
|
}
|
|
@@ -1801,7 +1855,7 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
|
1801
1855
|
}
|
|
1802
1856
|
|
|
1803
1857
|
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1804
|
-
var
|
|
1858
|
+
var import_react13 = require("react");
|
|
1805
1859
|
var import_slate_react4 = require("slate-react");
|
|
1806
1860
|
var import_slate9 = require("slate");
|
|
1807
1861
|
|
|
@@ -1854,7 +1908,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
|
1854
1908
|
text: editorToText(state)
|
|
1855
1909
|
}));
|
|
1856
1910
|
const previousState = usePrevious(cursorState);
|
|
1857
|
-
(0,
|
|
1911
|
+
(0, import_react13.useEffect)(() => {
|
|
1858
1912
|
if (!previousState) {
|
|
1859
1913
|
return;
|
|
1860
1914
|
}
|
|
@@ -1877,8 +1931,8 @@ var isSelectionEqual = (a, b) => {
|
|
|
1877
1931
|
return import_slate9.Range.equals(a, b);
|
|
1878
1932
|
};
|
|
1879
1933
|
function usePrevious(value) {
|
|
1880
|
-
const ref = (0,
|
|
1881
|
-
(0,
|
|
1934
|
+
const ref = (0, import_react13.useRef)();
|
|
1935
|
+
(0, import_react13.useEffect)(() => {
|
|
1882
1936
|
ref.current = value;
|
|
1883
1937
|
});
|
|
1884
1938
|
return ref.current;
|
|
@@ -1886,21 +1940,21 @@ function usePrevious(value) {
|
|
|
1886
1940
|
|
|
1887
1941
|
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
1888
1942
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1889
|
-
var BaseCopilotTextarea =
|
|
1943
|
+
var BaseCopilotTextarea = import_react14.default.forwardRef(
|
|
1890
1944
|
(props, ref) => {
|
|
1891
1945
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
1892
1946
|
}
|
|
1893
1947
|
);
|
|
1894
|
-
var BaseCopilotTextareaWithHoveringContext =
|
|
1948
|
+
var BaseCopilotTextareaWithHoveringContext = import_react14.default.forwardRef(
|
|
1895
1949
|
(props, ref) => {
|
|
1896
1950
|
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
1897
|
-
const valueOnInitialRender = (0,
|
|
1951
|
+
const valueOnInitialRender = (0, import_react14.useMemo)(() => {
|
|
1898
1952
|
var _a2;
|
|
1899
1953
|
return (_a2 = props.value) != null ? _a2 : "";
|
|
1900
1954
|
}, []);
|
|
1901
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0,
|
|
1902
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0,
|
|
1903
|
-
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)(() => {
|
|
1904
1958
|
return [
|
|
1905
1959
|
{
|
|
1906
1960
|
type: "paragraph",
|
|
@@ -1910,7 +1964,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1910
1964
|
}, [valueOnInitialRender]);
|
|
1911
1965
|
const editor = useCopilotTextareaEditor();
|
|
1912
1966
|
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
1913
|
-
const insertText = (0,
|
|
1967
|
+
const insertText = (0, import_react14.useCallback)(
|
|
1914
1968
|
(autosuggestion) => {
|
|
1915
1969
|
import_slate10.Editor.insertText(editor, autosuggestion.text, {
|
|
1916
1970
|
at: autosuggestion.point
|
|
@@ -1936,7 +1990,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1936
1990
|
autosuggestionsConfig.disableWhenEmpty,
|
|
1937
1991
|
shouldDisableAutosuggestions
|
|
1938
1992
|
);
|
|
1939
|
-
const onKeyDownHandlerForHoveringEditor = (0,
|
|
1993
|
+
const onKeyDownHandlerForHoveringEditor = (0, import_react14.useCallback)(
|
|
1940
1994
|
(event) => {
|
|
1941
1995
|
var _a2;
|
|
1942
1996
|
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, (_a2 = props.shortcut) != null ? _a2 : "k")) {
|
|
@@ -1950,7 +2004,7 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1950
2004
|
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
1951
2005
|
]
|
|
1952
2006
|
);
|
|
1953
|
-
(0,
|
|
2007
|
+
(0, import_react14.useEffect)(() => {
|
|
1954
2008
|
clearAutocompletionsFromEditor(editor);
|
|
1955
2009
|
if (currentAutocompleteSuggestion) {
|
|
1956
2010
|
addAutocompletionsToEditor(
|
|
@@ -1960,23 +2014,23 @@ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
|
|
|
1960
2014
|
);
|
|
1961
2015
|
}
|
|
1962
2016
|
}, [currentAutocompleteSuggestion]);
|
|
1963
|
-
const suggestionStyleAugmented = (0,
|
|
2017
|
+
const suggestionStyleAugmented = (0, import_react14.useMemo)(() => {
|
|
1964
2018
|
return __spreadValues({
|
|
1965
2019
|
fontStyle: "italic",
|
|
1966
2020
|
color: "gray"
|
|
1967
2021
|
}, props.suggestionsStyle);
|
|
1968
2022
|
}, [props.suggestionsStyle]);
|
|
1969
|
-
const renderElementMemoized = (0,
|
|
2023
|
+
const renderElementMemoized = (0, import_react14.useMemo)(() => {
|
|
1970
2024
|
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
1971
2025
|
}, [suggestionStyleAugmented]);
|
|
1972
|
-
const renderPlaceholderMemoized = (0,
|
|
2026
|
+
const renderPlaceholderMemoized = (0, import_react14.useMemo)(() => {
|
|
1973
2027
|
const placeholderStyleSlatejsOverrides = {
|
|
1974
2028
|
top: void 0
|
|
1975
2029
|
};
|
|
1976
2030
|
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
1977
2031
|
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
1978
2032
|
}, [props.placeholderStyle]);
|
|
1979
|
-
(0,
|
|
2033
|
+
(0, import_react14.useEffect)(() => {
|
|
1980
2034
|
var _a2, _b;
|
|
1981
2035
|
if (props.value === lastKnownFullEditorText) {
|
|
1982
2036
|
return;
|
|
@@ -2087,11 +2141,11 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
2087
2141
|
|
|
2088
2142
|
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
2089
2143
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
2090
|
-
var
|
|
2144
|
+
var import_react15 = require("react");
|
|
2091
2145
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2092
2146
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
2093
|
-
const { getContextString, copilotApiConfig } = (0,
|
|
2094
|
-
const insertionFunction = (0,
|
|
2147
|
+
const { getContextString, copilotApiConfig } = (0, import_react15.useContext)(import_react_core6.CopilotContext);
|
|
2148
|
+
const insertionFunction = (0, import_react15.useCallback)(
|
|
2095
2149
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2096
2150
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2097
2151
|
const messages = [
|
|
@@ -2131,7 +2185,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2131
2185
|
}),
|
|
2132
2186
|
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2133
2187
|
);
|
|
2134
|
-
const editingFunction = (0,
|
|
2188
|
+
const editingFunction = (0, import_react15.useCallback)(
|
|
2135
2189
|
(editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2136
2190
|
const res = yield retry(() => __async(this, null, function* () {
|
|
2137
2191
|
const messages = [
|
|
@@ -2176,7 +2230,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2176
2230
|
}),
|
|
2177
2231
|
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
2178
2232
|
);
|
|
2179
|
-
const insertionOrEditingFunction = (0,
|
|
2233
|
+
const insertionOrEditingFunction = (0, import_react15.useCallback)(
|
|
2180
2234
|
(editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
2181
2235
|
if (editorState2.selectedText === "") {
|
|
2182
2236
|
return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
|
|
@@ -2192,7 +2246,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
2192
2246
|
// src/components/copilot-textarea/copilot-textarea.tsx
|
|
2193
2247
|
var import_lodash = __toESM(require("lodash.merge"));
|
|
2194
2248
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2195
|
-
var CopilotTextarea =
|
|
2249
|
+
var CopilotTextarea = import_react16.default.forwardRef(
|
|
2196
2250
|
(props, ref) => {
|
|
2197
2251
|
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
2198
2252
|
const autosuggestionsConfig = (0, import_lodash.default)(
|