@copilotkit/react-textarea 0.24.0 → 0.26.0-alpha.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.
Files changed (277) hide show
  1. package/.turbo/turbo-build.log +313 -309
  2. package/CHANGELOG.md +22 -0
  3. package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +29 -0
  4. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1745 -35
  5. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  6. package/dist/components/base-copilot-textarea/render-element.mjs +51 -3
  7. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  8. package/dist/components/base-copilot-textarea/render-placeholder.mjs +49 -3
  9. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  10. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +86 -4
  11. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  12. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +57 -3
  13. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  14. package/dist/components/copilot-textarea/copilot-textarea.d.ts +3 -0
  15. package/dist/components/copilot-textarea/copilot-textarea.mjs +2202 -47
  16. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  17. package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +7 -3
  18. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +17 -3
  19. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  20. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +137 -3
  21. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  22. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +875 -18
  23. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  24. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +558 -12
  25. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  26. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +581 -13
  27. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  28. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +102 -5
  29. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  30. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +581 -14
  31. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  32. package/dist/components/index.mjs +2203 -48
  33. package/dist/components/index.mjs.map +1 -1
  34. package/dist/components/manual-ui/chip-with-icon.mjs +11 -27
  35. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  36. package/dist/components/source-search-box/source-search-box.mjs +211 -6
  37. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  38. package/dist/components/ui/button.mjs +85 -4
  39. package/dist/components/ui/button.mjs.map +1 -1
  40. package/dist/components/ui/card.mjs +96 -52
  41. package/dist/components/ui/card.mjs.map +1 -1
  42. package/dist/components/ui/command.mjs +244 -5
  43. package/dist/components/ui/command.mjs.map +1 -1
  44. package/dist/components/ui/dialog.mjs +144 -4
  45. package/dist/components/ui/dialog.mjs.map +1 -1
  46. package/dist/components/ui/label.mjs +60 -4
  47. package/dist/components/ui/label.mjs.map +1 -1
  48. package/dist/components/ui/separator.mjs +58 -15
  49. package/dist/components/ui/separator.mjs.map +1 -1
  50. package/dist/components/ui/textarea.mjs +58 -14
  51. package/dist/components/ui/textarea.mjs.map +1 -1
  52. package/dist/context/index.d.ts +1 -0
  53. package/dist/context/index.mjs +0 -2
  54. package/dist/context/index.mjs.map +1 -1
  55. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +1 -1
  56. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +158 -6
  57. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  58. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +168 -4
  59. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  60. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +148 -5
  61. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  62. package/dist/hooks/index.d.ts +1 -0
  63. package/dist/hooks/index.mjs +0 -2
  64. package/dist/hooks/index.mjs.map +1 -1
  65. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +147 -14
  66. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  67. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +193 -14
  68. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  69. package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
  70. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  71. package/dist/index.mjs +2206 -50
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/lib/debouncer.mjs +51 -3
  74. package/dist/lib/debouncer.mjs.map +1 -1
  75. package/dist/lib/editor-to-text.mjs +43 -3
  76. package/dist/lib/editor-to-text.mjs.map +1 -1
  77. package/dist/lib/get-text-around-cursor.mjs +102 -3
  78. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  79. package/dist/lib/retry.mjs +17 -3
  80. package/dist/lib/retry.mjs.map +1 -1
  81. package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
  82. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  83. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +20 -3
  84. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  85. package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
  86. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  87. package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
  88. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  89. package/dist/lib/stream-promise-flatten.mjs +47 -3
  90. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  91. package/dist/lib/utils.mjs +71 -3
  92. package/dist/lib/utils.mjs.map +1 -1
  93. package/dist/lib/utils.test.d.ts +1 -0
  94. package/dist/lib/utils.test.mjs +0 -1
  95. package/dist/lib/utils.test.mjs.map +1 -1
  96. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  97. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  98. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +265 -8
  99. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  100. package/dist/types/autosuggestions-config/editing-api-config.mjs +81 -3
  101. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  102. package/dist/types/autosuggestions-config/index.mjs +327 -10
  103. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  104. package/dist/types/autosuggestions-config/insertions-api-config.mjs +75 -3
  105. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  106. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +83 -3
  107. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
  108. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  109. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  110. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  111. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  112. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +64 -3
  113. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  114. package/dist/types/base/autosuggestion-state.mjs +0 -2
  115. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  116. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  117. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  118. package/dist/types/base/base-autosuggestions-config.d.ts +55 -2
  119. package/dist/types/base/base-autosuggestions-config.mjs +26 -3
  120. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  121. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  122. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  123. package/dist/types/base/custom-editor.mjs +0 -2
  124. package/dist/types/base/custom-editor.mjs.map +1 -1
  125. package/dist/types/base/editor-autocomplete-state.mjs +17 -4
  126. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  127. package/dist/types/base/index.mjs +26 -4
  128. package/dist/types/base/index.mjs.map +1 -1
  129. package/dist/types/html-copilot-textarea-element.mjs +0 -2
  130. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  131. package/dist/types/index.mjs +328 -12
  132. package/dist/types/index.mjs.map +1 -1
  133. package/package.json +7 -7
  134. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +79 -45
  135. package/src/components/base-copilot-textarea/render-element.tsx +3 -5
  136. package/src/components/base-copilot-textarea/render-placeholder.tsx +2 -4
  137. package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +22 -3
  138. package/src/components/base-copilot-textarea/use-add-branding-css.tsx +2 -4
  139. package/src/components/copilot-textarea/copilot-textarea.tsx +14 -18
  140. package/src/components/hovering-toolbar/hovering-editor-provider.tsx +7 -5
  141. package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +14 -31
  142. package/src/components/hovering-toolbar/hovering-toolbar.tsx +4 -16
  143. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +11 -25
  144. package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +2 -7
  145. package/src/components/manual-ui/chip-with-icon.tsx +3 -12
  146. package/src/components/source-search-box/source-search-box.tsx +2 -12
  147. package/src/components/ui/button.tsx +6 -13
  148. package/src/components/ui/card.tsx +35 -65
  149. package/src/components/ui/command.tsx +8 -21
  150. package/src/components/ui/dialog.tsx +8 -29
  151. package/src/components/ui/label.tsx +3 -8
  152. package/src/components/ui/separator.tsx +13 -18
  153. package/src/components/ui/textarea.tsx +3 -4
  154. package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +13 -27
  155. package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +1 -5
  156. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -11
  157. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +5 -10
  158. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +15 -35
  159. package/src/hooks/misc/use-autosize-textarea.tsx +1 -4
  160. package/src/lib/debouncer.ts +1 -3
  161. package/src/lib/editor-to-text.ts +4 -7
  162. package/src/lib/get-text-around-cursor.ts +2 -14
  163. package/src/lib/retry.tsx +1 -1
  164. package/src/lib/slatejs-edits/add-autocompletions.ts +2 -2
  165. package/src/lib/slatejs-edits/clear-autocompletions.ts +1 -4
  166. package/src/lib/slatejs-edits/replace-text.ts +1 -1
  167. package/src/lib/slatejs-edits/with-partial-history.ts +4 -11
  168. package/src/lib/stream-promise-flatten.ts +1 -3
  169. package/src/lib/utils.ts +4 -8
  170. package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -7
  171. package/src/types/autosuggestions-config/autosuggestions-config.tsx +5 -18
  172. package/src/types/autosuggestions-config/editing-api-config.tsx +3 -5
  173. package/src/types/autosuggestions-config/insertions-api-config.tsx +2 -3
  174. package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +18 -26
  175. package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +1 -4
  176. package/src/types/autosuggestions-config/suggestions-api-config.tsx +2 -3
  177. package/src/types/base/autosuggestions-bare-function.ts +2 -2
  178. package/src/types/base/base-autosuggestions-config.tsx +80 -3
  179. package/src/types/base/editor-autocomplete-state.ts +1 -1
  180. package/dist/chunk-2NURR2DX.mjs +0 -47
  181. package/dist/chunk-2NURR2DX.mjs.map +0 -1
  182. package/dist/chunk-3L6CNVCE.mjs +0 -108
  183. package/dist/chunk-3L6CNVCE.mjs.map +0 -1
  184. package/dist/chunk-463BFNUP.mjs +0 -77
  185. package/dist/chunk-463BFNUP.mjs.map +0 -1
  186. package/dist/chunk-4HHYJGZE.mjs +0 -117
  187. package/dist/chunk-4HHYJGZE.mjs.map +0 -1
  188. package/dist/chunk-4LOLCQGR.mjs +0 -50
  189. package/dist/chunk-4LOLCQGR.mjs.map +0 -1
  190. package/dist/chunk-4S5ZJH3I.mjs +0 -18
  191. package/dist/chunk-4S5ZJH3I.mjs.map +0 -1
  192. package/dist/chunk-4UYKBG35.mjs +0 -57
  193. package/dist/chunk-4UYKBG35.mjs.map +0 -1
  194. package/dist/chunk-5EJ5XOGP.mjs +0 -22
  195. package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
  196. package/dist/chunk-5FO6ISW4.mjs +0 -3
  197. package/dist/chunk-5FO6ISW4.mjs.map +0 -1
  198. package/dist/chunk-6Z2ATUNY.mjs +0 -15
  199. package/dist/chunk-6Z2ATUNY.mjs.map +0 -1
  200. package/dist/chunk-AQHORK66.mjs +0 -49
  201. package/dist/chunk-AQHORK66.mjs.map +0 -1
  202. package/dist/chunk-AXN37AHC.mjs +0 -80
  203. package/dist/chunk-AXN37AHC.mjs.map +0 -1
  204. package/dist/chunk-CSGFJU3L.mjs +0 -65
  205. package/dist/chunk-CSGFJU3L.mjs.map +0 -1
  206. package/dist/chunk-DE5K76I2.mjs +0 -3
  207. package/dist/chunk-DE5K76I2.mjs.map +0 -1
  208. package/dist/chunk-F3MHL6ZY.mjs +0 -25
  209. package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
  210. package/dist/chunk-GCMQHIRF.mjs +0 -29
  211. package/dist/chunk-GCMQHIRF.mjs.map +0 -1
  212. package/dist/chunk-GIJ3JZ4P.mjs +0 -224
  213. package/dist/chunk-GIJ3JZ4P.mjs.map +0 -1
  214. package/dist/chunk-GUH3Y2H4.mjs +0 -19
  215. package/dist/chunk-GUH3Y2H4.mjs.map +0 -1
  216. package/dist/chunk-H4VKQGVU.mjs +0 -3
  217. package/dist/chunk-H4VKQGVU.mjs.map +0 -1
  218. package/dist/chunk-IU3WTXLQ.mjs +0 -3
  219. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  220. package/dist/chunk-IXJ2HCOA.mjs +0 -101
  221. package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
  222. package/dist/chunk-JAFCXEPU.mjs +0 -10
  223. package/dist/chunk-JAFCXEPU.mjs.map +0 -1
  224. package/dist/chunk-JHTAOLEW.mjs +0 -63
  225. package/dist/chunk-JHTAOLEW.mjs.map +0 -1
  226. package/dist/chunk-JYVC4AW3.mjs +0 -205
  227. package/dist/chunk-JYVC4AW3.mjs.map +0 -1
  228. package/dist/chunk-KCHYD3EB.mjs +0 -107
  229. package/dist/chunk-KCHYD3EB.mjs.map +0 -1
  230. package/dist/chunk-KGKLUWKW.mjs +0 -47
  231. package/dist/chunk-KGKLUWKW.mjs.map +0 -1
  232. package/dist/chunk-L7VVZH4Q.mjs +0 -3
  233. package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
  234. package/dist/chunk-LNAIMEB2.mjs +0 -34
  235. package/dist/chunk-LNAIMEB2.mjs.map +0 -1
  236. package/dist/chunk-MMVDU6DF.mjs +0 -3
  237. package/dist/chunk-MMVDU6DF.mjs.map +0 -1
  238. package/dist/chunk-MPME5BW2.mjs +0 -59
  239. package/dist/chunk-MPME5BW2.mjs.map +0 -1
  240. package/dist/chunk-MRXNTQOX.mjs +0 -55
  241. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  242. package/dist/chunk-ND5PXTAW.mjs +0 -17
  243. package/dist/chunk-ND5PXTAW.mjs.map +0 -1
  244. package/dist/chunk-NKW5OU2S.mjs +0 -33
  245. package/dist/chunk-NKW5OU2S.mjs.map +0 -1
  246. package/dist/chunk-O4MHJSK2.mjs +0 -21
  247. package/dist/chunk-O4MHJSK2.mjs.map +0 -1
  248. package/dist/chunk-O5OWT5GE.mjs +0 -114
  249. package/dist/chunk-O5OWT5GE.mjs.map +0 -1
  250. package/dist/chunk-OD7ZMOVE.mjs +0 -45
  251. package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
  252. package/dist/chunk-OELUUJZY.mjs +0 -16
  253. package/dist/chunk-OELUUJZY.mjs.map +0 -1
  254. package/dist/chunk-QJDMIGLU.mjs +0 -38
  255. package/dist/chunk-QJDMIGLU.mjs.map +0 -1
  256. package/dist/chunk-RQHOUUXQ.mjs +0 -29
  257. package/dist/chunk-RQHOUUXQ.mjs.map +0 -1
  258. package/dist/chunk-RR6OQGTI.mjs +0 -74
  259. package/dist/chunk-RR6OQGTI.mjs.map +0 -1
  260. package/dist/chunk-UHD44NC5.mjs +0 -101
  261. package/dist/chunk-UHD44NC5.mjs.map +0 -1
  262. package/dist/chunk-WADHCMPK.mjs +0 -3
  263. package/dist/chunk-WADHCMPK.mjs.map +0 -1
  264. package/dist/chunk-WJHSY5T6.mjs +0 -3
  265. package/dist/chunk-WJHSY5T6.mjs.map +0 -1
  266. package/dist/chunk-WJYQWL4I.mjs +0 -27
  267. package/dist/chunk-WJYQWL4I.mjs.map +0 -1
  268. package/dist/chunk-WLPYYGES.mjs +0 -109
  269. package/dist/chunk-WLPYYGES.mjs.map +0 -1
  270. package/dist/chunk-XHUMROEY.mjs +0 -91
  271. package/dist/chunk-XHUMROEY.mjs.map +0 -1
  272. package/dist/chunk-YQU7WG7T.mjs +0 -83
  273. package/dist/chunk-YQU7WG7T.mjs.map +0 -1
  274. package/dist/chunk-YTOPHPSG.mjs +0 -45
  275. package/dist/chunk-YTOPHPSG.mjs.map +0 -1
  276. package/dist/chunk-YW3REYX6.mjs +0 -23
  277. package/dist/chunk-YW3REYX6.mjs.map +0 -1
@@ -1,13 +1,329 @@
1
- import '../chunk-DE5K76I2.mjs';
2
- import '../chunk-5FO6ISW4.mjs';
3
- export { ChatlikeApiEndpoint } from '../chunk-QJDMIGLU.mjs';
4
- export { defaultAutosuggestionsConfig } from '../chunk-GUH3Y2H4.mjs';
5
- import '../chunk-AXN37AHC.mjs';
6
- import '../chunk-RR6OQGTI.mjs';
7
- import '../chunk-JHTAOLEW.mjs';
8
- import '../chunk-WADHCMPK.mjs';
9
- import '../chunk-WJHSY5T6.mjs';
10
- export { defaultBaseAutosuggestionsConfig } from '../chunk-6Z2ATUNY.mjs';
11
- import '../chunk-MRXNTQOX.mjs';
12
- //# sourceMappingURL=out.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ // src/types/base/base-autosuggestions-config.tsx
42
+ import { defaultCopilotContextCategories } from "@copilotkit/react-core";
43
+ var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
44
+ if (event.key === "k" && event.metaKey) {
45
+ return true;
46
+ }
47
+ return false;
48
+ };
49
+ var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
50
+ if (event.key === "Tab") {
51
+ return true;
52
+ }
53
+ return false;
54
+ };
55
+ var defaultBaseAutosuggestionsConfig = {
56
+ debounceTime: 250,
57
+ contextCategories: defaultCopilotContextCategories,
58
+ disableWhenEmpty: true,
59
+ disabled: false,
60
+ temporarilyDisableWhenMovingCursorWithoutChangingText: true,
61
+ shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
62
+ shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
63
+ };
64
+
65
+ // src/types/autosuggestions-config/suggestions-api-config.tsx
66
+ var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
67
+ return `You are a versatile writing assistant.
68
+
69
+ The user is writing some text.
70
+ The purpose is: "${textareaPurpose}"
71
+
72
+ Your job is to guess what the user will write next AS BEST YOU CAN.
73
+ Only guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.
74
+
75
+ Adjust yourself to the user's style and implied intent.
76
+
77
+ 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.
78
+ <TextAfterCursor>
79
+ <TextBeforeCursor>
80
+ <YourSuggestion>
81
+
82
+ If we need to add a whitespace character to the suggested text, make sure to explicitly add it in.
83
+
84
+ The following external context is also provided. Use it to help you make better suggestions!!!
85
+ \`\`\`
86
+ ${contextString}
87
+ \`\`\`
88
+ `;
89
+ };
90
+ var defaultSuggestionsFewShotMessages = [
91
+ {
92
+ role: "user",
93
+ name: "TextAfterCursor",
94
+ content: "While I was there I also picked up some apples, oranges, and bananas."
95
+ },
96
+ {
97
+ role: "user",
98
+ content: "This morning I woke up and went straight to the grocery store."
99
+ },
100
+ {
101
+ role: "assistant",
102
+ content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
103
+ },
104
+ {
105
+ role: "user",
106
+ name: "TextAfterCursor",
107
+ content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
108
+ },
109
+ {
110
+ role: "user",
111
+ name: "TextBeforeCursor",
112
+ 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;`
113
+ },
114
+ {
115
+ role: "assistant",
116
+ 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"; `
117
+ }
118
+ ];
119
+ var defaultSuggestionsApiConfig = {
120
+ makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
121
+ fewShotMessages: defaultSuggestionsFewShotMessages,
122
+ forwardedParams: void 0
123
+ };
124
+
125
+ // src/types/autosuggestions-config/insertions-api-config.tsx
126
+ var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
127
+ return `You are a versatile writing assistant.
128
+
129
+ The user is writing some text.
130
+ The purpose is: "${textareaPurpose}"
131
+
132
+ The following external context is also provided. Use it to help you make better suggestions!!!
133
+ \`\`\`
134
+ ${contextString}
135
+ \`\`\`
136
+
137
+ The user also provides you with a prompt for INSERTIONS into the text they are writing.
138
+ Your job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.
139
+ Only insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.
140
+
141
+ Adjust yourself to the user's style and implied intent.
142
+
143
+ 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.
144
+ <TextAfterCursor>
145
+ <TextBeforeCursor>
146
+ <InsertionPrompt>
147
+ <YourSuggestion>
148
+ `;
149
+ };
150
+ var defaultInsertionsFewShotMessages = [
151
+ {
152
+ role: "user",
153
+ name: "TextAfterCursor",
154
+ content: "While I was there I also picked up some apples, oranges, and bananas."
155
+ },
156
+ {
157
+ role: "user",
158
+ name: "TextBeforeCursor",
159
+ content: "This morning I woke up and went straight to the grocery store."
160
+ },
161
+ {
162
+ role: "user",
163
+ name: "InsertionPrompt",
164
+ content: "I bought a big watermelon"
165
+ },
166
+ {
167
+ role: "assistant",
168
+ content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
169
+ },
170
+ {
171
+ role: "user",
172
+ name: "TextAfterCursor",
173
+ content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
174
+ },
175
+ {
176
+ role: "user",
177
+ name: "TextBeforeCursor",
178
+ 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;`
179
+ },
180
+ {
181
+ role: "user",
182
+ name: "InsertionPrompt",
183
+ content: "add section about the optionholder's pro rata share"
184
+ },
185
+ {
186
+ role: "assistant",
187
+ 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"; `
188
+ }
189
+ ];
190
+ var defaultInsertionsApiConfig = {
191
+ makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
192
+ fewShotMessages: defaultInsertionsFewShotMessages,
193
+ forwardedParams: void 0
194
+ };
195
+
196
+ // src/types/autosuggestions-config/editing-api-config.tsx
197
+ var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
198
+ return `You are a versatile writing assistant.
199
+
200
+ The user is writing some text.
201
+ The purpose is: "${textareaPurpose}"
202
+
203
+ The following external context is also provided. Use it to help you make better suggestions!!!
204
+ \`\`\`
205
+ ${contextString}
206
+ \`\`\`
207
+
208
+ The user also provides you with a prompt for EDITING some text they are writing.
209
+ Your job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.
210
+
211
+ Adjust yourself to the user's style and implied intent.
212
+
213
+ The user will provide the following information; use this to infer the best relevant EDIT:
214
+ <TextBeforeCursor>
215
+ <TextToEdit>
216
+ <TextAfterCursor>
217
+ <EditingPrompt>
218
+
219
+ <YourEditSuggestion>
220
+ `;
221
+ };
222
+ var defaultEditingFewShotMessages = [
223
+ {
224
+ role: "user",
225
+ name: "TextBeforeCursor",
226
+ content: "This morning I woke up and went straight to the grocery store. "
227
+ },
228
+ {
229
+ role: "user",
230
+ name: "TextToEdit",
231
+ content: "While I was there I also picked up some apples, oranges, and bananas. "
232
+ },
233
+ {
234
+ role: "user",
235
+ name: "TextAfterCursor",
236
+ content: "The grocery store was having a sale on fruit, so I decided to stock up."
237
+ },
238
+ {
239
+ role: "user",
240
+ name: "EditingPrompt",
241
+ content: "I bought a big watermelon"
242
+ },
243
+ {
244
+ role: "assistant",
245
+ content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
246
+ },
247
+ {
248
+ role: "user",
249
+ name: "TextAfterCursor",
250
+ content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
251
+ },
252
+ {
253
+ role: "user",
254
+ name: "TextBeforeCursor",
255
+ 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;`
256
+ },
257
+ {
258
+ role: "user",
259
+ name: "InsertionPrompt",
260
+ content: "add section about the optionholder's pro rata share"
261
+ },
262
+ {
263
+ role: "assistant",
264
+ 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"; `
265
+ }
266
+ ];
267
+ var defaultEditingApiConfig = {
268
+ makeSystemPrompt: defaultEditingMakeSystemPrompt,
269
+ fewShotMessages: defaultEditingFewShotMessages,
270
+ forwardedParams: void 0
271
+ };
272
+
273
+ // src/types/autosuggestions-config/autosuggestions-config.tsx
274
+ import { defaultCopilotContextCategories as defaultCopilotContextCategories2 } from "@copilotkit/react-core";
275
+ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
276
+ contextCategories: defaultCopilotContextCategories2,
277
+ chatApiConfigs: {
278
+ suggestionsApiConfig: defaultSuggestionsApiConfig,
279
+ insertionApiConfig: defaultInsertionsApiConfig,
280
+ editingApiConfig: defaultEditingApiConfig
281
+ }
282
+ });
283
+
284
+ // src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx
285
+ import { copilotApiConfigExtrapolator } from "@copilotkit/react-core";
286
+ var ChatlikeApiEndpoint = class {
287
+ constructor(run) {
288
+ this.run = run;
289
+ }
290
+ /**
291
+ * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.
292
+ * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.
293
+ * @returns A new instance of ChatlikeApiEndpoint.
294
+ */
295
+ static fromCopilotApiConfig(copilotApiConfig) {
296
+ return new ChatlikeApiEndpoint(
297
+ (abortSignal, messages, forwardedProps) => __async(this, null, function* () {
298
+ const res = yield fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {
299
+ method: "POST",
300
+ headers: __spreadValues({}, copilotApiConfig.headers),
301
+ body: JSON.stringify(__spreadProps(__spreadValues(__spreadValues({}, forwardedProps), copilotApiConfig.body), {
302
+ messages
303
+ })),
304
+ signal: abortSignal
305
+ });
306
+ const bodySteram = res.body;
307
+ if (!bodySteram) {
308
+ throw new Error("The response body is empty.");
309
+ }
310
+ const stringStream = bodySteram.pipeThrough(new TextDecoderStream());
311
+ return stringStream;
312
+ })
313
+ );
314
+ }
315
+ /**
316
+ * Creates a fully customized instance of ChatlikeApiEndpoint.
317
+ * @param run - The implementation of the ChatlikeApiEndpointImpl interface.
318
+ * @returns A new instance of ChatlikeApiEndpoint .
319
+ */
320
+ static custom(run) {
321
+ return new ChatlikeApiEndpoint(run);
322
+ }
323
+ };
324
+ export {
325
+ ChatlikeApiEndpoint,
326
+ defaultAutosuggestionsConfig,
327
+ defaultBaseAutosuggestionsConfig
328
+ };
13
329
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
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","../../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.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: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === \"k\" && 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.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user also provides you with a prompt for INSERTIONS into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like 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\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.\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n<YourSuggestion>\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.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user also provides you with a prompt for EDITING some text they are writing. \nYour job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the following information; use this to infer the best relevant EDIT:\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 also 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 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 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 { ChatlikeApiEndpoint } from \".\";\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","import { CopilotApiConfig, copilotApiConfigExtrapolator } from \"@copilotkit/react-core\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static fromCopilotApiConfig(copilotApiConfig: CopilotApiConfig): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n ) => {\n const res = await fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {\n method: \"POST\",\n headers: {\n ...copilotApiConfig.headers,\n },\n body: JSON.stringify({\n ...forwardedProps,\n ...copilotApiConfig.body,\n messages: messages,\n }),\n signal: abortSignal,\n });\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n },\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,uCAAuC;AAyDhD,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAS;AACtC,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;;;AC5FO,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,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;;;AClEO,IAAM,oCAAsD,CACjE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeF;AAEO,IAAM,mCAA4D;AAAA,EACvE;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,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,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;;;AC7EO,IAAM,iCAAmD,CAC9D,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBF;AAEO,IAAM,gCAAyD;AAAA,EACpE;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;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,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;;;ACvFA,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;;;AC9BA,SAA2B,oCAAoC;AAexD,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAAuC;AACjD,SAAK,MAAM;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,qBAAqB,kBAAyD;AACnF,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM,MAAM,6BAA6B,gBAAgB,EAAE,iBAAiB;AAAA,UACtF,QAAQ;AAAA,UACR,SAAS,mBACJ,iBAAiB;AAAA,UAEtB,MAAM,KAAK,UAAU,gDAChB,iBACA,iBAAiB,OAFD;AAAA,YAGnB;AAAA,UACF,EAAC;AAAA,UACD,QAAQ;AAAA,QACV,CAAC;AAED,cAAM,aAAgD,IAAI;AAC1D,YAAI,CAAC,YAAY;AACf,gBAAM,IAAI,MAAM,6BAA6B;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,YAAY,IAAI,kBAAkB,CAAC;AAEnE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,OAAO,KAA4D;AACxE,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF;","names":["defaultCopilotContextCategories","defaultCopilotContextCategories"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.24.0",
7
+ "version": "0.26.0-alpha.0",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -31,11 +31,11 @@
31
31
  "react": "^18.2.0",
32
32
  "tailwindcss": "^3.3.0",
33
33
  "ts-jest": "^29.1.1",
34
- "tsup": "^6.1.3",
35
- "typescript": "^4.9.4",
34
+ "tsup": "^6.7.0",
35
+ "typescript": "^5.1.3",
36
36
  "eslint-config-custom": "0.2.0",
37
- "tailwind-config": "0.1.0",
38
- "tsconfig": "0.5.0"
37
+ "tsconfig": "0.6.0-alpha.0",
38
+ "tailwind-config": "0.1.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "@emotion/css": "^11.11.2",
@@ -46,7 +46,7 @@
46
46
  "@radix-ui/react-label": "^2.0.2",
47
47
  "@radix-ui/react-separator": "^1.0.3",
48
48
  "@radix-ui/react-slot": "^1.0.2",
49
- "ai": "^2.2.12",
49
+ "ai": "^2.2.23",
50
50
  "class-variance-authority": "^0.6.1",
51
51
  "clsx": "^1.2.1",
52
52
  "cmdk": "^0.2.0",
@@ -59,7 +59,7 @@
59
59
  "slate-history": "^0.93.0",
60
60
  "slate-react": "^0.98.1",
61
61
  "tailwind-merge": "^1.13.2",
62
- "@copilotkit/react-core": "0.13.0"
62
+ "@copilotkit/react-core": "0.15.0-alpha.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsup --treeshake",
@@ -12,10 +12,7 @@ import {
12
12
  import { addAutocompletionsToEditor } from "../../lib/slatejs-edits/add-autocompletions";
13
13
  import { clearAutocompletionsFromEditor } from "../../lib/slatejs-edits/clear-autocompletions";
14
14
  import { replaceEditorText } from "../../lib/slatejs-edits/replace-text";
15
- import {
16
- BaseAutosuggestionsConfig,
17
- defaultBaseAutosuggestionsConfig,
18
- } from "../../types/base";
15
+ import { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from "../../types/base";
19
16
  import { AutosuggestionState } from "../../types/base/autosuggestion-state";
20
17
  import { BaseCopilotTextareaProps } from "../../types/base/base-copilot-textarea-props";
21
18
  import "./base-copilot-textarea.css";
@@ -30,27 +27,72 @@ import {
30
27
  import { EditorAutocompleteState } from "../../types/base/editor-autocomplete-state";
31
28
  import { TrackerTextEditedSinceLastCursorMovement } from "./track-cursor-moved-since-last-text-change";
32
29
 
30
+ /**
31
+ * Purpose: to be used as the `ref` type for `CopilotTextarea` and `BaseCopilotTextarea`.
32
+ *
33
+ * This interface extends `HTMLElement`, and is the subset of `HTMLTextAreaElement` that "actually matters".
34
+ * It provides the core functionality that consumers of `HTMLTextAreaElement` need 99.9% of the time:
35
+ * - `value`: the current value of the textarea
36
+ * - `focus`: make the textarea focused
37
+ * - `blur`: make the textarea unfocused
38
+ */
33
39
  export interface HTMLCopilotTextAreaElement extends HTMLElement {
40
+ /**
41
+ * The current value of the textarea.
42
+ */
34
43
  value: string;
44
+
45
+ /**
46
+ * focus on the textarea
47
+ */
35
48
  focus: () => void;
49
+
50
+ /**
51
+ * unfocus the textarea.
52
+ *
53
+ * Called `blur` for syntactic compatibility with `HTMLTextAreaElement`.
54
+ */
36
55
  blur: () => void;
37
56
  }
38
57
 
58
+ /**
59
+ * Not intended for direct use. Use CopilotTextarea instead.
60
+ *
61
+ * The `BaseCopilotTextarea` includes the basic UX component,
62
+ * without the business logic / AI logic that makes the content useful and coherent.
63
+ *
64
+ * It is useful if you want to build your own backend, with fully custom business logic
65
+ * for figuring out which contnet to fill in.
66
+ */
67
+ export const BaseCopilotTextarea = React.forwardRef(
68
+ (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {
69
+ return (
70
+ <HoveringEditorProvider>
71
+ <BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />
72
+ </HoveringEditorProvider>
73
+ );
74
+ },
75
+ );
76
+
77
+ /**
78
+ * Not intended for direct use. Use `CopilotTextarea` instead.
79
+ *
80
+ * This is the private core of the `BaseCopilotTextarea` component.
81
+ * For practical purposes the implementation is cleaner assuming containment in a `HoveringEditorProviderContext`.
82
+ *
83
+ * Therefore we separate the core logic into this component,
84
+ * and wrap it in a `HoveringEditorProviderContext` in `BaseCopilotTextarea`.
85
+ */
39
86
  const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
40
- (
41
- props: BaseCopilotTextareaProps,
42
- ref: React.Ref<HTMLCopilotTextAreaElement>
43
- ): JSX.Element => {
87
+ (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {
44
88
  const autosuggestionsConfig: BaseAutosuggestionsConfig = {
45
89
  ...defaultBaseAutosuggestionsConfig,
46
90
  ...props.baseAutosuggestionsConfig,
47
91
  };
48
92
 
49
93
  const valueOnInitialRender = useMemo(() => props.value ?? "", []);
50
- const [lastKnownFullEditorText, setLastKnownFullEditorText] =
51
- useState(valueOnInitialRender);
52
- const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] =
53
- useState(false);
94
+ const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);
95
+ const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);
54
96
 
55
97
  // // When the editor text changes, we want to reset the `textEditedSinceLastCursorMovement` state.
56
98
  // useEffect(() => {
@@ -68,10 +110,8 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
68
110
 
69
111
  const editor = useCopilotTextareaEditor();
70
112
 
71
- const {
72
- isDisplayed: hoveringEditorIsDisplayed,
73
- setIsDisplayed: setHoveringEditorIsDisplayed,
74
- } = useHoveringEditorContext();
113
+ const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } =
114
+ useHoveringEditorContext();
75
115
 
76
116
  const insertText = useCallback(
77
117
  (autosuggestion: AutosuggestionState) => {
@@ -79,33 +119,43 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
79
119
  at: autosuggestion.point,
80
120
  });
81
121
  },
82
- [editor]
122
+ [editor],
83
123
  );
84
124
 
125
+ const shouldDisableAutosuggestions =
126
+ // textarea is manually disabled:
127
+ autosuggestionsConfig.disabled ||
128
+ // hovering editor is displayed:
129
+ hoveringEditorIsDisplayed ||
130
+ // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:
131
+ (cursorMovedSinceLastTextChange &&
132
+ autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText);
133
+
85
134
  const {
86
135
  currentAutocompleteSuggestion,
87
136
  onChangeHandler: onChangeHandlerForAutocomplete,
88
137
  onKeyDownHandler: onKeyDownHandlerForAutocomplete,
89
138
  } = useAutosuggestions(
90
139
  autosuggestionsConfig.debounceTime,
91
- autosuggestionsConfig.acceptAutosuggestionKey,
140
+ autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,
92
141
  autosuggestionsConfig.apiConfig.autosuggestionsFunction,
93
142
  insertText,
94
143
  autosuggestionsConfig.disableWhenEmpty,
95
- autosuggestionsConfig.disabled ||
96
- hoveringEditorIsDisplayed || // disable autosuggestions when the hovering editor is displayed
97
- (cursorMovedSinceLastTextChange &&
98
- autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText) // disable autosuggestions when the cursor has moved since the last text change
144
+ shouldDisableAutosuggestions,
99
145
  );
146
+
100
147
  const onKeyDownHandlerForHoveringEditor = useCallback(
101
148
  (event: React.KeyboardEvent<HTMLDivElement>) => {
102
- // if command-k, toggle the hovering editor
103
- if (event.key === "k" && event.metaKey) {
149
+ if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {
104
150
  event.preventDefault();
105
151
  setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);
106
152
  }
107
153
  },
108
- [hoveringEditorIsDisplayed, setHoveringEditorIsDisplayed]
154
+ [
155
+ hoveringEditorIsDisplayed,
156
+ setHoveringEditorIsDisplayed,
157
+ autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress,
158
+ ],
109
159
  );
110
160
 
111
161
  // sync autosuggestions state with the editor
@@ -115,7 +165,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
115
165
  addAutocompletionsToEditor(
116
166
  editor,
117
167
  currentAutocompleteSuggestion.text,
118
- currentAutocompleteSuggestion.point
168
+ currentAutocompleteSuggestion.point,
119
169
  );
120
170
  }
121
171
  }, [currentAutocompleteSuggestion]);
@@ -177,10 +227,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
177
227
  const baseClassName = "copilot-textarea";
178
228
  const brandingClass = disableBranding ? "no-branding" : "with-branding";
179
229
  const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
180
- const mergedClassName = twMerge(
181
- defaultTailwindClassName,
182
- className ?? ""
183
- );
230
+ const mergedClassName = twMerge(defaultTailwindClassName, className ?? "");
184
231
  return `${baseClassName} ${brandingClass} ${mergedClassName}`;
185
232
  })();
186
233
 
@@ -228,7 +275,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
228
275
  />
229
276
  </Slate>
230
277
  );
231
- }
278
+ },
232
279
  );
233
280
 
234
281
  // Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.
@@ -243,7 +290,7 @@ const BaseCopilotTextareaWithHoveringContext = React.forwardRef(
243
290
  //
244
291
  // If this proves problematic, we can always revisit this decision.
245
292
  function makeSemiFakeReactTextAreaEvent(
246
- currentText: string
293
+ currentText: string,
247
294
  ): React.ChangeEvent<HTMLTextAreaElement> {
248
295
  return {
249
296
  target: {
@@ -256,16 +303,3 @@ function makeSemiFakeReactTextAreaEvent(
256
303
  },
257
304
  } as React.ChangeEvent<HTMLTextAreaElement>;
258
305
  }
259
-
260
- export const BaseCopilotTextarea = React.forwardRef(
261
- (
262
- props: BaseCopilotTextareaProps,
263
- ref: React.Ref<HTMLCopilotTextAreaElement>
264
- ): JSX.Element => {
265
- return (
266
- <HoveringEditorProvider>
267
- <BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />
268
- </HoveringEditorProvider>
269
- );
270
- }
271
- );
@@ -3,16 +3,14 @@ import { RenderElementProps } from "slate-react";
3
3
  export type RenderElementFunction = (props: RenderElementProps) => JSX.Element;
4
4
 
5
5
  export function makeRenderElementFunction(
6
- suggestionsStyle: React.CSSProperties
6
+ suggestionsStyle: React.CSSProperties,
7
7
  ): RenderElementFunction {
8
8
  return (props: RenderElementProps) => {
9
9
  switch (props.element.type) {
10
10
  case "paragraph":
11
11
  return <DefaultElement {...props} />;
12
12
  case "suggestion":
13
- return (
14
- <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />
15
- );
13
+ return <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />;
16
14
  }
17
15
  };
18
16
  }
@@ -23,7 +21,7 @@ const DefaultElement = (props: RenderElementProps) => {
23
21
  const SuggestionElement = (
24
22
  props: RenderElementProps & {
25
23
  suggestionsStyle: React.CSSProperties;
26
- }
24
+ },
27
25
  ) => {
28
26
  return (
29
27
  <span