@copilotkit/react-textarea 0.19.0-alpha.7 → 0.19.0-alpha.8
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 +163 -160
- package/CHANGELOG.md +11 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1910 -33
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +52 -3
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +46 -3
- 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 +86 -4
- 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 +57 -3
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +2378 -45
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +22 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +125 -3
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +1055 -16
- 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 +761 -10
- 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 +774 -11
- 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/index.mjs +774 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.mjs +2379 -46
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +5 -6
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +356 -10
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +88 -4
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +53 -7
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +266 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +164 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +63 -4
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +50 -8
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +48 -7
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.mjs +0 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +168 -6
- 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 +168 -4
- 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.mjs +155 -5
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +145 -14
- 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 +199 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.mjs +2382 -48
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +51 -3
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +43 -3
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +109 -3
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +17 -3
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +23 -3
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +47 -3
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +71 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +253 -8
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +83 -3
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +309 -10
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +77 -3
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +77 -3
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +64 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +0 -2
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +11 -3
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.mjs +0 -2
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +17 -4
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +11 -4
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +0 -2
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.mjs +310 -12
- package/dist/types/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-2NURR2DX.mjs +0 -47
- package/dist/chunk-2NURR2DX.mjs.map +0 -1
- package/dist/chunk-2TQBFDO7.mjs +0 -19
- package/dist/chunk-2TQBFDO7.mjs.map +0 -1
- package/dist/chunk-4S5ZJH3I.mjs +0 -18
- package/dist/chunk-4S5ZJH3I.mjs.map +0 -1
- package/dist/chunk-5EJ5XOGP.mjs +0 -22
- package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
- package/dist/chunk-5FO6ISW4.mjs +0 -3
- package/dist/chunk-5FO6ISW4.mjs.map +0 -1
- package/dist/chunk-66BDXIX4.mjs +0 -76
- package/dist/chunk-66BDXIX4.mjs.map +0 -1
- package/dist/chunk-7XKICWEE.mjs +0 -44
- package/dist/chunk-7XKICWEE.mjs.map +0 -1
- package/dist/chunk-CSGFJU3L.mjs +0 -65
- package/dist/chunk-CSGFJU3L.mjs.map +0 -1
- package/dist/chunk-D7SEV5PR.mjs +0 -12
- package/dist/chunk-D7SEV5PR.mjs.map +0 -1
- package/dist/chunk-DE5K76I2.mjs +0 -3
- package/dist/chunk-DE5K76I2.mjs.map +0 -1
- package/dist/chunk-F3MHL6ZY.mjs +0 -25
- package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
- package/dist/chunk-FN7GDKKG.mjs +0 -29
- package/dist/chunk-FN7GDKKG.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -3
- package/dist/chunk-H4VKQGVU.mjs.map +0 -1
- package/dist/chunk-HRTFMM7P.mjs +0 -82
- package/dist/chunk-HRTFMM7P.mjs.map +0 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -3
- package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
- package/dist/chunk-IXJ2HCOA.mjs +0 -101
- package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
- package/dist/chunk-JAFCXEPU.mjs +0 -10
- package/dist/chunk-JAFCXEPU.mjs.map +0 -1
- package/dist/chunk-JHTAOLEW.mjs +0 -63
- package/dist/chunk-JHTAOLEW.mjs.map +0 -1
- package/dist/chunk-K2AVA67P.mjs +0 -57
- package/dist/chunk-K2AVA67P.mjs.map +0 -1
- package/dist/chunk-KCHYD3EB.mjs +0 -107
- package/dist/chunk-KCHYD3EB.mjs.map +0 -1
- package/dist/chunk-KGKLUWKW.mjs +0 -47
- package/dist/chunk-KGKLUWKW.mjs.map +0 -1
- package/dist/chunk-KIRROE2K.mjs +0 -37
- package/dist/chunk-KIRROE2K.mjs.map +0 -1
- package/dist/chunk-L7VVZH4Q.mjs +0 -3
- package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
- package/dist/chunk-LNAIMEB2.mjs +0 -34
- package/dist/chunk-LNAIMEB2.mjs.map +0 -1
- package/dist/chunk-MMVDU6DF.mjs +0 -3
- package/dist/chunk-MMVDU6DF.mjs.map +0 -1
- package/dist/chunk-MPME5BW2.mjs +0 -59
- package/dist/chunk-MPME5BW2.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-ND5PXTAW.mjs +0 -17
- package/dist/chunk-ND5PXTAW.mjs.map +0 -1
- package/dist/chunk-NKA6K7FW.mjs +0 -201
- package/dist/chunk-NKA6K7FW.mjs.map +0 -1
- package/dist/chunk-NKW5OU2S.mjs +0 -33
- package/dist/chunk-NKW5OU2S.mjs.map +0 -1
- package/dist/chunk-O5OWT5GE.mjs +0 -114
- package/dist/chunk-O5OWT5GE.mjs.map +0 -1
- package/dist/chunk-OD7ZMOVE.mjs +0 -45
- package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
- package/dist/chunk-OELUUJZY.mjs +0 -16
- package/dist/chunk-OELUUJZY.mjs.map +0 -1
- package/dist/chunk-OXPXFYUG.mjs +0 -111
- package/dist/chunk-OXPXFYUG.mjs.map +0 -1
- package/dist/chunk-RQHOUUXQ.mjs +0 -29
- package/dist/chunk-RQHOUUXQ.mjs.map +0 -1
- package/dist/chunk-U5AJ5PBH.mjs +0 -107
- package/dist/chunk-U5AJ5PBH.mjs.map +0 -1
- package/dist/chunk-UHD44NC5.mjs +0 -101
- package/dist/chunk-UHD44NC5.mjs.map +0 -1
- package/dist/chunk-WADHCMPK.mjs +0 -3
- package/dist/chunk-WADHCMPK.mjs.map +0 -1
- package/dist/chunk-WJHSY5T6.mjs +0 -3
- package/dist/chunk-WJHSY5T6.mjs.map +0 -1
- package/dist/chunk-WJYQWL4I.mjs +0 -27
- package/dist/chunk-WJYQWL4I.mjs.map +0 -1
- package/dist/chunk-XA7M72ZO.mjs +0 -106
- package/dist/chunk-XA7M72ZO.mjs.map +0 -1
- package/dist/chunk-XHUMROEY.mjs +0 -91
- package/dist/chunk-XHUMROEY.mjs.map +0 -1
- package/dist/chunk-XYXKONR4.mjs +0 -501
- package/dist/chunk-XYXKONR4.mjs.map +0 -1
- package/dist/chunk-YQU7WG7T.mjs +0 -83
- package/dist/chunk-YQU7WG7T.mjs.map +0 -1
- package/dist/chunk-YTOPHPSG.mjs +0 -45
- package/dist/chunk-YTOPHPSG.mjs.map +0 -1
- package/dist/chunk-YW3REYX6.mjs +0 -23
- package/dist/chunk-YW3REYX6.mjs.map +0 -1
- package/dist/chunk-ZA3R6NZI.mjs +0 -20
- package/dist/chunk-ZA3R6NZI.mjs.map +0 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +0 -13
- package/dist/components/base-copilot-textarea/render-element.d.ts +0 -6
- package/dist/components/base-copilot-textarea/render-placeholder.d.ts +0 -6
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +0 -6
- package/dist/components/base-copilot-textarea/use-add-branding-css.d.ts +0 -3
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +0 -19
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +0 -13
- package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +0 -18
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +0 -8
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.d.ts +0 -29
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +0 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.ts +0 -3
- package/dist/components/index.d.ts +0 -14
- package/dist/components/manual-ui/chip-with-icon.d.ts +0 -10
- package/dist/components/source-search-box/source-search-box.d.ts +0 -17
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/card.d.ts +0 -10
- package/dist/components/ui/command.d.ts +0 -48
- package/dist/components/ui/dialog.d.ts +0 -18
- package/dist/components/ui/label.d.ts +0 -8
- package/dist/components/ui/separator.d.ts +0 -6
- package/dist/components/ui/textarea.d.ts +0 -7
- package/dist/context/index.d.ts +0 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +0 -13
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.d.ts +0 -8
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts +0 -7
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +0 -21
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +0 -22
- package/dist/hooks/misc/use-autosize-textarea.d.ts +0 -5
- package/dist/index.d.ts +0 -16
- package/dist/lib/debouncer.d.ts +0 -11
- package/dist/lib/editor-to-text.d.ts +0 -7
- package/dist/lib/get-text-around-cursor.d.ts +0 -15
- package/dist/lib/retry.d.ts +0 -3
- package/dist/lib/slatejs-edits/add-autocompletions.d.ts +0 -8
- package/dist/lib/slatejs-edits/clear-autocompletions.d.ts +0 -8
- package/dist/lib/slatejs-edits/replace-text.d.ts +0 -5
- package/dist/lib/slatejs-edits/with-partial-history.d.ts +0 -10
- package/dist/lib/stream-promise-flatten.d.ts +0 -3
- package/dist/lib/utils.d.ts +0 -10
- package/dist/lib/utils.test.d.ts +0 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +0 -22
- package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +0 -19
- package/dist/types/autosuggestions-config/editing-api-config.d.ts +0 -15
- package/dist/types/autosuggestions-config/index.d.ts +0 -11
- package/dist/types/autosuggestions-config/insertions-api-config.d.ts +0 -15
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.d.ts +0 -27
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.ts +0 -3
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.d.ts +0 -7
- package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +0 -15
- package/dist/types/base/autosuggestion-state.d.ts +0 -8
- package/dist/types/base/autosuggestions-bare-function.d.ts +0 -17
- package/dist/types/base/base-autosuggestions-config.d.ts +0 -14
- package/dist/types/base/base-copilot-textarea-props.d.ts +0 -40
- package/dist/types/base/custom-editor.d.ts +0 -29
- package/dist/types/base/editor-autocomplete-state.d.ts +0 -10
- package/dist/types/base/index.d.ts +0 -4
- package/dist/types/html-copilot-textarea-element.d.ts +0 -7
- package/dist/types/index.d.ts +0 -14
|
@@ -1,17 +1,1056 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
54
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
55
|
+
import { Transforms } from "slate";
|
|
56
|
+
import { useSlate, useSlateSelection } from "slate-react";
|
|
57
|
+
|
|
58
|
+
// src/hooks/misc/use-autosize-textarea.tsx
|
|
59
|
+
import { useEffect } from "react";
|
|
60
|
+
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (textAreaRef.current !== null) {
|
|
63
|
+
textAreaRef.current.style.height = "0px";
|
|
64
|
+
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
65
|
+
textAreaRef.current.style.height = scrollHeight + "px";
|
|
66
|
+
}
|
|
67
|
+
}, [textAreaRef, value]);
|
|
68
|
+
};
|
|
69
|
+
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
70
|
+
|
|
71
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
72
|
+
import { useState } from "react";
|
|
73
|
+
|
|
74
|
+
// src/components/ui/command.tsx
|
|
75
|
+
import * as React from "react";
|
|
76
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
77
|
+
|
|
78
|
+
// src/lib/utils.ts
|
|
79
|
+
import { clsx } from "clsx";
|
|
80
|
+
import { customAlphabet } from "nanoid";
|
|
81
|
+
import { twMerge } from "tailwind-merge";
|
|
82
|
+
function cn(...inputs) {
|
|
83
|
+
return twMerge(clsx(inputs));
|
|
84
|
+
}
|
|
85
|
+
var nanoid = customAlphabet(
|
|
86
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
87
|
+
7
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// src/components/ui/command.tsx
|
|
91
|
+
import { jsx } from "react/jsx-runtime";
|
|
92
|
+
"use client";
|
|
93
|
+
var Command = React.forwardRef((_a, ref) => {
|
|
94
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
95
|
+
return /* @__PURE__ */ jsx(CommandPrimitive, __spreadValues({
|
|
96
|
+
ref,
|
|
97
|
+
className: cn(
|
|
98
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
99
|
+
className
|
|
100
|
+
)
|
|
101
|
+
}, props));
|
|
102
|
+
});
|
|
103
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
104
|
+
var CommandInput = React.forwardRef((_a, ref) => {
|
|
105
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
106
|
+
return /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "flex items-center border-b px-3",
|
|
108
|
+
"cmdk-input-wrapper": "",
|
|
109
|
+
children: /* @__PURE__ */ jsx(CommandPrimitive.Input, __spreadValues({
|
|
110
|
+
ref,
|
|
111
|
+
className: cn(
|
|
112
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
113
|
+
className
|
|
114
|
+
)
|
|
115
|
+
}, props))
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
119
|
+
var CommandList = React.forwardRef((_a, ref) => {
|
|
120
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
121
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.List, __spreadValues({
|
|
122
|
+
ref,
|
|
123
|
+
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)
|
|
124
|
+
}, props));
|
|
125
|
+
});
|
|
126
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
127
|
+
var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(CommandPrimitive.Empty, __spreadValues({
|
|
128
|
+
ref,
|
|
129
|
+
className: "py-6 text-center text-sm"
|
|
130
|
+
}, props)));
|
|
131
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
132
|
+
var CommandGroup = React.forwardRef((_a, ref) => {
|
|
133
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
134
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Group, __spreadValues({
|
|
135
|
+
ref,
|
|
136
|
+
className: cn(
|
|
137
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
138
|
+
className
|
|
139
|
+
)
|
|
140
|
+
}, props));
|
|
141
|
+
});
|
|
142
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
143
|
+
var CommandSeparator = React.forwardRef((_a, ref) => {
|
|
144
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
145
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Separator, __spreadValues({
|
|
146
|
+
ref,
|
|
147
|
+
className: cn("-mx-1 h-px bg-border", className)
|
|
148
|
+
}, props));
|
|
149
|
+
});
|
|
150
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
151
|
+
var CommandItem = React.forwardRef((_a, ref) => {
|
|
152
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
153
|
+
return /* @__PURE__ */ jsx(CommandPrimitive.Item, __spreadValues({
|
|
154
|
+
ref,
|
|
155
|
+
className: cn(
|
|
156
|
+
"relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
157
|
+
className
|
|
158
|
+
)
|
|
159
|
+
}, props));
|
|
160
|
+
});
|
|
161
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
162
|
+
var CommandShortcut = (_a) => {
|
|
163
|
+
var _b = _a, {
|
|
164
|
+
className
|
|
165
|
+
} = _b, props = __objRest(_b, [
|
|
166
|
+
"className"
|
|
167
|
+
]);
|
|
168
|
+
return /* @__PURE__ */ jsx("span", __spreadValues({
|
|
169
|
+
className: cn(
|
|
170
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
171
|
+
className
|
|
172
|
+
)
|
|
173
|
+
}, props));
|
|
174
|
+
};
|
|
175
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
176
|
+
|
|
177
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
178
|
+
import {
|
|
179
|
+
Calculator,
|
|
180
|
+
Calendar,
|
|
181
|
+
Smile
|
|
182
|
+
} from "lucide-react";
|
|
183
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
184
|
+
function SourceSearchBox(props) {
|
|
185
|
+
const [selectedValue, setSelectedValue] = useState("");
|
|
186
|
+
return /* @__PURE__ */ jsxs(Command, {
|
|
187
|
+
className: "rounded-lg border shadow-md",
|
|
188
|
+
value: selectedValue,
|
|
189
|
+
onValueChange: (value) => {
|
|
190
|
+
setSelectedValue(value);
|
|
191
|
+
},
|
|
192
|
+
filter: (value, search) => {
|
|
193
|
+
if (props.searchTerm === "")
|
|
194
|
+
return 1;
|
|
195
|
+
if (value.startsWith(props.searchTerm))
|
|
196
|
+
return 1;
|
|
197
|
+
return 0;
|
|
198
|
+
},
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ jsx2(CommandInput, {
|
|
201
|
+
value: props.searchTerm,
|
|
202
|
+
className: "rounded-t-lg hidden",
|
|
203
|
+
placeholder: "Search for a command..."
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsxs(CommandList, {
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx2(CommandEmpty, {
|
|
208
|
+
children: "No results found."
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsx2(CommandGroup, {
|
|
211
|
+
heading: "Recents",
|
|
212
|
+
children: props.recentFiles.map((filePointer) => {
|
|
213
|
+
return /* @__PURE__ */ jsx2(CommandItem, {
|
|
214
|
+
value: filePointer.name,
|
|
215
|
+
onSelect: (value) => {
|
|
216
|
+
console.log(filePointer.name);
|
|
217
|
+
props.onSelectedFile(filePointer);
|
|
218
|
+
},
|
|
219
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
220
|
+
className: "flex flex-row gap-3 items-center",
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx2(Logo, {
|
|
223
|
+
size: "30px",
|
|
224
|
+
children: /* @__PURE__ */ jsx2(IconForFilePointer, {
|
|
225
|
+
filePointer,
|
|
226
|
+
className: "mx-auto my-auto"
|
|
227
|
+
})
|
|
228
|
+
}),
|
|
229
|
+
filePointer.name
|
|
230
|
+
]
|
|
231
|
+
})
|
|
232
|
+
}, `word-${filePointer.sourceApplication}.${filePointer.name}`);
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ jsxs(CommandGroup, {
|
|
236
|
+
heading: "Suggestions",
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
239
|
+
onSelect: (value) => {
|
|
240
|
+
console.log(value);
|
|
241
|
+
console.log(value);
|
|
242
|
+
},
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ jsx2(Calendar, {
|
|
245
|
+
className: "mr-2 h-4 w-4"
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ jsx2("span", {
|
|
248
|
+
children: "Calendar"
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ jsx2(Smile, {
|
|
255
|
+
className: "mr-2 h-4 w-4"
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ jsx2("span", {
|
|
258
|
+
children: "Search Emoji"
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
}),
|
|
262
|
+
/* @__PURE__ */ jsxs(CommandItem, {
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ jsx2(Calculator, {
|
|
265
|
+
className: "mr-2 h-4 w-4"
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ jsx2("span", {
|
|
268
|
+
children: "Calculator"
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ jsx2(CommandSeparator, {})
|
|
275
|
+
]
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function Logo({
|
|
281
|
+
children,
|
|
282
|
+
size = "30px"
|
|
283
|
+
}) {
|
|
284
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
285
|
+
className: "flex items-center justify-center",
|
|
286
|
+
style: { width: size, height: size },
|
|
287
|
+
children
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// src/components/ui/button.tsx
|
|
292
|
+
import * as React2 from "react";
|
|
293
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
294
|
+
import { cva } from "class-variance-authority";
|
|
295
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
296
|
+
var buttonVariants = cva(
|
|
297
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
298
|
+
{
|
|
299
|
+
variants: {
|
|
300
|
+
variant: {
|
|
301
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
302
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
303
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
304
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
305
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
306
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
307
|
+
},
|
|
308
|
+
size: {
|
|
309
|
+
default: "h-10 px-4 py-2",
|
|
310
|
+
sm: "h-9 rounded-md px-3",
|
|
311
|
+
lg: "h-11 rounded-md px-8",
|
|
312
|
+
icon: "h-10 w-10"
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
defaultVariants: {
|
|
316
|
+
variant: "default",
|
|
317
|
+
size: "default"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
var Button = React2.forwardRef(
|
|
322
|
+
(_a, ref) => {
|
|
323
|
+
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
324
|
+
const Comp = asChild ? Slot : "button";
|
|
325
|
+
return /* @__PURE__ */ jsx3(Comp, __spreadValues({
|
|
326
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
327
|
+
ref
|
|
328
|
+
}, props));
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
Button.displayName = "Button";
|
|
332
|
+
|
|
333
|
+
// src/components/ui/label.tsx
|
|
334
|
+
import * as React3 from "react";
|
|
335
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
336
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
337
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
338
|
+
"use client";
|
|
339
|
+
var labelVariants = cva2(
|
|
340
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
341
|
+
);
|
|
342
|
+
var Label = React3.forwardRef((_a, ref) => {
|
|
343
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
344
|
+
return /* @__PURE__ */ jsx4(LabelPrimitive.Root, __spreadValues({
|
|
345
|
+
ref,
|
|
346
|
+
className: cn(labelVariants(), className)
|
|
347
|
+
}, props));
|
|
348
|
+
});
|
|
349
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
350
|
+
|
|
351
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
352
|
+
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
353
|
+
import Chip from "@mui/material/Chip";
|
|
354
|
+
import Avatar from "@mui/material/Avatar";
|
|
355
|
+
|
|
356
|
+
// src/lib/stream-promise-flatten.ts
|
|
357
|
+
function streamPromiseFlatten(promise) {
|
|
358
|
+
return new ReadableStream({
|
|
359
|
+
start(controller) {
|
|
360
|
+
return __async(this, null, function* () {
|
|
361
|
+
try {
|
|
362
|
+
const stream = yield promise;
|
|
363
|
+
const reader = stream.getReader();
|
|
364
|
+
while (true) {
|
|
365
|
+
const { done, value } = yield reader.read();
|
|
366
|
+
if (done) {
|
|
367
|
+
controller.close();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
controller.enqueue(value);
|
|
371
|
+
}
|
|
372
|
+
} catch (error) {
|
|
373
|
+
controller.error(error);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
381
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
382
|
+
var HoveringInsertionPromptBoxCore = ({ performInsertion, state, insertionOrEditingFunction }) => {
|
|
383
|
+
const [editSuggestion, setEditSuggestion] = useState2("");
|
|
384
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = useState2(false);
|
|
385
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = useState2("");
|
|
386
|
+
const [generatingSuggestion, setGeneratingSuggestion] = useState2(null);
|
|
387
|
+
const adjustmentTextAreaRef = useRef(null);
|
|
388
|
+
const suggestionTextAreaRef = useRef(null);
|
|
389
|
+
const [filePointers, setFilePointers] = useState2([]);
|
|
390
|
+
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
391
|
+
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
392
|
+
useEffect2(() => {
|
|
393
|
+
var _a;
|
|
394
|
+
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
395
|
+
}, []);
|
|
396
|
+
useEffect2(() => {
|
|
397
|
+
if (!generatingSuggestion) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (generatingSuggestion.locked) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
setEditSuggestion("");
|
|
404
|
+
const reader = generatingSuggestion.getReader();
|
|
405
|
+
const read = () => __async(void 0, null, function* () {
|
|
406
|
+
setSuggestionIsLoading(true);
|
|
407
|
+
while (true) {
|
|
408
|
+
const { done, value } = yield reader.read();
|
|
409
|
+
if (done) {
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
setEditSuggestion((prev) => {
|
|
413
|
+
const newSuggestion = prev + value;
|
|
414
|
+
if (suggestionTextAreaRef.current) {
|
|
415
|
+
suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
|
|
416
|
+
}
|
|
417
|
+
return newSuggestion;
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
setSuggestionIsLoading(false);
|
|
421
|
+
});
|
|
422
|
+
read();
|
|
423
|
+
return () => {
|
|
424
|
+
const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
|
|
425
|
+
try {
|
|
426
|
+
yield reader.closed;
|
|
427
|
+
} catch (e) {
|
|
428
|
+
reader.releaseLock();
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
releaseLockIfNotClosed();
|
|
432
|
+
};
|
|
433
|
+
}, [generatingSuggestion]);
|
|
434
|
+
const begingGeneratingAdjustment = () => __async(void 0, null, function* () {
|
|
435
|
+
if (!adjustmentPrompt.trim()) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
let editorState2 = state.editorState;
|
|
439
|
+
if (editSuggestion !== "") {
|
|
440
|
+
editorState2.selectedText = editSuggestion;
|
|
441
|
+
}
|
|
442
|
+
const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
|
|
443
|
+
editorState2,
|
|
444
|
+
adjustmentPrompt,
|
|
445
|
+
new AbortController().signal
|
|
446
|
+
);
|
|
447
|
+
const adjustmentSuggestionTextStream = streamPromiseFlatten(
|
|
448
|
+
adjustmentSuggestionTextStreamPromise
|
|
449
|
+
);
|
|
450
|
+
setGeneratingSuggestion(adjustmentSuggestionTextStream);
|
|
451
|
+
});
|
|
452
|
+
const isLoading = suggestionIsLoading;
|
|
453
|
+
const textToEdit = editSuggestion || state.editorState.selectedText;
|
|
454
|
+
const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
|
|
455
|
+
const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
|
|
456
|
+
const AdjustmentPromptComponent = /* @__PURE__ */ jsxs2(Fragment, {
|
|
457
|
+
children: [
|
|
458
|
+
/* @__PURE__ */ jsx5(Label, {
|
|
459
|
+
className: "",
|
|
460
|
+
children: adjustmentLabel
|
|
461
|
+
}),
|
|
462
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
463
|
+
className: "relative w-full flex items-center",
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ jsx5("textarea", {
|
|
466
|
+
disabled: suggestionIsLoading,
|
|
467
|
+
ref: adjustmentTextAreaRef,
|
|
468
|
+
value: adjustmentPrompt,
|
|
469
|
+
onChange: (e) => setAdjustmentPrompt(e.target.value),
|
|
470
|
+
onKeyDown: (e) => {
|
|
471
|
+
if (e.key === "Enter" && e.shiftKey) {
|
|
472
|
+
e.preventDefault();
|
|
473
|
+
setAdjustmentPrompt(adjustmentPrompt + "\n");
|
|
474
|
+
} else if (e.key === "Enter") {
|
|
475
|
+
e.preventDefault();
|
|
476
|
+
begingGeneratingAdjustment();
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
placeholder,
|
|
480
|
+
style: { minHeight: "3rem" },
|
|
481
|
+
className: "w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]",
|
|
482
|
+
rows: 1
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ jsx5("button", {
|
|
485
|
+
onClick: begingGeneratingAdjustment,
|
|
486
|
+
className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
|
|
487
|
+
children: /* @__PURE__ */ jsx5("i", {
|
|
488
|
+
className: "material-icons",
|
|
489
|
+
children: "arrow_forward"
|
|
490
|
+
})
|
|
491
|
+
})
|
|
492
|
+
]
|
|
493
|
+
})
|
|
494
|
+
]
|
|
495
|
+
});
|
|
496
|
+
const SuggestionComponent = /* @__PURE__ */ jsxs2(Fragment, {
|
|
497
|
+
children: [
|
|
498
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
499
|
+
className: "flex justify-between items-end w-full",
|
|
500
|
+
children: [
|
|
501
|
+
/* @__PURE__ */ jsx5(Label, {
|
|
502
|
+
className: "mt-4",
|
|
503
|
+
children: "Suggested:"
|
|
504
|
+
}),
|
|
505
|
+
/* @__PURE__ */ jsx5("div", {
|
|
506
|
+
className: "ml-auto",
|
|
507
|
+
children: isLoading && /* @__PURE__ */ jsx5("div", {
|
|
508
|
+
className: "flex justify-center items-center",
|
|
509
|
+
children: /* @__PURE__ */ jsx5("div", {
|
|
510
|
+
className: "inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
|
|
511
|
+
role: "status",
|
|
512
|
+
children: /* @__PURE__ */ jsx5("span", {
|
|
513
|
+
className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]",
|
|
514
|
+
children: "Loading..."
|
|
515
|
+
})
|
|
516
|
+
})
|
|
517
|
+
})
|
|
518
|
+
})
|
|
519
|
+
]
|
|
520
|
+
}),
|
|
521
|
+
/* @__PURE__ */ jsx5("textarea", {
|
|
522
|
+
ref: suggestionTextAreaRef,
|
|
523
|
+
value: editSuggestion,
|
|
524
|
+
disabled: suggestionIsLoading,
|
|
525
|
+
onChange: (e) => setEditSuggestion(e.target.value),
|
|
526
|
+
className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
|
|
527
|
+
style: { overflow: "auto", maxHeight: "10em" }
|
|
528
|
+
})
|
|
529
|
+
]
|
|
530
|
+
});
|
|
531
|
+
const SubmitComponent = /* @__PURE__ */ jsx5("div", {
|
|
532
|
+
className: "flex w-full gap-4 justify-start",
|
|
533
|
+
children: /* @__PURE__ */ jsxs2(Button, {
|
|
534
|
+
className: " bg-green-700 text-white",
|
|
535
|
+
onClick: () => {
|
|
536
|
+
performInsertion(editSuggestion);
|
|
537
|
+
},
|
|
538
|
+
children: [
|
|
539
|
+
"Insert ",
|
|
540
|
+
/* @__PURE__ */ jsx5("i", {
|
|
541
|
+
className: "material-icons",
|
|
542
|
+
children: "check"
|
|
543
|
+
})
|
|
544
|
+
]
|
|
545
|
+
})
|
|
546
|
+
});
|
|
547
|
+
const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
|
|
548
|
+
const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
|
|
549
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
550
|
+
className: "w-full flex flex-col items-start relative gap-2",
|
|
551
|
+
children: [
|
|
552
|
+
AdjustmentPromptComponent,
|
|
553
|
+
filePointers.length > 0 && /* @__PURE__ */ jsx5(IncludedFilesPreview, {
|
|
554
|
+
includedFiles: filePointers,
|
|
555
|
+
setIncludedFiles: setFilePointers
|
|
556
|
+
}),
|
|
557
|
+
sourceSearchWord !== void 0 && /* @__PURE__ */ jsx5(SourceSearchBox, {
|
|
558
|
+
searchTerm: sourceSearchWord,
|
|
559
|
+
recentFiles: mockFiles,
|
|
560
|
+
onSelectedFile: (filePointer) => {
|
|
561
|
+
var _a;
|
|
562
|
+
setAdjustmentPrompt(
|
|
563
|
+
adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
|
|
564
|
+
);
|
|
565
|
+
setFilePointers((prev) => [...prev, filePointer]);
|
|
566
|
+
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
567
|
+
}
|
|
568
|
+
}),
|
|
569
|
+
generatingSuggestion ? SuggestionComponent : null,
|
|
570
|
+
generatingSuggestion ? SubmitComponent : null
|
|
571
|
+
]
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
var IncludedFilesPreview = ({
|
|
575
|
+
includedFiles,
|
|
576
|
+
setIncludedFiles
|
|
577
|
+
}) => {
|
|
578
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
579
|
+
className: "flex flex-col gap-2 mt-2",
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ jsx5(Label, {
|
|
582
|
+
className: "",
|
|
583
|
+
children: "Included context:"
|
|
584
|
+
}),
|
|
585
|
+
/* @__PURE__ */ jsx5("div", {
|
|
586
|
+
className: "flex flex-wrap gap-2",
|
|
587
|
+
children: includedFiles.map((filePointer, index) => {
|
|
588
|
+
return /* @__PURE__ */ jsx5(FileChipPreview, {
|
|
589
|
+
filePointer,
|
|
590
|
+
onDelete: () => {
|
|
591
|
+
setIncludedFiles(
|
|
592
|
+
(prev) => prev.filter((fp) => fp !== filePointer)
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
}, `file-${filePointer.sourceApplication}.${filePointer.name}`);
|
|
596
|
+
})
|
|
597
|
+
})
|
|
598
|
+
]
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
var FileChipPreview = ({
|
|
602
|
+
filePointer,
|
|
603
|
+
onDelete
|
|
604
|
+
}) => {
|
|
605
|
+
return /* @__PURE__ */ jsx5(Chip, {
|
|
606
|
+
label: filePointer.name,
|
|
607
|
+
onDelete,
|
|
608
|
+
avatar: /* @__PURE__ */ jsx5(Avatar, {
|
|
609
|
+
sx: { backgroundColor: "transparent" },
|
|
610
|
+
children: /* @__PURE__ */ jsx5(IconForFilePointer, {
|
|
611
|
+
filePointer,
|
|
612
|
+
className: "w-4 h-1 object-contain"
|
|
613
|
+
})
|
|
614
|
+
})
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
function IconForFilePointer({
|
|
618
|
+
filePointer,
|
|
619
|
+
className
|
|
620
|
+
}) {
|
|
621
|
+
if (filePointer.sourceApplication === "Salesforce") {
|
|
622
|
+
return /* @__PURE__ */ jsx5(IconSalesforce, {
|
|
623
|
+
className
|
|
624
|
+
});
|
|
625
|
+
} else if (filePointer.sourceApplication === "GoogleDocs") {
|
|
626
|
+
return /* @__PURE__ */ jsx5(IconGoogleDocs, {
|
|
627
|
+
className
|
|
628
|
+
});
|
|
629
|
+
} else {
|
|
630
|
+
return /* @__PURE__ */ jsx5(IconSalesforce, {
|
|
631
|
+
className
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function IconSalesforce(_a) {
|
|
636
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
637
|
+
return /* @__PURE__ */ jsxs2("svg", __spreadProps(__spreadValues({
|
|
638
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
639
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
640
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
641
|
+
viewBox: "0 0 273 191"
|
|
642
|
+
}, props), {
|
|
643
|
+
children: [
|
|
644
|
+
/* @__PURE__ */ jsx5("title", {
|
|
645
|
+
children: "Salesforce.com logo"
|
|
646
|
+
}),
|
|
647
|
+
/* @__PURE__ */ jsx5("defs", {
|
|
648
|
+
children: /* @__PURE__ */ jsx5("path", {
|
|
649
|
+
id: "a",
|
|
650
|
+
d: "M.06.5h272v190H.06z"
|
|
651
|
+
})
|
|
652
|
+
}),
|
|
653
|
+
/* @__PURE__ */ jsxs2("g", {
|
|
654
|
+
fillRule: "evenodd",
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx5("mask", {
|
|
657
|
+
id: "b",
|
|
658
|
+
fill: "#fff",
|
|
659
|
+
children: /* @__PURE__ */ jsx5("use", {
|
|
660
|
+
xlinkHref: "#a"
|
|
661
|
+
})
|
|
662
|
+
}),
|
|
663
|
+
/* @__PURE__ */ jsx5("path", {
|
|
664
|
+
fill: "#00A1E0",
|
|
665
|
+
d: "M113 21.3c8.78-9.14 21-14.8 34.5-14.8 18 0 33.6 10 42 24.9a58 58 0 0 1 23.7-5.05c32.4 0 58.7 26.5 58.7 59.2s-26.3 59.2-58.7 59.2c-3.96 0-7.82-.398-11.6-1.15-7.35 13.1-21.4 22-37.4 22a42.7 42.7 0 0 1-18.8-4.32c-7.45 17.5-24.8 29.8-45 29.8-21.1 0-39-13.3-45.9-32a45.1 45.1 0 0 1-9.34.972c-25.1 0-45.4-20.6-45.4-45.9 0-17 9.14-31.8 22.7-39.8a52.6 52.6 0 0 1-4.35-21c0-29.2 23.7-52.8 52.9-52.8 17.1 0 32.4 8.15 42 20.8",
|
|
666
|
+
mask: "url(#b)"
|
|
667
|
+
}),
|
|
668
|
+
/* @__PURE__ */ jsx5("path", {
|
|
669
|
+
fill: "#FFFFFE",
|
|
670
|
+
d: "M39.4 99.3c-.171.446.061.539.116.618.511.37 1.03.638 1.55.939 2.78 1.47 5.4 1.9 8.14 1.9 5.58 0 9.05-2.97 9.05-7.75v-.094c0-4.42-3.92-6.03-7.58-7.18l-.479-.155c-2.77-.898-5.16-1.68-5.16-3.5v-.093c0-1.56 1.4-2.71 3.56-2.71 2.4 0 5.26.799 7.09 1.81 0 0 .542.35.739-.173.107-.283 1.04-2.78 1.14-3.06.106-.293-.08-.514-.271-.628-2.1-1.28-5-2.15-8-2.15l-.557.002c-5.11 0-8.68 3.09-8.68 7.51v.095c0 4.66 3.94 6.18 7.62 7.23l.592.184c2.68.824 5 1.54 5 3.42v.094c0 1.73-1.51 3.02-3.93 3.02-.941 0-3.94-.016-7.19-2.07-.393-.229-.617-.394-.92-.579-.16-.097-.56-.272-.734.252l-1.1 3.06m81.7 0c-.171.446.061.539.118.618.509.37 1.03.638 1.55.939 2.78 1.47 5.4 1.9 8.14 1.9 5.58 0 9.05-2.97 9.05-7.75v-.094c0-4.42-3.91-6.03-7.58-7.18l-.479-.155c-2.77-.898-5.16-1.68-5.16-3.5v-.093c0-1.56 1.4-2.71 3.56-2.71 2.4 0 5.25.799 7.09 1.81 0 0 .542.35.74-.173.106-.283 1.04-2.78 1.13-3.06.107-.293-.08-.514-.27-.628-2.1-1.28-5-2.15-8-2.15l-.558.002c-5.11 0-8.68 3.09-8.68 7.51v.095c0 4.66 3.94 6.18 7.62 7.23l.591.184c2.69.824 5 1.54 5 3.42v.094c0 1.73-1.51 3.02-3.93 3.02-.943 0-3.95-.016-7.19-2.07-.393-.229-.623-.387-.921-.579-.101-.064-.572-.248-.733.252l-1.1 3.06m55.8-9.36c0 2.7-.504 4.83-1.49 6.34-.984 1.49-2.47 2.22-4.54 2.22s-3.55-.724-4.52-2.21c-.977-1.5-1.47-3.64-1.47-6.34 0-2.7.496-4.82 1.47-6.31.968-1.48 2.44-2.19 4.52-2.19s3.56.717 4.54 2.19c.992 1.49 1.49 3.61 1.49 6.31m4.66-5.01c-.459-1.55-1.17-2.91-2.12-4.05a10.151 10.151 0 0 0-3.58-2.72c-1.42-.665-3.1-1-5-1s-3.57.337-5 1c-1.42.664-2.63 1.58-3.58 2.72-.948 1.14-1.66 2.5-2.12 4.05-.455 1.54-.686 3.22-.686 5.01 0 1.79.231 3.47.686 5.01.457 1.55 1.17 2.91 2.12 4.05.951 1.14 2.16 2.05 3.58 2.7 1.43.648 3.11.978 5 .978 1.89 0 3.57-.33 4.99-.978 1.42-.648 2.63-1.56 3.58-2.7.949-1.14 1.66-2.5 2.12-4.05.454-1.54.685-3.22.685-5.01 0-1.78-.231-3.47-.685-5.01m38.3 12.8c-.153-.453-.595-.282-.595-.282-.677.259-1.4.499-2.17.619-.776.122-1.64.183-2.55.183-2.25 0-4.05-.671-5.33-2-1.29-1.33-2.01-3.47-2-6.37.007-2.64.645-4.62 1.79-6.14 1.13-1.5 2.87-2.28 5.17-2.28 1.92 0 3.39.223 4.93.705 0 0 .365.159.54-.322.409-1.13.711-1.94 1.15-3.18.124-.355-.18-.505-.291-.548-.604-.236-2.03-.623-3.11-.786-1.01-.154-2.18-.234-3.5-.234-1.96 0-3.7.335-5.19.999-1.49.663-2.75 1.58-3.75 2.72-1 1.14-1.76 2.5-2.27 4.05-.505 1.54-.76 3.23-.76 5.02 0 3.86 1.04 6.99 3.1 9.28 2.06 2.3 5.16 3.46 9.2 3.46 2.39 0 4.84-.483 6.6-1.18 0 0 .336-.162.19-.554l-1.15-3.16m8.15-10.4c.223-1.5.634-2.75 1.28-3.72.967-1.48 2.44-2.29 4.51-2.29s3.44.814 4.42 2.29c.65.975.934 2.27 1.04 3.72l-11.3-.002zm15.7-3.3c-.397-1.49-1.38-3-2.02-3.69-1.02-1.09-2.01-1.86-3-2.28a11.5 11.5 0 0 0-4.52-.917c-1.97 0-3.76.333-5.21 1.01-1.45.682-2.67 1.61-3.63 2.77-.959 1.16-1.68 2.53-2.14 4.1-.46 1.55-.692 3.25-.692 5.03 0 1.82.241 3.51.715 5.04.479 1.54 1.25 2.89 2.29 4.01 1.04 1.13 2.37 2.01 3.97 2.63 1.59.615 3.52.934 5.73.927 4.56-.015 6.96-1.03 7.94-1.58.175-.098.34-.267.134-.754l-1.03-2.89c-.158-.431-.594-.275-.594-.275-1.13.422-2.73 1.18-6.48 1.17-2.45-.004-4.26-.727-5.4-1.86-1.16-1.16-1.74-2.85-1.83-5.25l15.8.012s.416-.004.459-.41c.017-.168.541-3.24-.471-6.79zm-142 3.3c.223-1.5.635-2.75 1.28-3.72.968-1.48 2.44-2.29 4.51-2.29s3.44.814 4.42 2.29c.649.975.933 2.27 1.04 3.72l-11.3-.002zm15.7-3.3c-.396-1.49-1.38-3-2.02-3.69-1.02-1.09-2.01-1.86-3-2.28a11.5 11.5 0 0 0-4.52-.917c-1.97 0-3.76.333-5.21 1.01-1.45.682-2.67 1.61-3.63 2.77-.957 1.16-1.68 2.53-2.14 4.1-.459 1.55-.69 3.25-.69 5.03 0 1.82.239 3.51.716 5.04.478 1.54 1.25 2.89 2.28 4.01 1.04 1.13 2.37 2.01 3.97 2.63 1.59.615 3.51.934 5.73.927 4.56-.015 6.96-1.03 7.94-1.58.174-.098.34-.267.133-.754l-1.03-2.89c-.159-.431-.595-.275-.595-.275-1.13.422-2.73 1.18-6.48 1.17-2.44-.004-4.26-.727-5.4-1.86-1.16-1.16-1.74-2.85-1.83-5.25l15.8.012s.416-.004.459-.41c.017-.168.541-3.24-.472-6.79zm-49.8 13.6c-.619-.494-.705-.615-.91-.936-.313-.483-.473-1.17-.473-2.05 0-1.38.46-2.38 1.41-3.05-.01.002 1.36-1.18 4.58-1.14a32 32 0 0 1 4.28.365v7.17h.002s-2 .431-4.26.567c-3.21.193-4.63-.924-4.62-.921zm6.28-11.1c-.64-.047-1.47-.07-2.46-.07-1.35 0-2.66.168-3.88.498-1.23.332-2.34.846-3.29 1.53a7.63 7.63 0 0 0-2.29 2.6c-.559 1.04-.844 2.26-.844 3.64 0 1.4.243 2.61.723 3.6a6.54 6.54 0 0 0 2.06 2.47c.877.638 1.96 1.11 3.21 1.39 1.24.283 2.64.426 4.18.426 1.62 0 3.23-.136 4.79-.399a95.1 95.1 0 0 0 3.97-.772c.526-.121 1.11-.28 1.11-.28.39-.099.36-.516.36-.516l-.009-14.4c0-3.16-.844-5.51-2.51-6.96-1.66-1.45-4.09-2.18-7.24-2.18-1.18 0-3.09.16-4.23.389 0 0-3.44.668-4.86 1.78 0 0-.312.192-.142.627l1.12 3c.139.389.518.256.518.256s.119-.047.259-.13c3.03-1.65 6.87-1.6 6.87-1.6 1.7 0 3.02.345 3.9 1.02.861.661 1.3 1.66 1.3 3.76v.667c-1.35-.196-2.6-.309-2.6-.309zm127-8.13a.428.428 0 0 0-.237-.568c-.269-.102-1.61-.385-2.64-.449-1.98-.124-3.08.21-4.07.654-.978.441-2.06 1.15-2.66 1.97l-.002-1.92c0-.264-.187-.477-.453-.477h-4.04c-.262 0-.452.213-.452.477v23.5a.48.48 0 0 0 .479.479h4.14a.479.479 0 0 0 .478-.479v-11.8c0-1.58.174-3.15.521-4.14.342-.979.807-1.76 1.38-2.32a4.79 4.79 0 0 1 1.95-1.17 7.68 7.68 0 0 1 2.12-.298c.825 0 1.73.212 1.73.212.304.034.473-.152.576-.426.271-.721 1.04-2.88 1.19-3.31"
|
|
671
|
+
}),
|
|
672
|
+
/* @__PURE__ */ jsx5("path", {
|
|
673
|
+
fill: "#FFFFFE",
|
|
674
|
+
d: "M162.201 67.548a13.258 13.258 0 0 0-1.559-.37 12.217 12.217 0 0 0-2.144-.166c-2.853 0-5.102.806-6.681 2.398-1.568 1.58-2.635 3.987-3.17 7.154l-.193 1.069h-3.581s-.437-.018-.529.459l-.588 3.28c-.041.314.094.51.514.508h3.486l-3.537 19.743c-.277 1.59-.594 2.898-.945 3.889-.346.978-.684 1.711-1.1 2.243-.403.515-.785.894-1.444 1.115-.544.183-1.17.267-1.856.267-.382 0-.89-.064-1.265-.139-.375-.074-.57-.158-.851-.276 0 0-.409-.156-.57.254-.131.335-1.06 2.89-1.17 3.206-.112.312.045.558.243.629.464.166.809.272 1.441.421.878.207 1.618.22 2.311.22 1.452 0 2.775-.204 3.872-.6 1.104-.399 2.065-1.094 2.915-2.035.919-1.015 1.497-2.078 2.05-3.528.547-1.437 1.013-3.221 1.386-5.3l3.554-20.109h5.196s.438.016.529-.459l.588-3.28c.041-.314-.093-.51-.515-.508h-5.043c.025-.114.254-1.888.833-3.558.247-.713.712-1.288 1.106-1.683a3.273 3.273 0 0 1 1.321-.822 5.48 5.48 0 0 1 1.693-.244c.475 0 .941.057 1.296.131.489.104.679.159.807.197.514.157.583.005.684-.244l1.206-3.312c.124-.356-.178-.506-.29-.55m-70.474 34.117c0 .264-.188.479-.452.479h-4.183c-.265 0-.453-.215-.453-.479V67.997c0-.263.188-.476.453-.476h4.183c.264 0 .452.213.452.476v33.668"
|
|
675
|
+
})
|
|
676
|
+
]
|
|
677
|
+
})
|
|
678
|
+
]
|
|
679
|
+
}));
|
|
680
|
+
}
|
|
681
|
+
function IconGoogleDocs(_a) {
|
|
682
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
683
|
+
return /* @__PURE__ */ jsxs2("svg", __spreadProps(__spreadValues({
|
|
684
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
685
|
+
xmlSpace: "preserve",
|
|
686
|
+
viewBox: "0 0 64 88"
|
|
687
|
+
}, props), {
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ jsx5("path", {
|
|
690
|
+
d: "M58 88H6c-3.3 0-6-2.7-6-6V6c0-3.3 2.7-6 6-6h36l22 22v60c0 3.3-2.7 6-6 6z",
|
|
691
|
+
style: {
|
|
692
|
+
fill: "#3086f6"
|
|
693
|
+
}
|
|
694
|
+
}),
|
|
695
|
+
/* @__PURE__ */ jsx5("path", {
|
|
696
|
+
d: "m42 0 22 22H42V0z",
|
|
697
|
+
style: {
|
|
698
|
+
fill: "#0c67d6"
|
|
699
|
+
}
|
|
700
|
+
}),
|
|
701
|
+
/* @__PURE__ */ jsx5("path", {
|
|
702
|
+
d: "M50 39H14v-5h36v5zm0 7H14v5h36v-5zM40 58H14v5h26v-5z",
|
|
703
|
+
style: {
|
|
704
|
+
fill: "#fdffff"
|
|
705
|
+
}
|
|
706
|
+
})
|
|
707
|
+
]
|
|
708
|
+
}));
|
|
709
|
+
}
|
|
710
|
+
var mockFiles = [
|
|
711
|
+
{
|
|
712
|
+
name: "CopilotTextarea README",
|
|
713
|
+
sourceApplication: "GoogleDocs",
|
|
714
|
+
getContents: () => __async(void 0, null, function* () {
|
|
715
|
+
return "some contents";
|
|
716
|
+
})
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: "prospecting call transcript",
|
|
720
|
+
sourceApplication: "Salesforce",
|
|
721
|
+
getContents: () => __async(void 0, null, function* () {
|
|
722
|
+
return "some contents";
|
|
723
|
+
})
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "customer feedback",
|
|
727
|
+
sourceApplication: "Zendesk",
|
|
728
|
+
getContents: () => __async(void 0, null, function* () {
|
|
729
|
+
return "some contents";
|
|
730
|
+
})
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
name: "product specifications",
|
|
734
|
+
sourceApplication: "Google Docs",
|
|
735
|
+
getContents: () => __async(void 0, null, function* () {
|
|
736
|
+
return "some contents";
|
|
737
|
+
})
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
name: "meeting minutes",
|
|
741
|
+
sourceApplication: "Microsoft Teams",
|
|
742
|
+
getContents: () => __async(void 0, null, function* () {
|
|
743
|
+
return "some contents";
|
|
744
|
+
})
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "project plan",
|
|
748
|
+
sourceApplication: "Trello",
|
|
749
|
+
getContents: () => __async(void 0, null, function* () {
|
|
750
|
+
return "some contents";
|
|
751
|
+
})
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
name: "code review comments",
|
|
755
|
+
sourceApplication: "Github",
|
|
756
|
+
getContents: () => __async(void 0, null, function* () {
|
|
757
|
+
return "some contents";
|
|
758
|
+
})
|
|
759
|
+
}
|
|
760
|
+
];
|
|
761
|
+
|
|
762
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
763
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
764
|
+
var HoveringInsertionPromptBox = (props) => {
|
|
765
|
+
return /* @__PURE__ */ jsx6("div", {
|
|
766
|
+
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
767
|
+
style: { width: "35rem" },
|
|
768
|
+
children: /* @__PURE__ */ jsx6(HoveringInsertionPromptBoxCore, {
|
|
769
|
+
state: {
|
|
770
|
+
editorState: props.editorState
|
|
771
|
+
},
|
|
772
|
+
performInsertion: props.performInsertion,
|
|
773
|
+
insertionOrEditingFunction: props.apiConfig.insertionOrEditingFunction
|
|
774
|
+
})
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
779
|
+
import { css, cx } from "@emotion/css";
|
|
780
|
+
import React5 from "react";
|
|
781
|
+
import ReactDOM from "react-dom";
|
|
782
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
783
|
+
var Button2 = React5.forwardRef(
|
|
784
|
+
(_a, ref) => {
|
|
785
|
+
var _b = _a, {
|
|
786
|
+
className,
|
|
787
|
+
active,
|
|
788
|
+
reversed
|
|
789
|
+
} = _b, props = __objRest(_b, [
|
|
790
|
+
"className",
|
|
791
|
+
"active",
|
|
792
|
+
"reversed"
|
|
793
|
+
]);
|
|
794
|
+
return /* @__PURE__ */ jsx7("span", __spreadProps(__spreadValues({}, props), {
|
|
795
|
+
ref,
|
|
796
|
+
className: cx(
|
|
797
|
+
className,
|
|
798
|
+
css`
|
|
799
|
+
cursor: pointer;
|
|
800
|
+
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
801
|
+
`
|
|
802
|
+
)
|
|
803
|
+
}));
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
var Icon = React5.forwardRef(
|
|
807
|
+
(_a, ref) => {
|
|
808
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
809
|
+
return /* @__PURE__ */ jsx7("span", __spreadProps(__spreadValues({}, props), {
|
|
810
|
+
ref,
|
|
811
|
+
className: cx(
|
|
812
|
+
"material-icons",
|
|
813
|
+
className,
|
|
814
|
+
css`
|
|
815
|
+
font-size: 18px;
|
|
816
|
+
vertical-align: text-bottom;
|
|
817
|
+
`
|
|
818
|
+
)
|
|
819
|
+
}));
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
var Menu = React5.forwardRef(
|
|
823
|
+
(_a, ref) => {
|
|
824
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
825
|
+
return /* @__PURE__ */ jsx7("div", __spreadProps(__spreadValues({}, props), {
|
|
826
|
+
"data-test-id": "menu",
|
|
827
|
+
ref,
|
|
828
|
+
className: cx(
|
|
829
|
+
className,
|
|
830
|
+
css`
|
|
831
|
+
& > * {
|
|
832
|
+
display: inline-block;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
& > * + * {
|
|
836
|
+
margin-left: 15px;
|
|
837
|
+
}
|
|
838
|
+
`
|
|
839
|
+
)
|
|
840
|
+
}));
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
var Portal = ({ children }) => {
|
|
844
|
+
return typeof document === "object" ? ReactDOM.createPortal(children, document.body) : null;
|
|
845
|
+
};
|
|
846
|
+
var Toolbar = React5.forwardRef(
|
|
847
|
+
(_a, ref) => {
|
|
848
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
849
|
+
return /* @__PURE__ */ jsx7(Menu, __spreadProps(__spreadValues({}, props), {
|
|
850
|
+
ref,
|
|
851
|
+
className: cx(
|
|
852
|
+
className,
|
|
853
|
+
css`
|
|
854
|
+
position: relative;
|
|
855
|
+
padding: 1px 18px 17px;
|
|
856
|
+
margin: 0 -20px;
|
|
857
|
+
border-bottom: 2px solid #eee;
|
|
858
|
+
margin-bottom: 20px;
|
|
859
|
+
`
|
|
860
|
+
)
|
|
861
|
+
}));
|
|
862
|
+
}
|
|
863
|
+
);
|
|
864
|
+
|
|
865
|
+
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
866
|
+
import { createContext, useState as useState3, useContext } from "react";
|
|
867
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
868
|
+
var HoveringEditorContext = createContext({
|
|
869
|
+
isDisplayed: false,
|
|
870
|
+
setIsDisplayed: () => {
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
var useHoveringEditorContext = () => useContext(HoveringEditorContext);
|
|
874
|
+
|
|
875
|
+
// src/lib/get-text-around-cursor.ts
|
|
876
|
+
import {
|
|
877
|
+
Editor,
|
|
878
|
+
Path,
|
|
879
|
+
Range,
|
|
880
|
+
Text,
|
|
881
|
+
Element,
|
|
882
|
+
Point
|
|
883
|
+
} from "slate";
|
|
884
|
+
function getTextAroundSelection(editor) {
|
|
885
|
+
const { selection } = editor;
|
|
886
|
+
if (!selection) {
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
const wellOrderedSelection = wellOrderedRange(selection);
|
|
890
|
+
const beforeRange = {
|
|
891
|
+
anchor: Editor.start(editor, []),
|
|
892
|
+
focus: wellOrderedSelection.anchor
|
|
893
|
+
};
|
|
894
|
+
const afterRange = {
|
|
895
|
+
anchor: wellOrderedSelection.focus,
|
|
896
|
+
focus: Editor.end(editor, [])
|
|
897
|
+
};
|
|
898
|
+
const before = extractTextWithNewlines(editor, beforeRange);
|
|
899
|
+
const after = extractTextWithNewlines(editor, afterRange);
|
|
900
|
+
const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);
|
|
901
|
+
return {
|
|
902
|
+
selection: wellOrderedSelection,
|
|
903
|
+
textBeforeCursor: before,
|
|
904
|
+
selectedText,
|
|
905
|
+
textAfterCursor: after
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
function getFullEditorTextWithNewlines(editor) {
|
|
909
|
+
const fullDocumentRange = {
|
|
910
|
+
anchor: Editor.start(editor, []),
|
|
911
|
+
focus: Editor.end(editor, [])
|
|
912
|
+
};
|
|
913
|
+
return extractTextWithNewlines(editor, fullDocumentRange);
|
|
914
|
+
}
|
|
915
|
+
function extractTextWithNewlines(editor, range) {
|
|
916
|
+
const voids = false;
|
|
917
|
+
const [start, end] = Range.edges(range);
|
|
918
|
+
let text = "";
|
|
919
|
+
let lastBlock = null;
|
|
920
|
+
for (const [node, path] of Editor.nodes(editor, {
|
|
921
|
+
at: range,
|
|
922
|
+
match: Text.isText,
|
|
923
|
+
voids
|
|
924
|
+
})) {
|
|
925
|
+
let t = node.text;
|
|
926
|
+
const [block] = Editor.above(editor, {
|
|
927
|
+
at: path,
|
|
928
|
+
match: (n) => Element.isElement(n) && n.type === "paragraph"
|
|
929
|
+
}) || [null];
|
|
930
|
+
if (lastBlock !== block && block) {
|
|
931
|
+
if (lastBlock) {
|
|
932
|
+
text += "\n";
|
|
933
|
+
}
|
|
934
|
+
lastBlock = block;
|
|
935
|
+
}
|
|
936
|
+
if (Path.equals(path, end.path)) {
|
|
937
|
+
t = t.slice(0, end.offset);
|
|
938
|
+
}
|
|
939
|
+
if (Path.equals(path, start.path)) {
|
|
940
|
+
t = t.slice(start.offset);
|
|
941
|
+
}
|
|
942
|
+
text += t;
|
|
943
|
+
}
|
|
944
|
+
return text;
|
|
945
|
+
}
|
|
946
|
+
function wellOrderedRange(range) {
|
|
947
|
+
const { anchor, focus } = range;
|
|
948
|
+
if (Point.isBefore(anchor, focus)) {
|
|
949
|
+
return range;
|
|
950
|
+
}
|
|
951
|
+
return {
|
|
952
|
+
anchor: focus,
|
|
953
|
+
focus: anchor
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
958
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
959
|
+
var HoveringToolbar = (props) => {
|
|
960
|
+
const ref = useRef2(null);
|
|
961
|
+
const editor = useSlate();
|
|
962
|
+
const selection = useSlateSelection();
|
|
963
|
+
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
964
|
+
const [isClient, setIsClient] = useState4(false);
|
|
965
|
+
useEffect3(() => {
|
|
966
|
+
setIsClient(true);
|
|
967
|
+
}, []);
|
|
968
|
+
useEffect3(() => {
|
|
969
|
+
const el = ref.current;
|
|
970
|
+
const { selection: selection2 } = editor;
|
|
971
|
+
if (!el) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
if (!selection2) {
|
|
975
|
+
el.removeAttribute("style");
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const domSelection = window.getSelection();
|
|
979
|
+
if (!domSelection) {
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const domRange = domSelection.getRangeAt(0);
|
|
983
|
+
const rect = domRange.getBoundingClientRect();
|
|
984
|
+
if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
const minGapFromEdge = 60;
|
|
988
|
+
const verticalOffsetFromCorner = 35;
|
|
989
|
+
const horizontalOffsetFromCorner = 15;
|
|
990
|
+
let top = rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;
|
|
991
|
+
if (top < minGapFromEdge) {
|
|
992
|
+
top = rect.bottom + window.scrollY + minGapFromEdge;
|
|
993
|
+
} else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {
|
|
994
|
+
top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;
|
|
995
|
+
}
|
|
996
|
+
let left = rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;
|
|
997
|
+
if (left < minGapFromEdge) {
|
|
998
|
+
left = minGapFromEdge;
|
|
999
|
+
} else if (left + el.offsetWidth > window.innerWidth - minGapFromEdge) {
|
|
1000
|
+
left = window.innerWidth - el.offsetWidth - minGapFromEdge;
|
|
1001
|
+
}
|
|
1002
|
+
el.style.opacity = "1";
|
|
1003
|
+
el.style.top = `${top}px`;
|
|
1004
|
+
el.style.left = `${left}px`;
|
|
1005
|
+
});
|
|
1006
|
+
useEffect3(() => {
|
|
1007
|
+
const handleClickOutside = (event) => {
|
|
1008
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
1009
|
+
setIsDisplayed(false);
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1013
|
+
return () => {
|
|
1014
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
1015
|
+
};
|
|
1016
|
+
}, [ref, setIsDisplayed]);
|
|
1017
|
+
if (!isClient) {
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
return /* @__PURE__ */ jsx9(Portal, {
|
|
1021
|
+
children: /* @__PURE__ */ jsx9(Menu, {
|
|
1022
|
+
ref,
|
|
1023
|
+
className: "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
|
|
1024
|
+
children: isDisplayed && selection && /* @__PURE__ */ jsx9(HoveringInsertionPromptBox, {
|
|
1025
|
+
editorState: editorState(editor, selection),
|
|
1026
|
+
apiConfig: props.apiConfig,
|
|
1027
|
+
closeWindow: () => {
|
|
1028
|
+
setIsDisplayed(false);
|
|
1029
|
+
},
|
|
1030
|
+
performInsertion: (insertedText) => {
|
|
1031
|
+
console.log("inserted text", insertedText);
|
|
1032
|
+
Transforms.delete(editor, { at: selection });
|
|
1033
|
+
Transforms.insertText(editor, insertedText, {
|
|
1034
|
+
at: selection
|
|
1035
|
+
});
|
|
1036
|
+
setIsDisplayed(false);
|
|
1037
|
+
}
|
|
1038
|
+
})
|
|
1039
|
+
})
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
function editorState(editor, selection) {
|
|
1043
|
+
const textAroundCursor = getTextAroundSelection(editor);
|
|
1044
|
+
if (textAroundCursor) {
|
|
1045
|
+
return textAroundCursor;
|
|
1046
|
+
}
|
|
1047
|
+
return {
|
|
1048
|
+
textBeforeCursor: getFullEditorTextWithNewlines(editor),
|
|
1049
|
+
textAfterCursor: "",
|
|
1050
|
+
selectedText: ""
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
export {
|
|
1054
|
+
HoveringToolbar
|
|
1055
|
+
};
|
|
17
1056
|
//# sourceMappingURL=hovering-toolbar.mjs.map
|