@copilotkit/react-textarea 0.35.0-function-calling-fixes.2 → 0.35.0-mme-cloud.1
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 -432
- package/CHANGELOG.md +8 -20
- package/dist/{chunk-VPEH6V7T.mjs → chunk-FMQG2ZM3.mjs} +1 -1
- package/dist/chunk-FMQG2ZM3.mjs.map +1 -0
- package/dist/{chunk-SP5HFO3H.mjs → chunk-HWM2CVKO.mjs} +2 -2
- package/dist/{chunk-22TYLEZZ.mjs → chunk-XU5Z5BWV.mjs} +2 -2
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +36 -1752
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +4 -48
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +4 -46
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +5 -83
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +4 -54
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +45 -2196
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +5 -13
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +8 -130
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +19 -876
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +14 -569
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +15 -592
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +7 -98
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +16 -592
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +48 -2196
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +2 -0
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +8 -207
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +6 -81
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +7 -42
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +14 -232
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +11 -134
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +5 -56
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +7 -42
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +7 -42
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.mjs +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +7 -155
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +5 -165
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- 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 +6 -145
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +5 -111
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +5 -160
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +4 -12
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -2196
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +4 -48
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +4 -40
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +7 -96
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +4 -14
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +4 -22
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +4 -17
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +4 -24
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +5 -102
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +4 -44
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +9 -63
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +9 -271
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +6 -82
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +10 -271
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +6 -73
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +6 -59
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +4 -23
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +5 -14
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +5 -23
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +1 -0
- package/dist/types/index.mjs +14 -271
- package/dist/types/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -1
- package/dist/chunk-VPEH6V7T.mjs.map +0 -1
- /package/dist/{chunk-SP5HFO3H.mjs.map → chunk-HWM2CVKO.mjs.map} +0 -0
- /package/dist/{chunk-22TYLEZZ.mjs.map → chunk-XU5Z5BWV.mjs.map} +0 -0
package/dist/types/index.mjs
CHANGED
|
@@ -1,274 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
// src/types/base/base-autosuggestions-config.tsx
|
|
22
|
-
import { defaultCopilotContextCategories } from "@copilotkit/react-core";
|
|
23
|
-
var defaultShouldToggleHoveringEditorOnKeyPress = (event, shortcut) => {
|
|
24
|
-
if (event.key === shortcut && event.metaKey) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
29
|
-
var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
|
|
30
|
-
if (event.key === "Tab") {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
};
|
|
35
|
-
var defaultBaseAutosuggestionsConfig = {
|
|
36
|
-
debounceTime: 250,
|
|
37
|
-
contextCategories: defaultCopilotContextCategories,
|
|
38
|
-
disableWhenEmpty: true,
|
|
39
|
-
disabled: false,
|
|
40
|
-
temporarilyDisableWhenMovingCursorWithoutChangingText: true,
|
|
41
|
-
shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
|
|
42
|
-
shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/types/autosuggestions-config/suggestions-api-config.tsx
|
|
46
|
-
var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
47
|
-
return `You are a versatile writing assistant.
|
|
48
|
-
|
|
49
|
-
The user is writing some text.
|
|
50
|
-
The purpose is: "${textareaPurpose}"
|
|
51
|
-
|
|
52
|
-
Your job is to guess what the user will write next AS BEST YOU CAN.
|
|
53
|
-
Only guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.
|
|
54
|
-
|
|
55
|
-
Adjust yourself to the user's style and implied intent.
|
|
56
|
-
|
|
57
|
-
The user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.
|
|
58
|
-
<TextAfterCursor>
|
|
59
|
-
<TextBeforeCursor>
|
|
60
|
-
<YourSuggestion>
|
|
61
|
-
|
|
62
|
-
If we need to add a whitespace character to the suggested text, make sure to explicitly add it in.
|
|
63
|
-
|
|
64
|
-
The following external context is also provided. Use it to help you make better suggestions!!!
|
|
65
|
-
\`\`\`
|
|
66
|
-
${contextString}
|
|
67
|
-
\`\`\`
|
|
68
|
-
`;
|
|
69
|
-
};
|
|
70
|
-
var defaultSuggestionsFewShotMessages = [
|
|
71
|
-
{
|
|
72
|
-
role: "user",
|
|
73
|
-
name: "TextAfterCursor",
|
|
74
|
-
content: "While I was there I also picked up some apples, oranges, and bananas."
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
role: "user",
|
|
78
|
-
content: "This morning I woke up and went straight to the grocery store."
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
role: "assistant",
|
|
82
|
-
content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
role: "user",
|
|
86
|
-
name: "TextAfterCursor",
|
|
87
|
-
content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
role: "user",
|
|
91
|
-
name: "TextBeforeCursor",
|
|
92
|
-
content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
role: "assistant",
|
|
96
|
-
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
var defaultSuggestionsApiConfig = {
|
|
100
|
-
makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
|
|
101
|
-
fewShotMessages: defaultSuggestionsFewShotMessages,
|
|
102
|
-
forwardedParams: void 0
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// src/types/autosuggestions-config/insertions-api-config.tsx
|
|
106
|
-
var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
107
|
-
return `You are a versatile writing assistant helping the user insert new text into their existing work.
|
|
108
|
-
|
|
109
|
-
The user is writing some text.
|
|
110
|
-
The purpose is: "${textareaPurpose}"
|
|
111
|
-
|
|
112
|
-
The following external context is also provided. Use it to inform your suggestions when relevant!!!
|
|
113
|
-
\`\`\`
|
|
114
|
-
${contextString}
|
|
115
|
-
\`\`\`
|
|
116
|
-
|
|
117
|
-
The user will provide you with a prompt for an INSERTION into the text they are writing.
|
|
118
|
-
Your job is to come up with an INSERTION into the text that the user would like to use, AS BEST YOU CAN.
|
|
119
|
-
Only insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.
|
|
120
|
-
|
|
121
|
-
Adjust yourself to the user's style and implied intent.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
The user will provide the text before and after the cursor, as well as the INSERTION prompt. You should use this to infer the best relevant insertion.
|
|
125
|
-
The conversation will be structured as follows:
|
|
126
|
-
<TextAfterCursor>
|
|
127
|
-
<TextBeforeCursor>
|
|
128
|
-
<InsertionPrompt>
|
|
129
|
-
|
|
130
|
-
<YourInsertionSuggestion>
|
|
131
|
-
`;
|
|
132
|
-
};
|
|
133
|
-
var defaultInsertionsFewShotMessages = [
|
|
134
|
-
{
|
|
135
|
-
role: "user",
|
|
136
|
-
name: "TextAfterCursor",
|
|
137
|
-
content: "While I was there I also picked up some apples, oranges, and bananas."
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
role: "user",
|
|
141
|
-
name: "TextBeforeCursor",
|
|
142
|
-
content: "This morning I woke up and went straight to the grocery store."
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
role: "user",
|
|
146
|
-
name: "InsertionPrompt",
|
|
147
|
-
content: "I bought a big watermelon"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
role: "assistant",
|
|
151
|
-
content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
role: "user",
|
|
155
|
-
name: "TextAfterCursor",
|
|
156
|
-
content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
role: "user",
|
|
160
|
-
name: "TextBeforeCursor",
|
|
161
|
-
content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
role: "user",
|
|
165
|
-
name: "InsertionPrompt",
|
|
166
|
-
content: "add section about the optionholder's pro rata share"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
role: "assistant",
|
|
170
|
-
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
171
|
-
}
|
|
172
|
-
];
|
|
173
|
-
var defaultInsertionsApiConfig = {
|
|
174
|
-
makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
|
|
175
|
-
fewShotMessages: defaultInsertionsFewShotMessages,
|
|
176
|
-
forwardedParams: void 0
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// src/types/autosuggestions-config/editing-api-config.tsx
|
|
180
|
-
var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
181
|
-
return `You are a versatile writing assistant helping the user edit a portion of their text.
|
|
182
|
-
|
|
183
|
-
The user is writing some text.
|
|
184
|
-
The purpose is: "${textareaPurpose}"
|
|
185
|
-
|
|
186
|
-
The following external context is also provided. Use it when relevant.
|
|
187
|
-
\`\`\`
|
|
188
|
-
${contextString}
|
|
189
|
-
\`\`\`
|
|
190
|
-
|
|
191
|
-
The user has provided you with a PROMPT for EDITING a PORTION of the text.
|
|
192
|
-
Your job is to come up with a new EDITED version OF THE SEGMENT IN QUESTION - AS BEST YOU CAN.
|
|
193
|
-
Only rewrite the portion of the text that the user has marked as "TextToEdit"!!!
|
|
194
|
-
|
|
195
|
-
Adjust yourself to the user's style and implied intent.
|
|
196
|
-
|
|
197
|
-
The conversation will be structured as follows:
|
|
198
|
-
<TextBeforeCursor>
|
|
199
|
-
<TextToEdit>
|
|
200
|
-
<TextAfterCursor>
|
|
201
|
-
<EditingPrompt>
|
|
202
|
-
|
|
203
|
-
<YourEditSuggestion>
|
|
204
|
-
`;
|
|
205
|
-
};
|
|
206
|
-
var defaultEditingFewShotMessages = [
|
|
207
|
-
{
|
|
208
|
-
role: "user",
|
|
209
|
-
name: "TextBeforeCursor",
|
|
210
|
-
content: "This morning I woke up and went straight to the grocery store. "
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
role: "user",
|
|
214
|
-
name: "TextToEdit",
|
|
215
|
-
content: "While I was there I picked up some apples, oranges, and bananas. "
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
role: "user",
|
|
219
|
-
name: "TextAfterCursor",
|
|
220
|
-
content: "The grocery store was having a sale on fruit, so I decided to stock up."
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
role: "user",
|
|
224
|
-
name: "EditingPrompt",
|
|
225
|
-
content: "I also bought a big watermelon"
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
role: "assistant",
|
|
229
|
-
content: "While I was there I picked up some apples, oranges, and bananas, and a big watermelon."
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
role: "user",
|
|
233
|
-
name: "TextBeforeCursor",
|
|
234
|
-
content: "Yesterday, I spent the afternoon working on my new project. "
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
role: "user",
|
|
238
|
-
name: "TextToEdit",
|
|
239
|
-
content: "It's quite challenging and requires a lot of focus. "
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
role: "user",
|
|
243
|
-
name: "TextAfterCursor",
|
|
244
|
-
content: "I'm really excited about the potential outcomes of this project."
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
role: "user",
|
|
248
|
-
name: "EditingPrompt",
|
|
249
|
-
content: "emphasize the complexity and my enthusiasm for the project"
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
role: "assistant",
|
|
253
|
-
content: "It's a highly complex task that demands intense concentration, but I'm incredibly enthusiastic about the promising prospects of this project."
|
|
254
|
-
}
|
|
255
|
-
];
|
|
256
|
-
var defaultEditingApiConfig = {
|
|
257
|
-
makeSystemPrompt: defaultEditingMakeSystemPrompt,
|
|
258
|
-
fewShotMessages: defaultEditingFewShotMessages,
|
|
259
|
-
forwardedParams: void 0
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// src/types/autosuggestions-config/autosuggestions-config.tsx
|
|
263
|
-
import { defaultCopilotContextCategories as defaultCopilotContextCategories2 } from "@copilotkit/react-core";
|
|
264
|
-
var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
|
|
265
|
-
contextCategories: defaultCopilotContextCategories2,
|
|
266
|
-
chatApiConfigs: {
|
|
267
|
-
suggestionsApiConfig: defaultSuggestionsApiConfig,
|
|
268
|
-
insertionApiConfig: defaultInsertionsApiConfig,
|
|
269
|
-
editingApiConfig: defaultEditingApiConfig
|
|
270
|
-
}
|
|
271
|
-
});
|
|
1
|
+
import "../chunk-DE5K76I2.mjs";
|
|
2
|
+
import "../chunk-WADHCMPK.mjs";
|
|
3
|
+
import "../chunk-RUV6NBIF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
defaultAutosuggestionsConfig
|
|
6
|
+
} from "../chunk-DKE57EAC.mjs";
|
|
7
|
+
import "../chunk-4OJ3H65F.mjs";
|
|
8
|
+
import "../chunk-RKQ6RTZM.mjs";
|
|
9
|
+
import "../chunk-KDVMG3XF.mjs";
|
|
10
|
+
import "../chunk-WJHSY5T6.mjs";
|
|
11
|
+
import {
|
|
12
|
+
defaultBaseAutosuggestionsConfig
|
|
13
|
+
} from "../chunk-LCDTIJSD.mjs";
|
|
14
|
+
import "../chunk-MRXNTQOX.mjs";
|
|
272
15
|
export {
|
|
273
16
|
defaultAutosuggestionsConfig,
|
|
274
17
|
defaultBaseAutosuggestionsConfig
|
package/dist/types/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/base/base-autosuggestions-config.tsx","../../src/types/autosuggestions-config/suggestions-api-config.tsx","../../src/types/autosuggestions-config/insertions-api-config.tsx","../../src/types/autosuggestions-config/editing-api-config.tsx","../../src/types/autosuggestions-config/autosuggestions-config.tsx"],"sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n/**\n * @interface BaseAutosuggestionsConfig\n *\n * @property {string} textareaPurpose - The purpose of the textarea. This is used to guide the autosuggestions.\n *\n * @property {string[]} contextCategories - The categories of context to consider when providing autosuggestions.\n *\n * @property {number} debounceTime - The amount of time (in milliseconds) to wait before triggering autosuggestions after the user has stopped typing.\n *\n * @property {BaseCopilotTextareaApiConfig} apiConfig - The configuration for the API that provides the autosuggestions.\n *\n * @property {boolean} disableWhenEmpty - Whether to disable autosuggestions when the textarea is empty.\n *\n * @property {boolean} disabled - Whether to disable autosuggestions entirely.\n *\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable autosuggestions when the user moves the cursor without changing the text.\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the current autosuggestion based on a key press event. By default, the Tab key is used to accept the autosuggestion. Example code:\n *\n * ```typescript\n * const defaultShouldAcceptAutosuggestionOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if tab, accept the autosuggestion\n * if (event.key === \"Tab\") {\n * return true;\n * }\n * return false;\n * }\n * ```\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:\n *\n * ```typescript\n * const defaultShouldToggleHoveringEditorOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if command-k, toggle the hovering editor\n * if (event.key === \"k\" && event.metaKey) {\n * return true;\n * }\n * return false;\n * }\n * ```\n */\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n contextCategories: string[];\n debounceTime: number;\n apiConfig: BaseCopilotTextareaApiConfig;\n\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n shouldToggleHoveringEditorOnKeyPress: (\n event: React.KeyboardEvent<HTMLDivElement>,\n shortcut: string,\n ) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n shortcut: string,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === shortcut && event.metaKey) {\n return true;\n }\n return false;\n};\n\nconst defaultShouldAcceptAutosuggestionOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if tab, accept the autosuggestion\n if (event.key === \"Tab\") {\n return true;\n }\n return false;\n};\n\n/**\n * Default configuration for the BaseAutosuggestions.\n *\n * @property {number} debounceTime - The amount of time to wait before triggering the autosuggestions API call.\n * @property {string[]} contextCategories - The categories to use for context when making the autosuggestions API call.\n * @property {boolean} disableWhenEmpty - Whether to disable the autosuggestions when the textarea is empty.\n * @property {boolean} disabled - Whether to disable the autosuggestions feature entirely.\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.\n */\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n contextCategories: defaultCopilotContextCategories,\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,\n shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,\n};\n","import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n","import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface InsertionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant helping the user insert new text into their existing work.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to inform your suggestions when relevant!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user will provide you with a prompt for an INSERTION into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like to use, AS BEST YOU CAN.\nOnly insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\n\nThe user will provide the text before and after the cursor, as well as the INSERTION prompt. You should use this to infer the best relevant insertion.\nThe conversation will be structured as follows:\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n\n<YourInsertionSuggestion>\n`;\n};\n\nexport const defaultInsertionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"I bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultInsertionsApiConfig: InsertionsApiConfig = {\n makeSystemPrompt: defaultInsertionsMakeSystemPrompt,\n fewShotMessages: defaultInsertionsFewShotMessages,\n forwardedParams: undefined,\n};\n","import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface EditingApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultEditingMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant helping the user edit a portion of their text.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it when relevant.\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user has provided you with a PROMPT for EDITING a PORTION of the text. \nYour job is to come up with a new EDITED version OF THE SEGMENT IN QUESTION - AS BEST YOU CAN.\nOnly rewrite the portion of the text that the user has marked as \"TextToEdit\"!!!\n\nAdjust yourself to the user's style and implied intent.\n\nThe conversation will be structured as follows:\n<TextBeforeCursor>\n<TextToEdit>\n<TextAfterCursor>\n<EditingPrompt>\n\n<YourEditSuggestion>\n`;\n};\n\nexport const defaultEditingFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store. \",\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: \"While I was there I picked up some apples, oranges, and bananas. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"The grocery store was having a sale on fruit, so I decided to stock up.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"I also bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \"While I was there I picked up some apples, oranges, and bananas, and a big watermelon.\",\n },\n\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"Yesterday, I spent the afternoon working on my new project. \",\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: \"It's quite challenging and requires a lot of focus. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"I'm really excited about the potential outcomes of this project.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"emphasize the complexity and my enthusiasm for the project\",\n },\n {\n role: \"assistant\",\n content:\n \"It's a highly complex task that demands intense concentration, but I'm incredibly enthusiastic about the promising prospects of this project.\",\n },\n];\n\nexport const defaultEditingApiConfig: EditingApiConfig = {\n makeSystemPrompt: defaultEditingMakeSystemPrompt,\n fewShotMessages: defaultEditingFewShotMessages,\n forwardedParams: undefined,\n};\n","import { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from \"../base\";\nimport { SuggestionsApiConfig, defaultSuggestionsApiConfig } from \"./suggestions-api-config\";\nimport { InsertionsApiConfig, defaultInsertionsApiConfig } from \"./insertions-api-config\";\nimport { EditingApiConfig, defaultEditingApiConfig } from \"./editing-api-config\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n// Like the base autosuggestions config, with 2 additional fields:\n// 1. contextCategories: string[] | undefined;\n// 2. instead of apiConfigs, we have chatApiConfigs: a higher-level abstraction that uses a ChatGPT-like API endpoint.\nexport interface AutosuggestionsConfig extends Omit<BaseAutosuggestionsConfig, \"apiConfig\"> {\n contextCategories: string[];\n chatApiConfigs: {\n suggestionsApiConfig: SuggestionsApiConfig;\n insertionApiConfig: InsertionsApiConfig;\n editingApiConfig: EditingApiConfig;\n };\n}\n\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"textareaPurpose\" | \"apiEndpoint\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n contextCategories: defaultCopilotContextCategories,\n chatApiConfigs: {\n suggestionsApiConfig: defaultSuggestionsApiConfig,\n insertionApiConfig: defaultInsertionsApiConfig,\n editingApiConfig: defaultEditingApiConfig,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAAS,uCAAuC;AA4DhD,IAAM,8CAA8C,CAClD,OACA,aACG;AAEH,MAAI,MAAM,QAAQ,YAAY,MAAM,SAAS;AAC3C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcO,IAAM,mCAGT;AAAA,EACF,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uDAAuD;AAAA,EACvD,sCAAsC;AAAA,EACtC,sCAAsC;AACxC;;;AChGO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,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,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,0BAA4C;AAAA,EACvD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;;;AC7FA,SAAS,mCAAAA,wCAAuC;AAczC,IAAM,+BAGT,iCACC,mCADD;AAAA,EAEF,mBAAmBC;AAAA,EACnB,gBAAgB;AAAA,IACd,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,EACpB;AACF;","names":["defaultCopilotContextCategories","defaultCopilotContextCategories"]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.35.0-
|
|
7
|
+
"version": "0.35.0-mme-cloud.1",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"**/*.css"
|
|
10
10
|
],
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"ts-jest": "^29.1.1",
|
|
38
38
|
"tsup": "^6.7.0",
|
|
39
39
|
"typescript": "^5.2.3",
|
|
40
|
-
"eslint-config-custom": "0.10.0-
|
|
41
|
-
"tailwind-config": "0.9.0-
|
|
42
|
-
"tsconfig": "0.14.0-
|
|
40
|
+
"eslint-config-custom": "0.10.0-mme-cloud.1",
|
|
41
|
+
"tailwind-config": "0.9.0-mme-cloud.1",
|
|
42
|
+
"tsconfig": "0.14.0-mme-cloud.1"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@emotion/css": "^11.11.2",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"slate-history": "^0.93.0",
|
|
63
63
|
"slate-react": "^0.98.1",
|
|
64
64
|
"tailwind-merge": "^1.13.2",
|
|
65
|
-
"@copilotkit/react-core": "0.25.0-
|
|
66
|
-
"@copilotkit/shared": "0.9.0-
|
|
65
|
+
"@copilotkit/react-core": "0.25.0-mme-cloud.1",
|
|
66
|
+
"@copilotkit/shared": "0.9.0-mme-cloud.1"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsup --clean",
|
|
@@ -14,7 +14,10 @@ export function usePopulateCopilotTextareaRef(
|
|
|
14
14
|
ref,
|
|
15
15
|
() => {
|
|
16
16
|
class Combined {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(
|
|
18
|
+
private customMethods: CustomMethods,
|
|
19
|
+
private editorHtmlElement: HTMLElement,
|
|
20
|
+
) {}
|
|
18
21
|
|
|
19
22
|
[key: string]: any;
|
|
20
23
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts"],"sourcesContent":["import React from \"react\";\nimport { Editor } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\nimport { getFullEditorTextWithNewlines } from \"../../lib/get-text-around-cursor\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function usePopulateCopilotTextareaRef(\n editor: Editor,\n ref: React.Ref<HTMLCopilotTextAreaElement>,\n) {\n React.useImperativeHandle(\n ref,\n () => {\n class Combined {\n constructor(private customMethods: CustomMethods, private editorHtmlElement: HTMLElement) {}\n\n [key: string]: any;\n\n get(target: any, propKey: string): any {\n if (this.isKeyOfCustomMethods(propKey)) {\n const value = this.customMethods[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.customMethods);\n }\n return value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n const value = this.editorHtmlElement[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.editorHtmlElement);\n }\n return value;\n }\n }\n\n set(target: any, propKey: string, value: any): boolean {\n if (this.isKeyOfCustomMethods(propKey)) {\n (this.customMethods as any)[propKey] = value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n (this.editorHtmlElement as any)[propKey] = value;\n } else {\n // Default behavior (optional)\n target[propKey] = value;\n }\n return true;\n }\n\n private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {\n return key in this.customMethods;\n }\n\n private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {\n return key in this.editorHtmlElement;\n }\n }\n\n const handler = {\n get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {\n return target.get(target, propKey);\n },\n set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {\n return target.set(target, propKey, value);\n },\n };\n\n class CustomMethods {\n constructor(private editor: CustomEditor) {}\n\n focus() {\n ReactEditor.focus(this.editor);\n }\n\n blur() {\n ReactEditor.blur(this.editor);\n }\n\n get value() {\n return getFullEditorTextWithNewlines(this.editor);\n }\n set value(value: string) {\n replaceEditorText(this.editor, value);\n }\n }\n\n const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);\n const customMethods = new CustomMethods(editor);\n\n const comb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