@copilotkit/react-textarea 0.28.0-alpha.7 → 0.28.0-alpha.9
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 +341 -379
- package/CHANGELOG.md +24 -0
- package/dist/chunk-224UKA7C.mjs +9 -4
- package/dist/chunk-224UKA7C.mjs.map +1 -1
- package/dist/chunk-2C7O2EVM.mjs +4 -4
- package/dist/chunk-2C7O2EVM.mjs.map +1 -1
- package/dist/chunk-2QDCE7PD.mjs +6 -3
- package/dist/chunk-2QDCE7PD.mjs.map +1 -1
- package/dist/chunk-3PQ7GSFE.mjs +4 -4
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -1
- package/dist/chunk-4NHVQZ67.mjs +6 -5
- package/dist/chunk-4NHVQZ67.mjs.map +1 -1
- package/dist/chunk-4OJ3H65F.mjs +5 -2
- package/dist/chunk-4OJ3H65F.mjs.map +1 -1
- package/dist/chunk-5J3UZV77.mjs +23 -11
- package/dist/chunk-5J3UZV77.mjs.map +1 -1
- package/dist/chunk-5UNJXFUO.mjs +4 -4
- package/dist/chunk-5UNJXFUO.mjs.map +1 -1
- package/dist/chunk-72P3KOHZ.mjs +17 -7
- package/dist/chunk-72P3KOHZ.mjs.map +1 -1
- package/dist/chunk-7LSRNPNI.mjs +4 -4
- package/dist/chunk-7LSRNPNI.mjs.map +1 -1
- package/dist/chunk-7SUZ6CXM.mjs +15 -6
- package/dist/chunk-7SUZ6CXM.mjs.map +1 -1
- package/dist/chunk-AZHILHKM.mjs +21 -8
- package/dist/chunk-AZHILHKM.mjs.map +1 -1
- package/dist/chunk-B6TKVDDY.mjs +58 -22
- package/dist/chunk-B6TKVDDY.mjs.map +1 -1
- package/dist/chunk-BBZ7AWOB.mjs +8 -4
- package/dist/chunk-BBZ7AWOB.mjs.map +1 -1
- package/dist/chunk-DE5K76I2.mjs +0 -2
- package/dist/chunk-DE5K76I2.mjs.map +1 -1
- package/dist/chunk-DRV2FOHZ.mjs +11 -6
- package/dist/chunk-DRV2FOHZ.mjs.map +1 -1
- package/dist/chunk-ECR45NSD.mjs +7 -4
- package/dist/chunk-ECR45NSD.mjs.map +1 -1
- package/dist/chunk-FJNUPSQK.mjs +16 -5
- package/dist/chunk-FJNUPSQK.mjs.map +1 -1
- package/dist/chunk-FP2EKU3L.mjs +4 -4
- package/dist/chunk-FP2EKU3L.mjs.map +1 -1
- package/dist/chunk-GQN2HYFJ.mjs +4 -4
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -2
- package/dist/chunk-H4VKQGVU.mjs.map +1 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -2
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
- package/dist/chunk-JJLQVT7S.mjs +6 -3
- package/dist/chunk-JJLQVT7S.mjs.map +1 -1
- package/dist/chunk-KDVMG3XF.mjs +5 -2
- package/dist/chunk-KDVMG3XF.mjs.map +1 -1
- package/dist/chunk-KFQZHRPJ.mjs +15 -8
- package/dist/chunk-KFQZHRPJ.mjs.map +1 -1
- package/dist/chunk-KNQIEOFP.mjs +3 -2
- package/dist/chunk-KNQIEOFP.mjs.map +1 -1
- package/dist/chunk-L7VVZH4Q.mjs +0 -2
- package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
- package/dist/chunk-LQ2OWQU7.mjs +11 -7
- package/dist/chunk-LQ2OWQU7.mjs.map +1 -1
- package/dist/chunk-LYB4B6MK.mjs +6 -5
- package/dist/chunk-LYB4B6MK.mjs.map +1 -1
- package/dist/chunk-M2DR4KVB.mjs +6 -3
- package/dist/chunk-M2DR4KVB.mjs.map +1 -1
- package/dist/chunk-MMVDU6DF.mjs +0 -2
- package/dist/chunk-MMVDU6DF.mjs.map +1 -1
- package/dist/chunk-MRXNTQOX.mjs +6 -2
- package/dist/chunk-MRXNTQOX.mjs.map +1 -1
- package/dist/chunk-P4QVFRLY.mjs +17 -7
- package/dist/chunk-P4QVFRLY.mjs.map +1 -1
- package/dist/chunk-PTZVE6NC.mjs +22 -8
- package/dist/chunk-PTZVE6NC.mjs.map +1 -1
- package/dist/chunk-QCPS6IYI.mjs +15 -6
- package/dist/chunk-QCPS6IYI.mjs.map +1 -1
- package/dist/chunk-RKQ6RTZM.mjs +5 -2
- package/dist/chunk-RKQ6RTZM.mjs.map +1 -1
- package/dist/chunk-RT4UTBH3.mjs +15 -6
- package/dist/chunk-RT4UTBH3.mjs.map +1 -1
- package/dist/chunk-RUV6NBIF.mjs +0 -2
- package/dist/chunk-RUV6NBIF.mjs.map +1 -1
- package/dist/chunk-SNQEBH5I.mjs +24 -10
- package/dist/chunk-SNQEBH5I.mjs.map +1 -1
- package/dist/chunk-SX6NY5FW.mjs +11 -6
- package/dist/chunk-SX6NY5FW.mjs.map +1 -1
- package/dist/chunk-T6MTDQZ7.mjs +4 -4
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -1
- package/dist/chunk-VB4VNCIQ.mjs +28 -12
- package/dist/chunk-VB4VNCIQ.mjs.map +1 -1
- package/dist/chunk-VPEH6V7T.mjs +12 -6
- package/dist/chunk-VPEH6V7T.mjs.map +1 -1
- package/dist/chunk-WADHCMPK.mjs +0 -2
- package/dist/chunk-WADHCMPK.mjs.map +1 -1
- package/dist/chunk-WFTAAA7R.mjs +16 -8
- package/dist/chunk-WFTAAA7R.mjs.map +1 -1
- package/dist/chunk-WJHSY5T6.mjs +0 -2
- package/dist/chunk-WJHSY5T6.mjs.map +1 -1
- package/dist/chunk-WTASPE2W.mjs +41 -22
- package/dist/chunk-WTASPE2W.mjs.map +1 -1
- package/dist/chunk-XW3ICO4S.mjs +10 -4
- package/dist/chunk-XW3ICO4S.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +379 -257
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +39 -35
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.js +32 -11
- package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +7 -3
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.js +29 -8
- package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +7 -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.js +44 -17
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +8 -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.js +29 -7
- package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +7 -3
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.js +414 -272
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +48 -44
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.js +35 -12
- package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +9 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js +66 -36
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +15 -3
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js +247 -179
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +22 -18
- 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.js +180 -129
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +16 -12
- 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.js +185 -131
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +17 -13
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +71 -55
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +11 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +185 -131
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +18 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.js +418 -273
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +52 -45
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.js +31 -9
- package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.js +104 -72
- package/dist/components/source-search-box/source-search-box.js.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +12 -6
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.js +56 -40
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/button.mjs +10 -4
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.js +70 -50
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/card.mjs +18 -7
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.js +139 -97
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/command.mjs +26 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.js +90 -69
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dialog.mjs +21 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.js +55 -40
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/label.mjs +9 -4
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.js +54 -39
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/separator.mjs +15 -8
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.js +50 -35
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/textarea.mjs +13 -7
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.js +17 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +43 -18
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +10 -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.js +50 -25
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +8 -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.js +62 -29
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +9 -5
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.js +17 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +35 -11
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -4
- 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.js +38 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -4
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.js +25 -7
- package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +7 -3
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.js +422 -275
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -49
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.js +27 -5
- package/dist/lib/debouncer.js.map +1 -1
- package/dist/lib/debouncer.mjs +7 -3
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.js +30 -8
- package/dist/lib/editor-to-text.js.map +1 -1
- package/dist/lib/editor-to-text.mjs +7 -3
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.js +49 -24
- package/dist/lib/get-text-around-cursor.js.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +13 -3
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.js +27 -4
- package/dist/lib/retry.js.map +1 -1
- package/dist/lib/retry.mjs +7 -3
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.js +29 -7
- package/dist/lib/slatejs-edits/add-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +7 -3
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.js +31 -9
- package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +7 -3
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.js +32 -10
- package/dist/lib/slatejs-edits/replace-text.js.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +7 -3
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.js +42 -19
- package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +9 -3
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.js +27 -5
- package/dist/lib/stream-promise-flatten.js.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +7 -3
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.js +44 -16
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs +17 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +1 -2
- package/dist/lib/utils.test.js.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.js +17 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.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.js +35 -9
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +12 -8
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.js +31 -6
- package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.js +35 -9
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +13 -9
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.js +31 -6
- package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +17 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.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.js +17 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.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.js +31 -6
- package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.js +17 -2
- package/dist/types/base/autosuggestion-state.js.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.js +17 -2
- package/dist/types/base/autosuggestions-bare-function.js.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.js +29 -7
- package/dist/types/base/base-autosuggestions-config.js.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +7 -3
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.js +17 -2
- package/dist/types/base/base-copilot-textarea-props.js.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.js +17 -2
- package/dist/types/base/custom-editor.js.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.js +32 -8
- package/dist/types/base/editor-autocomplete-state.js.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +8 -4
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.js +30 -6
- package/dist/types/base/index.js.map +1 -1
- package/dist/types/base/index.mjs +8 -4
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.js +17 -2
- package/dist/types/html-copilot-textarea-element.js.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +1 -2
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +18 -11
- package/dist/types/index.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -1,53 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React2 = require('react');
|
|
4
|
-
var slate = require('slate');
|
|
5
|
-
var slateReact = require('slate-react');
|
|
6
|
-
var tailwindMerge = require('tailwind-merge');
|
|
7
|
-
var clsx = require('clsx');
|
|
8
|
-
var nanoid = require('nanoid');
|
|
9
|
-
var slateHistory = require('slate-history');
|
|
10
|
-
var reactCore = require('@copilotkit/react-core');
|
|
11
|
-
var cmdk = require('cmdk');
|
|
12
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
-
var reactSlot = require('@radix-ui/react-slot');
|
|
14
|
-
var classVarianceAuthority = require('class-variance-authority');
|
|
15
|
-
var LabelPrimitive = require('@radix-ui/react-label');
|
|
16
|
-
var Chip = require('@mui/material/Chip/Chip.js');
|
|
17
|
-
var Avatar = require('@mui/material/Avatar/Avatar.js');
|
|
18
|
-
var css = require('@emotion/css');
|
|
19
|
-
var ReactDOM = require('react-dom');
|
|
20
|
-
|
|
21
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
-
|
|
23
|
-
function _interopNamespace(e) {
|
|
24
|
-
if (e && e.__esModule) return e;
|
|
25
|
-
var n = Object.create(null);
|
|
26
|
-
if (e) {
|
|
27
|
-
Object.keys(e).forEach(function (k) {
|
|
28
|
-
if (k !== 'default') {
|
|
29
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () { return e[k]; }
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
n.default = e;
|
|
38
|
-
return Object.freeze(n);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
42
|
-
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
|
|
43
|
-
var Chip__default = /*#__PURE__*/_interopDefault(Chip);
|
|
44
|
-
var Avatar__default = /*#__PURE__*/_interopDefault(Avatar);
|
|
45
|
-
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
46
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
47
3
|
var __defProp = Object.defineProperty;
|
|
48
4
|
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
49
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
50
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
51
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
52
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
53
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -75,6 +34,27 @@ var __objRest = (source, exclude) => {
|
|
|
75
34
|
}
|
|
76
35
|
return target;
|
|
77
36
|
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
78
58
|
var __async = (__this, __arguments, generator) => {
|
|
79
59
|
return new Promise((resolve, reject) => {
|
|
80
60
|
var fulfilled = (value) => {
|
|
@@ -96,6 +76,20 @@ var __async = (__this, __arguments, generator) => {
|
|
|
96
76
|
});
|
|
97
77
|
};
|
|
98
78
|
|
|
79
|
+
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
80
|
+
var base_copilot_textarea_exports = {};
|
|
81
|
+
__export(base_copilot_textarea_exports, {
|
|
82
|
+
BaseCopilotTextarea: () => BaseCopilotTextarea
|
|
83
|
+
});
|
|
84
|
+
module.exports = __toCommonJS(base_copilot_textarea_exports);
|
|
85
|
+
var import_react12 = __toESM(require("react"));
|
|
86
|
+
var import_slate10 = require("slate");
|
|
87
|
+
var import_slate_react5 = require("slate-react");
|
|
88
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
89
|
+
|
|
90
|
+
// src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
|
|
91
|
+
var import_react = require("react");
|
|
92
|
+
|
|
99
93
|
// src/lib/debouncer.ts
|
|
100
94
|
var Debouncer = class {
|
|
101
95
|
constructor(wait) {
|
|
@@ -123,10 +117,15 @@ var Debouncer = class {
|
|
|
123
117
|
};
|
|
124
118
|
}
|
|
125
119
|
};
|
|
120
|
+
|
|
121
|
+
// src/lib/utils.ts
|
|
122
|
+
var import_clsx = require("clsx");
|
|
123
|
+
var import_nanoid = require("nanoid");
|
|
124
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
126
125
|
function cn(...inputs) {
|
|
127
|
-
return
|
|
126
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
128
127
|
}
|
|
129
|
-
nanoid.customAlphabet(
|
|
128
|
+
var nanoid = (0, import_nanoid.customAlphabet)(
|
|
130
129
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
131
130
|
7
|
|
132
131
|
);
|
|
@@ -145,9 +144,9 @@ function areEqual_autocompleteState(prev, next) {
|
|
|
145
144
|
|
|
146
145
|
// src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
|
|
147
146
|
function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress, autosuggestionFunction, insertAutocompleteSuggestion, disableWhenEmpty, disabled) {
|
|
148
|
-
const [previousAutocompleteState, setPreviousAutocompleteState] =
|
|
149
|
-
const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] =
|
|
150
|
-
const awaitForAndAppendSuggestion =
|
|
147
|
+
const [previousAutocompleteState, setPreviousAutocompleteState] = (0, import_react.useState)(null);
|
|
148
|
+
const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = (0, import_react.useState)(null);
|
|
149
|
+
const awaitForAndAppendSuggestion = (0, import_react.useCallback)(
|
|
151
150
|
(editorAutocompleteState, abortSignal) => __async(this, null, function* () {
|
|
152
151
|
if (disabled) {
|
|
153
152
|
return;
|
|
@@ -166,17 +165,17 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
|
|
|
166
165
|
}),
|
|
167
166
|
[autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled]
|
|
168
167
|
);
|
|
169
|
-
const debouncedFunction =
|
|
168
|
+
const debouncedFunction = (0, import_react.useMemo)(
|
|
170
169
|
() => new Debouncer(debounceTime),
|
|
171
170
|
[debounceTime]
|
|
172
171
|
);
|
|
173
|
-
|
|
172
|
+
(0, import_react.useEffect)(() => {
|
|
174
173
|
return () => {
|
|
175
174
|
debouncedFunction.cancel();
|
|
176
175
|
setCurrentAutocompleteSuggestion(null);
|
|
177
176
|
};
|
|
178
177
|
}, [debouncedFunction, disabled]);
|
|
179
|
-
const onChange =
|
|
178
|
+
const onChange = (0, import_react.useCallback)(
|
|
180
179
|
(newEditorState) => {
|
|
181
180
|
const editorStateHasChanged = !nullableCompatibleEqualityCheck(
|
|
182
181
|
areEqual_autocompleteState,
|
|
@@ -202,7 +201,7 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
|
|
|
202
201
|
setCurrentAutocompleteSuggestion
|
|
203
202
|
]
|
|
204
203
|
);
|
|
205
|
-
const keyDownHandler =
|
|
204
|
+
const keyDownHandler = (0, import_react.useCallback)(
|
|
206
205
|
(event) => {
|
|
207
206
|
if (currentAutocompleteSuggestion) {
|
|
208
207
|
if (shouldAcceptAutosuggestionOnKeyPress(event)) {
|
|
@@ -225,6 +224,15 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
|
|
|
225
224
|
onKeyDownHandler: keyDownHandler
|
|
226
225
|
};
|
|
227
226
|
}
|
|
227
|
+
|
|
228
|
+
// src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
|
|
229
|
+
var import_react2 = require("react");
|
|
230
|
+
var import_slate2 = require("slate");
|
|
231
|
+
var import_slate_react = require("slate-react");
|
|
232
|
+
|
|
233
|
+
// src/lib/slatejs-edits/with-partial-history.ts
|
|
234
|
+
var import_slate = require("slate");
|
|
235
|
+
var import_slate_history = require("slate-history");
|
|
228
236
|
var withPartialHistory = (editor, shouldSave2) => {
|
|
229
237
|
const e = editor;
|
|
230
238
|
const { apply } = e;
|
|
@@ -235,10 +243,10 @@ var withPartialHistory = (editor, shouldSave2) => {
|
|
|
235
243
|
if (redos.length > 0) {
|
|
236
244
|
const batch = redos[redos.length - 1];
|
|
237
245
|
if (batch.selectionBefore) {
|
|
238
|
-
|
|
246
|
+
import_slate.Transforms.setSelection(e, batch.selectionBefore);
|
|
239
247
|
}
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
import_slate_history.HistoryEditor.withoutSaving(e, () => {
|
|
249
|
+
import_slate.Editor.withoutNormalizing(e, () => {
|
|
242
250
|
for (const op of batch.operations) {
|
|
243
251
|
e.apply(op);
|
|
244
252
|
}
|
|
@@ -253,14 +261,14 @@ var withPartialHistory = (editor, shouldSave2) => {
|
|
|
253
261
|
const { undos } = history;
|
|
254
262
|
if (undos.length > 0) {
|
|
255
263
|
const batch = undos[undos.length - 1];
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const inverseOps = batch.operations.map(
|
|
264
|
+
import_slate_history.HistoryEditor.withoutSaving(e, () => {
|
|
265
|
+
import_slate.Editor.withoutNormalizing(e, () => {
|
|
266
|
+
const inverseOps = batch.operations.map(import_slate.Operation.inverse).reverse();
|
|
259
267
|
for (const op of inverseOps) {
|
|
260
268
|
e.apply(op);
|
|
261
269
|
}
|
|
262
270
|
if (batch.selectionBefore) {
|
|
263
|
-
|
|
271
|
+
import_slate.Transforms.setSelection(e, batch.selectionBefore);
|
|
264
272
|
}
|
|
265
273
|
});
|
|
266
274
|
});
|
|
@@ -273,8 +281,8 @@ var withPartialHistory = (editor, shouldSave2) => {
|
|
|
273
281
|
const { undos } = history;
|
|
274
282
|
const lastBatch = undos[undos.length - 1];
|
|
275
283
|
const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
|
|
276
|
-
let save =
|
|
277
|
-
let merge =
|
|
284
|
+
let save = import_slate_history.HistoryEditor.isSaving(e);
|
|
285
|
+
let merge = import_slate_history.HistoryEditor.isMerging(e);
|
|
278
286
|
if (save == null) {
|
|
279
287
|
save = shouldSave2(op, lastOp);
|
|
280
288
|
}
|
|
@@ -310,10 +318,10 @@ var withPartialHistory = (editor, shouldSave2) => {
|
|
|
310
318
|
return e;
|
|
311
319
|
};
|
|
312
320
|
var shouldMerge = (op, prev) => {
|
|
313
|
-
if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length &&
|
|
321
|
+
if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && import_slate.Path.equals(op.path, prev.path)) {
|
|
314
322
|
return true;
|
|
315
323
|
}
|
|
316
|
-
if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset &&
|
|
324
|
+
if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && import_slate.Path.equals(op.path, prev.path)) {
|
|
317
325
|
return true;
|
|
318
326
|
}
|
|
319
327
|
return false;
|
|
@@ -328,10 +336,10 @@ var defaultShouldSave = (op, prev) => {
|
|
|
328
336
|
// src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
|
|
329
337
|
var shouldSave = (op, prev) => {
|
|
330
338
|
const excludedNodeType = "suggestion";
|
|
331
|
-
if (op.type === "insert_node" &&
|
|
339
|
+
if (op.type === "insert_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
|
|
332
340
|
return false;
|
|
333
341
|
}
|
|
334
|
-
if (op.type === "remove_node" &&
|
|
342
|
+
if (op.type === "remove_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
|
|
335
343
|
return false;
|
|
336
344
|
}
|
|
337
345
|
if (op.type === "set_node" && "type" in op.newProperties && op.newProperties.type === excludedNodeType) {
|
|
@@ -346,11 +354,11 @@ var shouldSave = (op, prev) => {
|
|
|
346
354
|
if (op.type === "split_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
|
|
347
355
|
return false;
|
|
348
356
|
}
|
|
349
|
-
return defaultShouldSave(op);
|
|
357
|
+
return defaultShouldSave(op, prev);
|
|
350
358
|
};
|
|
351
359
|
function useCopilotTextareaEditor() {
|
|
352
|
-
const editor =
|
|
353
|
-
const editor2 = withPartialHistory(
|
|
360
|
+
const editor = (0, import_react2.useMemo)(() => {
|
|
361
|
+
const editor2 = withPartialHistory((0, import_slate_react.withReact)((0, import_slate2.createEditor)()), shouldSave);
|
|
354
362
|
const { isVoid } = editor2;
|
|
355
363
|
editor2.isVoid = (element) => {
|
|
356
364
|
switch (element.type) {
|
|
@@ -382,19 +390,26 @@ function useCopilotTextareaEditor() {
|
|
|
382
390
|
}, []);
|
|
383
391
|
return editor;
|
|
384
392
|
}
|
|
393
|
+
|
|
394
|
+
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
395
|
+
var import_react3 = __toESM(require("react"));
|
|
396
|
+
var import_slate_react2 = require("slate-react");
|
|
397
|
+
|
|
398
|
+
// src/lib/get-text-around-cursor.ts
|
|
399
|
+
var import_slate3 = require("slate");
|
|
385
400
|
function getTextAroundCollapsedCursor(editor) {
|
|
386
401
|
const { selection } = editor;
|
|
387
|
-
if (!selection || !
|
|
402
|
+
if (!selection || !import_slate3.Range.isCollapsed(selection)) {
|
|
388
403
|
return null;
|
|
389
404
|
}
|
|
390
405
|
const cursorPoint = selection.anchor;
|
|
391
406
|
const beforeRange = {
|
|
392
|
-
anchor:
|
|
407
|
+
anchor: import_slate3.Editor.start(editor, []),
|
|
393
408
|
focus: cursorPoint
|
|
394
409
|
};
|
|
395
410
|
const afterRange = {
|
|
396
411
|
anchor: cursorPoint,
|
|
397
|
-
focus:
|
|
412
|
+
focus: import_slate3.Editor.end(editor, [])
|
|
398
413
|
};
|
|
399
414
|
const before = extractTextWithNewlines(editor, beforeRange);
|
|
400
415
|
const after = extractTextWithNewlines(editor, afterRange);
|
|
@@ -411,12 +426,12 @@ function getTextAroundSelection(editor) {
|
|
|
411
426
|
}
|
|
412
427
|
const wellOrderedSelection = wellOrderedRange(selection);
|
|
413
428
|
const beforeRange = {
|
|
414
|
-
anchor:
|
|
429
|
+
anchor: import_slate3.Editor.start(editor, []),
|
|
415
430
|
focus: wellOrderedSelection.anchor
|
|
416
431
|
};
|
|
417
432
|
const afterRange = {
|
|
418
433
|
anchor: wellOrderedSelection.focus,
|
|
419
|
-
focus:
|
|
434
|
+
focus: import_slate3.Editor.end(editor, [])
|
|
420
435
|
};
|
|
421
436
|
const before = extractTextWithNewlines(editor, beforeRange);
|
|
422
437
|
const after = extractTextWithNewlines(editor, afterRange);
|
|
@@ -430,25 +445,25 @@ function getTextAroundSelection(editor) {
|
|
|
430
445
|
}
|
|
431
446
|
function getFullEditorTextWithNewlines(editor) {
|
|
432
447
|
const fullDocumentRange = {
|
|
433
|
-
anchor:
|
|
434
|
-
focus:
|
|
448
|
+
anchor: import_slate3.Editor.start(editor, []),
|
|
449
|
+
focus: import_slate3.Editor.end(editor, [])
|
|
435
450
|
};
|
|
436
451
|
return extractTextWithNewlines(editor, fullDocumentRange);
|
|
437
452
|
}
|
|
438
453
|
function extractTextWithNewlines(editor, range) {
|
|
439
454
|
const voids = false;
|
|
440
|
-
const [start, end] =
|
|
455
|
+
const [start, end] = import_slate3.Range.edges(range);
|
|
441
456
|
let text = "";
|
|
442
457
|
let lastBlock = null;
|
|
443
|
-
for (const [node, path] of
|
|
458
|
+
for (const [node, path] of import_slate3.Editor.nodes(editor, {
|
|
444
459
|
at: range,
|
|
445
|
-
match:
|
|
460
|
+
match: import_slate3.Text.isText,
|
|
446
461
|
voids
|
|
447
462
|
})) {
|
|
448
463
|
let t = node.text;
|
|
449
|
-
const [block] =
|
|
464
|
+
const [block] = import_slate3.Editor.above(editor, {
|
|
450
465
|
at: path,
|
|
451
|
-
match: (n) =>
|
|
466
|
+
match: (n) => import_slate3.Element.isElement(n) && n.type === "paragraph"
|
|
452
467
|
}) || [null];
|
|
453
468
|
if (lastBlock !== block && block) {
|
|
454
469
|
if (lastBlock) {
|
|
@@ -456,10 +471,10 @@ function extractTextWithNewlines(editor, range) {
|
|
|
456
471
|
}
|
|
457
472
|
lastBlock = block;
|
|
458
473
|
}
|
|
459
|
-
if (
|
|
474
|
+
if (import_slate3.Path.equals(path, end.path)) {
|
|
460
475
|
t = t.slice(0, end.offset);
|
|
461
476
|
}
|
|
462
|
-
if (
|
|
477
|
+
if (import_slate3.Path.equals(path, start.path)) {
|
|
463
478
|
t = t.slice(start.offset);
|
|
464
479
|
}
|
|
465
480
|
text += t;
|
|
@@ -468,7 +483,7 @@ function extractTextWithNewlines(editor, range) {
|
|
|
468
483
|
}
|
|
469
484
|
function wellOrderedRange(range) {
|
|
470
485
|
const { anchor, focus } = range;
|
|
471
|
-
if (
|
|
486
|
+
if (import_slate3.Point.isBefore(anchor, focus)) {
|
|
472
487
|
return range;
|
|
473
488
|
}
|
|
474
489
|
return {
|
|
@@ -476,15 +491,18 @@ function wellOrderedRange(range) {
|
|
|
476
491
|
focus: anchor
|
|
477
492
|
};
|
|
478
493
|
}
|
|
494
|
+
|
|
495
|
+
// src/lib/slatejs-edits/replace-text.ts
|
|
496
|
+
var import_slate4 = require("slate");
|
|
479
497
|
function replaceEditorText(editor, newText) {
|
|
480
|
-
|
|
498
|
+
import_slate4.Transforms.delete(editor, {
|
|
481
499
|
at: {
|
|
482
|
-
anchor:
|
|
483
|
-
focus:
|
|
500
|
+
anchor: import_slate4.Editor.start(editor, []),
|
|
501
|
+
focus: import_slate4.Editor.end(editor, [])
|
|
484
502
|
}
|
|
485
503
|
});
|
|
486
504
|
if (newText && newText !== "") {
|
|
487
|
-
|
|
505
|
+
import_slate4.Transforms.insertNodes(
|
|
488
506
|
editor,
|
|
489
507
|
[
|
|
490
508
|
{
|
|
@@ -501,7 +519,7 @@ function replaceEditorText(editor, newText) {
|
|
|
501
519
|
|
|
502
520
|
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
503
521
|
function usePopulateCopilotTextareaRef(editor, ref) {
|
|
504
|
-
|
|
522
|
+
import_react3.default.useImperativeHandle(
|
|
505
523
|
ref,
|
|
506
524
|
() => {
|
|
507
525
|
class Combined {
|
|
@@ -554,10 +572,10 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
554
572
|
this.editor = editor2;
|
|
555
573
|
}
|
|
556
574
|
focus() {
|
|
557
|
-
|
|
575
|
+
import_slate_react2.ReactEditor.focus(this.editor);
|
|
558
576
|
}
|
|
559
577
|
blur() {
|
|
560
|
-
|
|
578
|
+
import_slate_react2.ReactEditor.blur(this.editor);
|
|
561
579
|
}
|
|
562
580
|
get value() {
|
|
563
581
|
return getFullEditorTextWithNewlines(this.editor);
|
|
@@ -566,7 +584,7 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
566
584
|
replaceEditorText(this.editor, value);
|
|
567
585
|
}
|
|
568
586
|
}
|
|
569
|
-
const editorHtmlElement =
|
|
587
|
+
const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
|
|
570
588
|
const customMethods = new CustomMethods(editor);
|
|
571
589
|
const combined = new Combined(customMethods, editorHtmlElement);
|
|
572
590
|
return new Proxy(combined, handler);
|
|
@@ -574,9 +592,12 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
574
592
|
[editor]
|
|
575
593
|
);
|
|
576
594
|
}
|
|
595
|
+
|
|
596
|
+
// src/lib/slatejs-edits/add-autocompletions.ts
|
|
597
|
+
var import_slate5 = require("slate");
|
|
577
598
|
function addAutocompletionsToEditor(editor, newSuggestion, point) {
|
|
578
599
|
const editorPosition = editor.selection;
|
|
579
|
-
|
|
600
|
+
import_slate5.Transforms.insertNodes(
|
|
580
601
|
editor,
|
|
581
602
|
[
|
|
582
603
|
{
|
|
@@ -594,21 +615,27 @@ function addAutocompletionsToEditor(editor, newSuggestion, point) {
|
|
|
594
615
|
editor.selection = editorPosition;
|
|
595
616
|
}
|
|
596
617
|
}
|
|
618
|
+
|
|
619
|
+
// src/lib/slatejs-edits/clear-autocompletions.ts
|
|
620
|
+
var import_slate6 = require("slate");
|
|
597
621
|
function clearAutocompletionsFromEditor(editor) {
|
|
598
622
|
const paths = [];
|
|
599
|
-
for (const [node, path] of
|
|
600
|
-
if (
|
|
623
|
+
for (const [node, path] of import_slate6.Node.nodes(editor)) {
|
|
624
|
+
if (import_slate6.Element.isElement(node) && node.type === "suggestion") {
|
|
601
625
|
paths.push(path);
|
|
602
626
|
}
|
|
603
627
|
}
|
|
604
628
|
for (const path of paths) {
|
|
605
629
|
try {
|
|
606
|
-
|
|
630
|
+
import_slate6.Transforms.removeNodes(editor, { at: path });
|
|
607
631
|
} catch (e) {
|
|
608
632
|
console.log("CopilotTextarea.clearAutocompletionsFromEditor: error removing node", e);
|
|
609
633
|
}
|
|
610
634
|
}
|
|
611
635
|
}
|
|
636
|
+
|
|
637
|
+
// src/types/base/base-autosuggestions-config.tsx
|
|
638
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
612
639
|
var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
|
|
613
640
|
if (event.key === "k" && event.metaKey) {
|
|
614
641
|
return true;
|
|
@@ -623,15 +650,23 @@ var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
|
|
|
623
650
|
};
|
|
624
651
|
var defaultBaseAutosuggestionsConfig = {
|
|
625
652
|
debounceTime: 250,
|
|
626
|
-
contextCategories:
|
|
653
|
+
contextCategories: import_react_core.defaultCopilotContextCategories,
|
|
627
654
|
disableWhenEmpty: true,
|
|
628
655
|
disabled: false,
|
|
629
656
|
temporarilyDisableWhenMovingCursorWithoutChangingText: true,
|
|
630
657
|
shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
|
|
631
658
|
shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
|
|
632
659
|
};
|
|
660
|
+
|
|
661
|
+
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
662
|
+
var import_react9 = require("react");
|
|
663
|
+
var import_slate7 = require("slate");
|
|
664
|
+
var import_slate_react3 = require("slate-react");
|
|
665
|
+
|
|
666
|
+
// src/hooks/misc/use-autosize-textarea.tsx
|
|
667
|
+
var import_react4 = require("react");
|
|
633
668
|
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
634
|
-
|
|
669
|
+
(0, import_react4.useEffect)(() => {
|
|
635
670
|
if (textAreaRef.current !== null) {
|
|
636
671
|
textAreaRef.current.style.height = "0px";
|
|
637
672
|
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
@@ -640,10 +675,18 @@ var useAutosizeTextArea = (textAreaRef, value) => {
|
|
|
640
675
|
}, [textAreaRef, value]);
|
|
641
676
|
};
|
|
642
677
|
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
643
|
-
|
|
678
|
+
|
|
679
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
680
|
+
var import_react5 = require("react");
|
|
681
|
+
|
|
682
|
+
// src/components/ui/command.tsx
|
|
683
|
+
var React2 = __toESM(require("react"));
|
|
684
|
+
var import_cmdk = require("cmdk");
|
|
685
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
686
|
+
var Command = React2.forwardRef((_a, ref) => {
|
|
644
687
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
645
|
-
return /* @__PURE__ */
|
|
646
|
-
|
|
688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
689
|
+
import_cmdk.Command,
|
|
647
690
|
__spreadValues({
|
|
648
691
|
ref,
|
|
649
692
|
className: cn(
|
|
@@ -653,11 +696,11 @@ var Command = React2__namespace.forwardRef((_a, ref) => {
|
|
|
653
696
|
}, props)
|
|
654
697
|
);
|
|
655
698
|
});
|
|
656
|
-
Command.displayName =
|
|
657
|
-
var CommandInput =
|
|
699
|
+
Command.displayName = import_cmdk.Command.displayName;
|
|
700
|
+
var CommandInput = React2.forwardRef((_a, ref) => {
|
|
658
701
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
659
|
-
return /* @__PURE__ */
|
|
660
|
-
|
|
702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
703
|
+
import_cmdk.Command.Input,
|
|
661
704
|
__spreadValues({
|
|
662
705
|
ref,
|
|
663
706
|
className: cn(
|
|
@@ -667,24 +710,24 @@ var CommandInput = React2__namespace.forwardRef((_a, ref) => {
|
|
|
667
710
|
}, props)
|
|
668
711
|
) });
|
|
669
712
|
});
|
|
670
|
-
CommandInput.displayName =
|
|
671
|
-
var CommandList =
|
|
713
|
+
CommandInput.displayName = import_cmdk.Command.Input.displayName;
|
|
714
|
+
var CommandList = React2.forwardRef((_a, ref) => {
|
|
672
715
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
673
|
-
return /* @__PURE__ */
|
|
674
|
-
|
|
716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
717
|
+
import_cmdk.Command.List,
|
|
675
718
|
__spreadValues({
|
|
676
719
|
ref,
|
|
677
720
|
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
|
|
678
721
|
}, props)
|
|
679
722
|
);
|
|
680
723
|
});
|
|
681
|
-
CommandList.displayName =
|
|
682
|
-
var CommandEmpty =
|
|
683
|
-
CommandEmpty.displayName =
|
|
684
|
-
var CommandGroup =
|
|
724
|
+
CommandList.displayName = import_cmdk.Command.List.displayName;
|
|
725
|
+
var CommandEmpty = React2.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
|
|
726
|
+
CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
|
|
727
|
+
var CommandGroup = React2.forwardRef((_a, ref) => {
|
|
685
728
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
686
|
-
return /* @__PURE__ */
|
|
687
|
-
|
|
729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
730
|
+
import_cmdk.Command.Group,
|
|
688
731
|
__spreadValues({
|
|
689
732
|
ref,
|
|
690
733
|
className: cn(
|
|
@@ -694,22 +737,22 @@ var CommandGroup = React2__namespace.forwardRef((_a, ref) => {
|
|
|
694
737
|
}, props)
|
|
695
738
|
);
|
|
696
739
|
});
|
|
697
|
-
CommandGroup.displayName =
|
|
698
|
-
var CommandSeparator =
|
|
740
|
+
CommandGroup.displayName = import_cmdk.Command.Group.displayName;
|
|
741
|
+
var CommandSeparator = React2.forwardRef((_a, ref) => {
|
|
699
742
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
700
|
-
return /* @__PURE__ */
|
|
701
|
-
|
|
743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
744
|
+
import_cmdk.Command.Separator,
|
|
702
745
|
__spreadValues({
|
|
703
746
|
ref,
|
|
704
747
|
className: cn("-mx-1 h-px bg-border", className)
|
|
705
748
|
}, props)
|
|
706
749
|
);
|
|
707
750
|
});
|
|
708
|
-
CommandSeparator.displayName =
|
|
709
|
-
var CommandItem =
|
|
751
|
+
CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
|
|
752
|
+
var CommandItem = React2.forwardRef((_a, ref) => {
|
|
710
753
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
711
|
-
return /* @__PURE__ */
|
|
712
|
-
|
|
754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
755
|
+
import_cmdk.Command.Item,
|
|
713
756
|
__spreadValues({
|
|
714
757
|
ref,
|
|
715
758
|
className: cn(
|
|
@@ -719,10 +762,23 @@ var CommandItem = React2__namespace.forwardRef((_a, ref) => {
|
|
|
719
762
|
}, props)
|
|
720
763
|
);
|
|
721
764
|
});
|
|
722
|
-
CommandItem.displayName =
|
|
765
|
+
CommandItem.displayName = import_cmdk.Command.Item.displayName;
|
|
766
|
+
var CommandShortcut = (_a) => {
|
|
767
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
769
|
+
"span",
|
|
770
|
+
__spreadValues({
|
|
771
|
+
className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
|
|
772
|
+
}, props)
|
|
773
|
+
);
|
|
774
|
+
};
|
|
775
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
776
|
+
|
|
777
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
778
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
723
779
|
function SourceSearchBox(props) {
|
|
724
|
-
const [selectedValue, setSelectedValue] =
|
|
725
|
-
return /* @__PURE__ */
|
|
780
|
+
const [selectedValue, setSelectedValue] = (0, import_react5.useState)("");
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
726
782
|
Command,
|
|
727
783
|
{
|
|
728
784
|
className: "rounded-lg border shadow-md",
|
|
@@ -738,7 +794,7 @@ function SourceSearchBox(props) {
|
|
|
738
794
|
return 0;
|
|
739
795
|
},
|
|
740
796
|
children: [
|
|
741
|
-
/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
742
798
|
CommandInput,
|
|
743
799
|
{
|
|
744
800
|
value: props.searchTerm,
|
|
@@ -746,18 +802,18 @@ function SourceSearchBox(props) {
|
|
|
746
802
|
placeholder: "Search for a command..."
|
|
747
803
|
}
|
|
748
804
|
),
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
/* @__PURE__ */
|
|
751
|
-
/* @__PURE__ */
|
|
752
|
-
return /* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(CommandList, { children: [
|
|
806
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandEmpty, { children: "No results found." }),
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
|
|
808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
753
809
|
CommandItem,
|
|
754
810
|
{
|
|
755
811
|
value: filePointer.name,
|
|
756
812
|
onSelect: (value) => {
|
|
757
813
|
props.onSelectedFile(filePointer);
|
|
758
814
|
},
|
|
759
|
-
children: /* @__PURE__ */
|
|
760
|
-
/* @__PURE__ */
|
|
815
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
761
817
|
"img",
|
|
762
818
|
{
|
|
763
819
|
src: filePointer.iconImageUri,
|
|
@@ -771,7 +827,7 @@ function SourceSearchBox(props) {
|
|
|
771
827
|
`word-${filePointer.sourceApplication}.${filePointer.name}`
|
|
772
828
|
);
|
|
773
829
|
}) }),
|
|
774
|
-
/* @__PURE__ */
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandSeparator, {})
|
|
775
831
|
] })
|
|
776
832
|
]
|
|
777
833
|
}
|
|
@@ -782,9 +838,15 @@ function Logo({
|
|
|
782
838
|
width,
|
|
783
839
|
height
|
|
784
840
|
}) {
|
|
785
|
-
return /* @__PURE__ */
|
|
841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex items-center justify-center", style: { width, height }, children });
|
|
786
842
|
}
|
|
787
|
-
|
|
843
|
+
|
|
844
|
+
// src/components/ui/button.tsx
|
|
845
|
+
var React3 = __toESM(require("react"));
|
|
846
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
847
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
848
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
849
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
788
850
|
"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",
|
|
789
851
|
{
|
|
790
852
|
variants: {
|
|
@@ -809,22 +871,31 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
809
871
|
}
|
|
810
872
|
}
|
|
811
873
|
);
|
|
812
|
-
var Button =
|
|
874
|
+
var Button = React3.forwardRef(
|
|
813
875
|
(_a, ref) => {
|
|
814
876
|
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
815
|
-
const Comp = asChild ?
|
|
816
|
-
return /* @__PURE__ */
|
|
877
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
|
|
817
879
|
}
|
|
818
880
|
);
|
|
819
881
|
Button.displayName = "Button";
|
|
820
|
-
|
|
882
|
+
|
|
883
|
+
// src/components/ui/label.tsx
|
|
884
|
+
var React4 = __toESM(require("react"));
|
|
885
|
+
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
886
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
887
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
888
|
+
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
821
889
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
822
890
|
);
|
|
823
|
-
var Label =
|
|
891
|
+
var Label = React4.forwardRef((_a, ref) => {
|
|
824
892
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
825
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
|
|
826
894
|
});
|
|
827
|
-
Label.displayName =
|
|
895
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
896
|
+
|
|
897
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
898
|
+
var import_react6 = require("react");
|
|
828
899
|
|
|
829
900
|
// src/lib/stream-promise-flatten.ts
|
|
830
901
|
function streamPromiseFlatten(promise) {
|
|
@@ -849,14 +920,22 @@ function streamPromiseFlatten(promise) {
|
|
|
849
920
|
}
|
|
850
921
|
});
|
|
851
922
|
}
|
|
923
|
+
|
|
924
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
925
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
926
|
+
|
|
927
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
928
|
+
var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
|
|
929
|
+
var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
|
|
930
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
852
931
|
var IncludedFilesPreview = ({
|
|
853
932
|
includedFiles,
|
|
854
933
|
setIncludedFiles
|
|
855
934
|
}) => {
|
|
856
|
-
return /* @__PURE__ */
|
|
857
|
-
/* @__PURE__ */
|
|
858
|
-
/* @__PURE__ */
|
|
859
|
-
return /* @__PURE__ */
|
|
935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-2 mt-2", children: [
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { className: "", children: "Included context:" }),
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
|
|
938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
860
939
|
FileChipPreview,
|
|
861
940
|
{
|
|
862
941
|
filePointer,
|
|
@@ -870,13 +949,13 @@ var IncludedFilesPreview = ({
|
|
|
870
949
|
] });
|
|
871
950
|
};
|
|
872
951
|
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
873
|
-
return /* @__PURE__ */
|
|
874
|
-
|
|
952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
953
|
+
import_Chip.default,
|
|
875
954
|
{
|
|
876
955
|
label: filePointer.name,
|
|
877
956
|
onDelete,
|
|
878
|
-
avatar: /* @__PURE__ */
|
|
879
|
-
|
|
957
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
958
|
+
import_Avatar.default,
|
|
880
959
|
{
|
|
881
960
|
src: filePointer.iconImageUri,
|
|
882
961
|
alt: filePointer.sourceApplication,
|
|
@@ -886,35 +965,38 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
|
886
965
|
}
|
|
887
966
|
);
|
|
888
967
|
};
|
|
968
|
+
|
|
969
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
970
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
889
971
|
var HoveringInsertionPromptBoxCore = ({
|
|
890
972
|
performInsertion,
|
|
891
973
|
state,
|
|
892
974
|
insertionOrEditingFunction,
|
|
893
975
|
contextCategories
|
|
894
976
|
}) => {
|
|
895
|
-
const { getDocumentsContext } =
|
|
896
|
-
const [editSuggestion, setEditSuggestion] =
|
|
897
|
-
const [suggestionIsLoading, setSuggestionIsLoading] =
|
|
898
|
-
const [adjustmentPrompt, setAdjustmentPrompt] =
|
|
899
|
-
const [generatingSuggestion, setGeneratingSuggestion] =
|
|
977
|
+
const { getDocumentsContext } = (0, import_react6.useContext)(import_react_core2.CopilotContext);
|
|
978
|
+
const [editSuggestion, setEditSuggestion] = (0, import_react6.useState)("");
|
|
979
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react6.useState)(false);
|
|
980
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react6.useState)("");
|
|
981
|
+
const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react6.useState)(
|
|
900
982
|
null
|
|
901
983
|
);
|
|
902
|
-
const adjustmentTextAreaRef =
|
|
903
|
-
const suggestionTextAreaRef =
|
|
904
|
-
const [filePointers, setFilePointers] =
|
|
905
|
-
const [suggestedFiles, setSuggestedFiles] =
|
|
906
|
-
|
|
984
|
+
const adjustmentTextAreaRef = (0, import_react6.useRef)(null);
|
|
985
|
+
const suggestionTextAreaRef = (0, import_react6.useRef)(null);
|
|
986
|
+
const [filePointers, setFilePointers] = (0, import_react6.useState)([]);
|
|
987
|
+
const [suggestedFiles, setSuggestedFiles] = (0, import_react6.useState)([]);
|
|
988
|
+
(0, import_react6.useEffect)(() => {
|
|
907
989
|
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
908
990
|
}, [contextCategories, getDocumentsContext]);
|
|
909
991
|
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
910
992
|
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
911
|
-
|
|
993
|
+
(0, import_react6.useEffect)(() => {
|
|
912
994
|
setTimeout(() => {
|
|
913
995
|
var _a;
|
|
914
996
|
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
915
997
|
}, 0);
|
|
916
998
|
}, []);
|
|
917
|
-
|
|
999
|
+
(0, import_react6.useEffect)(() => {
|
|
918
1000
|
if (!generatingSuggestion) {
|
|
919
1001
|
return;
|
|
920
1002
|
}
|
|
@@ -952,7 +1034,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
952
1034
|
releaseLockIfNotClosed();
|
|
953
1035
|
};
|
|
954
1036
|
}, [generatingSuggestion]);
|
|
955
|
-
const beginGeneratingAdjustment =
|
|
1037
|
+
const beginGeneratingAdjustment = (0, import_react6.useCallback)(() => __async(void 0, null, function* () {
|
|
956
1038
|
if (!adjustmentPrompt.trim()) {
|
|
957
1039
|
return;
|
|
958
1040
|
}
|
|
@@ -981,10 +1063,10 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
981
1063
|
const textToEdit = editSuggestion || state.editorState.selectedText;
|
|
982
1064
|
const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
|
|
983
1065
|
const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
|
|
984
|
-
const AdjustmentPromptComponent = /* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
987
|
-
/* @__PURE__ */
|
|
1066
|
+
const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1067
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "", children: adjustmentLabel }),
|
|
1068
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative w-full flex items-center", children: [
|
|
1069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
988
1070
|
"textarea",
|
|
989
1071
|
{
|
|
990
1072
|
disabled: suggestionIsLoading,
|
|
@@ -1006,29 +1088,29 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1006
1088
|
rows: 1
|
|
1007
1089
|
}
|
|
1008
1090
|
),
|
|
1009
|
-
/* @__PURE__ */
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1010
1092
|
"button",
|
|
1011
1093
|
{
|
|
1012
1094
|
onClick: beginGeneratingAdjustment,
|
|
1013
1095
|
className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
|
|
1014
|
-
children: /* @__PURE__ */
|
|
1096
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "arrow_forward" })
|
|
1015
1097
|
}
|
|
1016
1098
|
)
|
|
1017
1099
|
] })
|
|
1018
1100
|
] });
|
|
1019
|
-
const SuggestionComponent = /* @__PURE__ */
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
/* @__PURE__ */
|
|
1101
|
+
const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
|
|
1103
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1023
1105
|
"div",
|
|
1024
1106
|
{
|
|
1025
1107
|
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]",
|
|
1026
1108
|
role: "status",
|
|
1027
|
-
children: /* @__PURE__ */
|
|
1109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
|
|
1028
1110
|
}
|
|
1029
1111
|
) }) })
|
|
1030
1112
|
] }),
|
|
1031
|
-
/* @__PURE__ */
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1032
1114
|
"textarea",
|
|
1033
1115
|
{
|
|
1034
1116
|
ref: suggestionTextAreaRef,
|
|
@@ -1040,7 +1122,7 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1040
1122
|
}
|
|
1041
1123
|
)
|
|
1042
1124
|
] });
|
|
1043
|
-
const SubmitComponent = /* @__PURE__ */
|
|
1125
|
+
const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1044
1126
|
Button,
|
|
1045
1127
|
{
|
|
1046
1128
|
className: " bg-green-700 text-white",
|
|
@@ -1049,16 +1131,16 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1049
1131
|
},
|
|
1050
1132
|
children: [
|
|
1051
1133
|
"Insert ",
|
|
1052
|
-
/* @__PURE__ */
|
|
1134
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "check" })
|
|
1053
1135
|
]
|
|
1054
1136
|
}
|
|
1055
1137
|
) });
|
|
1056
1138
|
const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
|
|
1057
1139
|
const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
|
|
1058
|
-
return /* @__PURE__ */
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
|
|
1059
1141
|
AdjustmentPromptComponent,
|
|
1060
|
-
filePointers.length > 0 && /* @__PURE__ */
|
|
1061
|
-
sourceSearchWord !== void 0 && /* @__PURE__ */
|
|
1142
|
+
filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
|
|
1143
|
+
sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1062
1144
|
SourceSearchBox,
|
|
1063
1145
|
{
|
|
1064
1146
|
searchTerm: sourceSearchWord,
|
|
@@ -1075,13 +1157,16 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
1075
1157
|
generatingSuggestion ? SubmitComponent : null
|
|
1076
1158
|
] });
|
|
1077
1159
|
};
|
|
1160
|
+
|
|
1161
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
1162
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1078
1163
|
var HoveringInsertionPromptBox = (props) => {
|
|
1079
|
-
return /* @__PURE__ */
|
|
1164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1080
1165
|
"div",
|
|
1081
1166
|
{
|
|
1082
1167
|
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
1083
1168
|
style: { width: "35rem" },
|
|
1084
|
-
children: /* @__PURE__ */
|
|
1169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1085
1170
|
HoveringInsertionPromptBoxCore,
|
|
1086
1171
|
{
|
|
1087
1172
|
state: {
|
|
@@ -1095,7 +1180,13 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
1095
1180
|
}
|
|
1096
1181
|
);
|
|
1097
1182
|
};
|
|
1098
|
-
|
|
1183
|
+
|
|
1184
|
+
// src/components/hovering-toolbar/hovering-toolbar-components.tsx
|
|
1185
|
+
var import_css = require("@emotion/css");
|
|
1186
|
+
var import_react7 = __toESM(require("react"));
|
|
1187
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
1188
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1189
|
+
var Button2 = import_react7.default.forwardRef(
|
|
1099
1190
|
(_a, ref) => {
|
|
1100
1191
|
var _b = _a, {
|
|
1101
1192
|
className,
|
|
@@ -1106,13 +1197,13 @@ React2__namespace.default.forwardRef(
|
|
|
1106
1197
|
"active",
|
|
1107
1198
|
"reversed"
|
|
1108
1199
|
]);
|
|
1109
|
-
return /* @__PURE__ */
|
|
1200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1110
1201
|
"span",
|
|
1111
1202
|
__spreadProps(__spreadValues({}, props), {
|
|
1112
1203
|
ref,
|
|
1113
|
-
className:
|
|
1204
|
+
className: (0, import_css.cx)(
|
|
1114
1205
|
className,
|
|
1115
|
-
|
|
1206
|
+
import_css.css`
|
|
1116
1207
|
cursor: pointer;
|
|
1117
1208
|
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
1118
1209
|
`
|
|
@@ -1121,17 +1212,17 @@ React2__namespace.default.forwardRef(
|
|
|
1121
1212
|
);
|
|
1122
1213
|
}
|
|
1123
1214
|
);
|
|
1124
|
-
|
|
1215
|
+
var Icon = import_react7.default.forwardRef(
|
|
1125
1216
|
(_a, ref) => {
|
|
1126
1217
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1127
|
-
return /* @__PURE__ */
|
|
1218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1128
1219
|
"span",
|
|
1129
1220
|
__spreadProps(__spreadValues({}, props), {
|
|
1130
1221
|
ref,
|
|
1131
|
-
className:
|
|
1222
|
+
className: (0, import_css.cx)(
|
|
1132
1223
|
"material-icons",
|
|
1133
1224
|
className,
|
|
1134
|
-
|
|
1225
|
+
import_css.css`
|
|
1135
1226
|
font-size: 18px;
|
|
1136
1227
|
vertical-align: text-bottom;
|
|
1137
1228
|
`
|
|
@@ -1140,17 +1231,17 @@ React2__namespace.default.forwardRef(
|
|
|
1140
1231
|
);
|
|
1141
1232
|
}
|
|
1142
1233
|
);
|
|
1143
|
-
var Menu =
|
|
1234
|
+
var Menu = import_react7.default.forwardRef(
|
|
1144
1235
|
(_a, ref) => {
|
|
1145
1236
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1146
|
-
return /* @__PURE__ */
|
|
1237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1147
1238
|
"div",
|
|
1148
1239
|
__spreadProps(__spreadValues({}, props), {
|
|
1149
1240
|
"data-test-id": "menu",
|
|
1150
1241
|
ref,
|
|
1151
|
-
className:
|
|
1242
|
+
className: (0, import_css.cx)(
|
|
1152
1243
|
className,
|
|
1153
|
-
|
|
1244
|
+
import_css.css`
|
|
1154
1245
|
& > * {
|
|
1155
1246
|
display: inline-block;
|
|
1156
1247
|
}
|
|
@@ -1165,18 +1256,18 @@ var Menu = React2__namespace.default.forwardRef(
|
|
|
1165
1256
|
}
|
|
1166
1257
|
);
|
|
1167
1258
|
var Portal = ({ children }) => {
|
|
1168
|
-
return typeof document === "object" ?
|
|
1259
|
+
return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
|
|
1169
1260
|
};
|
|
1170
|
-
|
|
1261
|
+
var Toolbar = import_react7.default.forwardRef(
|
|
1171
1262
|
(_a, ref) => {
|
|
1172
1263
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
1173
|
-
return /* @__PURE__ */
|
|
1264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1174
1265
|
Menu,
|
|
1175
1266
|
__spreadProps(__spreadValues({}, props), {
|
|
1176
1267
|
ref,
|
|
1177
|
-
className:
|
|
1268
|
+
className: (0, import_css.cx)(
|
|
1178
1269
|
className,
|
|
1179
|
-
|
|
1270
|
+
import_css.css`
|
|
1180
1271
|
position: relative;
|
|
1181
1272
|
padding: 1px 18px 17px;
|
|
1182
1273
|
margin: 0 -20px;
|
|
@@ -1188,26 +1279,33 @@ React2__namespace.default.forwardRef(
|
|
|
1188
1279
|
);
|
|
1189
1280
|
}
|
|
1190
1281
|
);
|
|
1191
|
-
|
|
1282
|
+
|
|
1283
|
+
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
1284
|
+
var import_react8 = require("react");
|
|
1285
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1286
|
+
var HoveringEditorContext = (0, import_react8.createContext)({
|
|
1192
1287
|
isDisplayed: false,
|
|
1193
1288
|
setIsDisplayed: () => {
|
|
1194
1289
|
}
|
|
1195
1290
|
});
|
|
1196
1291
|
var HoveringEditorProvider = ({ children }) => {
|
|
1197
|
-
const [isDisplayed, setIsDisplayed] =
|
|
1198
|
-
return /* @__PURE__ */
|
|
1292
|
+
const [isDisplayed, setIsDisplayed] = (0, import_react8.useState)(false);
|
|
1293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
1199
1294
|
};
|
|
1200
|
-
var useHoveringEditorContext = () =>
|
|
1295
|
+
var useHoveringEditorContext = () => (0, import_react8.useContext)(HoveringEditorContext);
|
|
1296
|
+
|
|
1297
|
+
// src/components/hovering-toolbar/hovering-toolbar.tsx
|
|
1298
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1201
1299
|
var HoveringToolbar = (props) => {
|
|
1202
|
-
const ref =
|
|
1203
|
-
const editor =
|
|
1204
|
-
const selection =
|
|
1300
|
+
const ref = (0, import_react9.useRef)(null);
|
|
1301
|
+
const editor = (0, import_slate_react3.useSlate)();
|
|
1302
|
+
const selection = (0, import_slate_react3.useSlateSelection)();
|
|
1205
1303
|
const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
|
|
1206
|
-
const [isClient, setIsClient] =
|
|
1207
|
-
|
|
1304
|
+
const [isClient, setIsClient] = (0, import_react9.useState)(false);
|
|
1305
|
+
(0, import_react9.useEffect)(() => {
|
|
1208
1306
|
setIsClient(true);
|
|
1209
1307
|
}, []);
|
|
1210
|
-
|
|
1308
|
+
(0, import_react9.useEffect)(() => {
|
|
1211
1309
|
const el = ref.current;
|
|
1212
1310
|
const { selection: selection2 } = editor;
|
|
1213
1311
|
if (!el) {
|
|
@@ -1245,7 +1343,7 @@ var HoveringToolbar = (props) => {
|
|
|
1245
1343
|
el.style.top = `${top}px`;
|
|
1246
1344
|
el.style.left = `${left}px`;
|
|
1247
1345
|
});
|
|
1248
|
-
|
|
1346
|
+
(0, import_react9.useEffect)(() => {
|
|
1249
1347
|
const handleClickOutside = (event) => {
|
|
1250
1348
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
1251
1349
|
setIsDisplayed(false);
|
|
@@ -1259,23 +1357,23 @@ var HoveringToolbar = (props) => {
|
|
|
1259
1357
|
if (!isClient) {
|
|
1260
1358
|
return null;
|
|
1261
1359
|
}
|
|
1262
|
-
return /* @__PURE__ */
|
|
1360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1263
1361
|
Menu,
|
|
1264
1362
|
{
|
|
1265
1363
|
ref,
|
|
1266
1364
|
className: props.hoverMenuClassname || "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
|
|
1267
|
-
children: isDisplayed && selection && /* @__PURE__ */
|
|
1365
|
+
children: isDisplayed && selection && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1268
1366
|
HoveringInsertionPromptBox,
|
|
1269
1367
|
{
|
|
1270
|
-
editorState: editorState(editor),
|
|
1368
|
+
editorState: editorState(editor, selection),
|
|
1271
1369
|
apiConfig: props.apiConfig,
|
|
1272
1370
|
closeWindow: () => {
|
|
1273
1371
|
setIsDisplayed(false);
|
|
1274
1372
|
},
|
|
1275
1373
|
performInsertion: (insertedText) => {
|
|
1276
1374
|
console.log("inserted text", insertedText);
|
|
1277
|
-
|
|
1278
|
-
|
|
1375
|
+
import_slate7.Transforms.delete(editor, { at: selection });
|
|
1376
|
+
import_slate7.Transforms.insertText(editor, insertedText, {
|
|
1279
1377
|
at: selection
|
|
1280
1378
|
});
|
|
1281
1379
|
setIsDisplayed(false);
|
|
@@ -1297,21 +1395,24 @@ function editorState(editor, selection) {
|
|
|
1297
1395
|
selectedText: ""
|
|
1298
1396
|
};
|
|
1299
1397
|
}
|
|
1398
|
+
|
|
1399
|
+
// src/components/base-copilot-textarea/render-element.tsx
|
|
1400
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1300
1401
|
function makeRenderElementFunction(suggestionsStyle) {
|
|
1301
1402
|
return (props) => {
|
|
1302
1403
|
switch (props.element.type) {
|
|
1303
1404
|
case "paragraph":
|
|
1304
|
-
return /* @__PURE__ */
|
|
1405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultElement, __spreadValues({}, props));
|
|
1305
1406
|
case "suggestion":
|
|
1306
|
-
return /* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SuggestionElement, __spreadProps(__spreadValues({}, props), { suggestionsStyle }));
|
|
1307
1408
|
}
|
|
1308
1409
|
};
|
|
1309
1410
|
}
|
|
1310
1411
|
var DefaultElement = (props) => {
|
|
1311
|
-
return /* @__PURE__ */
|
|
1412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", __spreadProps(__spreadValues({}, props.attributes), { children: props.children }));
|
|
1312
1413
|
};
|
|
1313
1414
|
var SuggestionElement = (props) => {
|
|
1314
|
-
return /* @__PURE__ */
|
|
1415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1315
1416
|
"span",
|
|
1316
1417
|
__spreadProps(__spreadValues({}, props.attributes), {
|
|
1317
1418
|
style: __spreadValues({}, props.suggestionsStyle),
|
|
@@ -1323,10 +1424,13 @@ var SuggestionElement = (props) => {
|
|
|
1323
1424
|
})
|
|
1324
1425
|
);
|
|
1325
1426
|
};
|
|
1427
|
+
|
|
1428
|
+
// src/components/base-copilot-textarea/render-placeholder.tsx
|
|
1429
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1326
1430
|
function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
1327
1431
|
return (props) => {
|
|
1328
1432
|
const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
|
|
1329
|
-
return /* @__PURE__ */
|
|
1433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1330
1434
|
"div",
|
|
1331
1435
|
__spreadProps(__spreadValues({}, restAttributes), {
|
|
1332
1436
|
style: __spreadValues(__spreadValues({}, style), placeholderStyle),
|
|
@@ -1335,9 +1439,12 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
|
1335
1439
|
);
|
|
1336
1440
|
};
|
|
1337
1441
|
}
|
|
1442
|
+
|
|
1443
|
+
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
1444
|
+
var import_react10 = require("react");
|
|
1338
1445
|
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
1339
1446
|
const cssSelector = ".copilot-textarea.with-branding";
|
|
1340
|
-
|
|
1447
|
+
(0, import_react10.useEffect)(() => {
|
|
1341
1448
|
if (disableBranding) {
|
|
1342
1449
|
return;
|
|
1343
1450
|
}
|
|
@@ -1387,10 +1494,18 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
|
1387
1494
|
};
|
|
1388
1495
|
}, [disableBranding, suggestionStyleAugmented]);
|
|
1389
1496
|
}
|
|
1497
|
+
|
|
1498
|
+
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1499
|
+
var import_react11 = require("react");
|
|
1500
|
+
var import_slate_react4 = require("slate-react");
|
|
1501
|
+
var import_slate9 = require("slate");
|
|
1502
|
+
|
|
1503
|
+
// src/lib/editor-to-text.ts
|
|
1504
|
+
var import_slate8 = require("slate");
|
|
1390
1505
|
function nodeChildrenToTextComponents(editor, nodes) {
|
|
1391
1506
|
const indeciesOfInlineElements = new Set(
|
|
1392
1507
|
nodes.map((node, index) => {
|
|
1393
|
-
if (
|
|
1508
|
+
if (import_slate8.Element.isElement(node) && editor.isInline(node)) {
|
|
1394
1509
|
return index;
|
|
1395
1510
|
}
|
|
1396
1511
|
return -1;
|
|
@@ -1408,7 +1523,7 @@ function nodeChildrenToTextComponents(editor, nodes) {
|
|
|
1408
1523
|
return true;
|
|
1409
1524
|
});
|
|
1410
1525
|
return nonIgnorableItems.map((node) => {
|
|
1411
|
-
if (
|
|
1526
|
+
if (import_slate8.Element.isElement(node)) {
|
|
1412
1527
|
switch (node.type) {
|
|
1413
1528
|
case "paragraph":
|
|
1414
1529
|
return nodeChildrenToTextComponents(editor, node.children);
|
|
@@ -1425,13 +1540,16 @@ var editorToText = (editor) => {
|
|
|
1425
1540
|
const text = flattened.map((textComponent) => textComponent.text).join("\n");
|
|
1426
1541
|
return text;
|
|
1427
1542
|
};
|
|
1543
|
+
|
|
1544
|
+
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
1545
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1428
1546
|
function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
1429
|
-
const cursorState =
|
|
1547
|
+
const cursorState = (0, import_slate_react4.useSlateSelector)((state) => ({
|
|
1430
1548
|
selection: state.selection,
|
|
1431
1549
|
text: editorToText(state)
|
|
1432
1550
|
}));
|
|
1433
1551
|
const previousState = usePrevious(cursorState);
|
|
1434
|
-
|
|
1552
|
+
(0, import_react11.useEffect)(() => {
|
|
1435
1553
|
if (!previousState) {
|
|
1436
1554
|
return;
|
|
1437
1555
|
}
|
|
@@ -1439,7 +1557,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
|
1439
1557
|
props.setCursorMovedSinceLastTextChange(true);
|
|
1440
1558
|
}
|
|
1441
1559
|
}, [props.setCursorMovedSinceLastTextChange, cursorState]);
|
|
1442
|
-
return /* @__PURE__ */
|
|
1560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {});
|
|
1443
1561
|
}
|
|
1444
1562
|
var cursorChangedWithoutTextChanged = (prev, next) => {
|
|
1445
1563
|
const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
|
|
@@ -1451,30 +1569,33 @@ var isSelectionEqual = (a, b) => {
|
|
|
1451
1569
|
return true;
|
|
1452
1570
|
if (!a || !b)
|
|
1453
1571
|
return false;
|
|
1454
|
-
return
|
|
1572
|
+
return import_slate9.Range.equals(a, b);
|
|
1455
1573
|
};
|
|
1456
1574
|
function usePrevious(value) {
|
|
1457
|
-
const ref =
|
|
1458
|
-
|
|
1575
|
+
const ref = (0, import_react11.useRef)();
|
|
1576
|
+
(0, import_react11.useEffect)(() => {
|
|
1459
1577
|
ref.current = value;
|
|
1460
1578
|
});
|
|
1461
1579
|
return ref.current;
|
|
1462
1580
|
}
|
|
1463
|
-
|
|
1581
|
+
|
|
1582
|
+
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
1583
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1584
|
+
var BaseCopilotTextarea = import_react12.default.forwardRef(
|
|
1464
1585
|
(props, ref) => {
|
|
1465
|
-
return /* @__PURE__ */
|
|
1586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
1466
1587
|
}
|
|
1467
1588
|
);
|
|
1468
|
-
var BaseCopilotTextareaWithHoveringContext =
|
|
1589
|
+
var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
|
|
1469
1590
|
(props, ref) => {
|
|
1470
1591
|
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
1471
|
-
const valueOnInitialRender =
|
|
1592
|
+
const valueOnInitialRender = (0, import_react12.useMemo)(() => {
|
|
1472
1593
|
var _a2;
|
|
1473
1594
|
return (_a2 = props.value) != null ? _a2 : "";
|
|
1474
1595
|
}, []);
|
|
1475
|
-
const [lastKnownFullEditorText, setLastKnownFullEditorText] =
|
|
1476
|
-
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] =
|
|
1477
|
-
const initialValue =
|
|
1596
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
|
|
1597
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
|
|
1598
|
+
const initialValue = (0, import_react12.useMemo)(() => {
|
|
1478
1599
|
return [
|
|
1479
1600
|
{
|
|
1480
1601
|
type: "paragraph",
|
|
@@ -1484,9 +1605,9 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1484
1605
|
}, [valueOnInitialRender]);
|
|
1485
1606
|
const editor = useCopilotTextareaEditor();
|
|
1486
1607
|
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
1487
|
-
const insertText =
|
|
1608
|
+
const insertText = (0, import_react12.useCallback)(
|
|
1488
1609
|
(autosuggestion) => {
|
|
1489
|
-
|
|
1610
|
+
import_slate10.Editor.insertText(editor, autosuggestion.text, {
|
|
1490
1611
|
at: autosuggestion.point
|
|
1491
1612
|
});
|
|
1492
1613
|
},
|
|
@@ -1510,7 +1631,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1510
1631
|
autosuggestionsConfig.disableWhenEmpty,
|
|
1511
1632
|
shouldDisableAutosuggestions
|
|
1512
1633
|
);
|
|
1513
|
-
const onKeyDownHandlerForHoveringEditor =
|
|
1634
|
+
const onKeyDownHandlerForHoveringEditor = (0, import_react12.useCallback)(
|
|
1514
1635
|
(event) => {
|
|
1515
1636
|
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {
|
|
1516
1637
|
event.preventDefault();
|
|
@@ -1523,7 +1644,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1523
1644
|
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
1524
1645
|
]
|
|
1525
1646
|
);
|
|
1526
|
-
|
|
1647
|
+
(0, import_react12.useEffect)(() => {
|
|
1527
1648
|
clearAutocompletionsFromEditor(editor);
|
|
1528
1649
|
if (currentAutocompleteSuggestion) {
|
|
1529
1650
|
addAutocompletionsToEditor(
|
|
@@ -1533,23 +1654,23 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1533
1654
|
);
|
|
1534
1655
|
}
|
|
1535
1656
|
}, [currentAutocompleteSuggestion]);
|
|
1536
|
-
const suggestionStyleAugmented =
|
|
1657
|
+
const suggestionStyleAugmented = (0, import_react12.useMemo)(() => {
|
|
1537
1658
|
return __spreadValues({
|
|
1538
1659
|
fontStyle: "italic",
|
|
1539
1660
|
color: "gray"
|
|
1540
1661
|
}, props.suggestionsStyle);
|
|
1541
1662
|
}, [props.suggestionsStyle]);
|
|
1542
|
-
const renderElementMemoized =
|
|
1663
|
+
const renderElementMemoized = (0, import_react12.useMemo)(() => {
|
|
1543
1664
|
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
1544
1665
|
}, [suggestionStyleAugmented]);
|
|
1545
|
-
const renderPlaceholderMemoized =
|
|
1666
|
+
const renderPlaceholderMemoized = (0, import_react12.useMemo)(() => {
|
|
1546
1667
|
const placeholderStyleSlatejsOverrides = {
|
|
1547
1668
|
top: void 0
|
|
1548
1669
|
};
|
|
1549
1670
|
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
1550
1671
|
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
1551
1672
|
}, [props.placeholderStyle]);
|
|
1552
|
-
|
|
1673
|
+
(0, import_react12.useEffect)(() => {
|
|
1553
1674
|
var _a2, _b;
|
|
1554
1675
|
if (props.value === lastKnownFullEditorText) {
|
|
1555
1676
|
return;
|
|
@@ -1584,11 +1705,11 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1584
1705
|
const baseClassName = "copilot-textarea";
|
|
1585
1706
|
const brandingClass = disableBranding ? "no-branding" : "with-branding";
|
|
1586
1707
|
const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
|
|
1587
|
-
const mergedClassName =
|
|
1708
|
+
const mergedClassName = (0, import_tailwind_merge2.twMerge)(defaultTailwindClassName, className != null ? className : "");
|
|
1588
1709
|
return `${baseClassName} ${brandingClass} ${mergedClassName}`;
|
|
1589
1710
|
})();
|
|
1590
|
-
return /* @__PURE__ */
|
|
1591
|
-
|
|
1711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1712
|
+
import_slate_react5.Slate,
|
|
1592
1713
|
{
|
|
1593
1714
|
editor,
|
|
1594
1715
|
initialValue,
|
|
@@ -1607,13 +1728,13 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1607
1728
|
(_b = props.onChange) == null ? void 0 : _b.call(props, makeSemiFakeReactTextAreaEvent(fullEditorText));
|
|
1608
1729
|
},
|
|
1609
1730
|
children: [
|
|
1610
|
-
/* @__PURE__ */
|
|
1731
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1611
1732
|
TrackerTextEditedSinceLastCursorMovement,
|
|
1612
1733
|
{
|
|
1613
1734
|
setCursorMovedSinceLastTextChange
|
|
1614
1735
|
}
|
|
1615
1736
|
),
|
|
1616
|
-
/* @__PURE__ */
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1617
1738
|
HoveringToolbar,
|
|
1618
1739
|
{
|
|
1619
1740
|
apiConfig: autosuggestionsConfig.apiConfig,
|
|
@@ -1621,8 +1742,8 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
|
|
|
1621
1742
|
hoverMenuClassname
|
|
1622
1743
|
}
|
|
1623
1744
|
),
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1746
|
+
import_slate_react5.Editable,
|
|
1626
1747
|
__spreadValues({
|
|
1627
1748
|
renderElement: renderElementMemoized,
|
|
1628
1749
|
renderPlaceholder: renderPlaceholderMemoized,
|
|
@@ -1652,7 +1773,8 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
1652
1773
|
}
|
|
1653
1774
|
};
|
|
1654
1775
|
}
|
|
1655
|
-
|
|
1656
|
-
exports
|
|
1657
|
-
|
|
1776
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1777
|
+
0 && (module.exports = {
|
|
1778
|
+
BaseCopilotTextarea
|
|
1779
|
+
});
|
|
1658
1780
|
//# sourceMappingURL=base-copilot-textarea.js.map
|