@copilotkit/react-textarea 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/chunk-224UKA7C.mjs +38 -0
- package/dist/chunk-224UKA7C.mjs.map +1 -0
- package/dist/chunk-23Q6A46J.mjs +103 -0
- package/dist/chunk-23Q6A46J.mjs.map +1 -0
- package/dist/chunk-2C7O2EVM.mjs +27 -0
- package/dist/chunk-2C7O2EVM.mjs.map +1 -0
- package/dist/chunk-2QDCE7PD.mjs +32 -0
- package/dist/chunk-2QDCE7PD.mjs.map +1 -0
- package/dist/chunk-2XDYLKPH.mjs +181 -0
- package/dist/chunk-2XDYLKPH.mjs.map +1 -0
- package/dist/chunk-3PQ7GSFE.mjs +17 -0
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -0
- package/dist/chunk-4AMCUMC7.mjs +124 -0
- package/dist/chunk-4AMCUMC7.mjs.map +1 -0
- package/dist/chunk-4CVSOOJY.mjs +30 -0
- package/dist/chunk-4CVSOOJY.mjs.map +1 -0
- package/dist/chunk-4NHVQZ67.mjs +108 -0
- package/dist/chunk-4NHVQZ67.mjs.map +1 -0
- package/dist/chunk-4PDYALMP.mjs +52 -0
- package/dist/chunk-4PDYALMP.mjs.map +1 -0
- package/dist/chunk-5UNJXFUO.mjs +29 -0
- package/dist/chunk-5UNJXFUO.mjs.map +1 -0
- package/dist/chunk-7LSRNPNI.mjs +59 -0
- package/dist/chunk-7LSRNPNI.mjs.map +1 -0
- package/dist/chunk-AJ5OMEXM.mjs +13 -0
- package/dist/chunk-AJ5OMEXM.mjs.map +1 -0
- package/dist/chunk-CF5GISTC.mjs +113 -0
- package/dist/chunk-CF5GISTC.mjs.map +1 -0
- package/dist/chunk-D2SUDM2O.mjs +99 -0
- package/dist/chunk-D2SUDM2O.mjs.map +1 -0
- package/dist/chunk-D47EKHIF.mjs +26 -0
- package/dist/chunk-D47EKHIF.mjs.map +1 -0
- package/dist/chunk-DE5K76I2.mjs +1 -0
- package/dist/chunk-DE5K76I2.mjs.map +1 -0
- package/dist/chunk-DFTV4TST.mjs +36 -0
- package/dist/chunk-DFTV4TST.mjs.map +1 -0
- package/dist/chunk-DRV2FOHZ.mjs +70 -0
- package/dist/chunk-DRV2FOHZ.mjs.map +1 -0
- package/dist/chunk-ECR45NSD.mjs +104 -0
- package/dist/chunk-ECR45NSD.mjs.map +1 -0
- package/dist/chunk-EJGGLWWR.mjs +82 -0
- package/dist/chunk-EJGGLWWR.mjs.map +1 -0
- package/dist/chunk-FYCQE57K.mjs +60 -0
- package/dist/chunk-FYCQE57K.mjs.map +1 -0
- package/dist/chunk-GQN2HYFJ.mjs +22 -0
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +1 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-HL7EF7KA.mjs +32 -0
- package/dist/chunk-HL7EF7KA.mjs.map +1 -0
- package/dist/chunk-I3SPIGAI.mjs +31 -0
- package/dist/chunk-I3SPIGAI.mjs.map +1 -0
- package/dist/chunk-I72DKFHD.mjs +114 -0
- package/dist/chunk-I72DKFHD.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +1 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-J62KUPFZ.mjs +264 -0
- package/dist/chunk-J62KUPFZ.mjs.map +1 -0
- package/dist/chunk-KMVGEY7Q.mjs +51 -0
- package/dist/chunk-KMVGEY7Q.mjs.map +1 -0
- package/dist/chunk-KNQIEOFP.mjs +19 -0
- package/dist/chunk-KNQIEOFP.mjs.map +1 -0
- package/dist/chunk-L7VVZH4Q.mjs +1 -0
- package/dist/chunk-L7VVZH4Q.mjs.map +1 -0
- package/dist/chunk-LQ2OWQU7.mjs +49 -0
- package/dist/chunk-LQ2OWQU7.mjs.map +1 -0
- package/dist/chunk-LYB4B6MK.mjs +19 -0
- package/dist/chunk-LYB4B6MK.mjs.map +1 -0
- package/dist/chunk-MCNXIA4Q.mjs +75 -0
- package/dist/chunk-MCNXIA4Q.mjs.map +1 -0
- package/dist/chunk-MMVDU6DF.mjs +1 -0
- package/dist/chunk-MMVDU6DF.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +59 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-QJNFNPWH.mjs +85 -0
- package/dist/chunk-QJNFNPWH.mjs.map +1 -0
- package/dist/chunk-RUV6NBIF.mjs +1 -0
- package/dist/chunk-RUV6NBIF.mjs.map +1 -0
- package/dist/chunk-SDHH6DI6.mjs +63 -0
- package/dist/chunk-SDHH6DI6.mjs.map +1 -0
- package/dist/chunk-T6MTDQZ7.mjs +45 -0
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -0
- package/dist/chunk-UGEKMSRR.mjs +225 -0
- package/dist/chunk-UGEKMSRR.mjs.map +1 -0
- package/dist/chunk-VSVQZUPW.mjs +124 -0
- package/dist/chunk-VSVQZUPW.mjs.map +1 -0
- package/dist/chunk-WADHCMPK.mjs +1 -0
- package/dist/chunk-WADHCMPK.mjs.map +1 -0
- package/dist/chunk-WGWQRALG.mjs +83 -0
- package/dist/chunk-WGWQRALG.mjs.map +1 -0
- package/dist/chunk-WJHSY5T6.mjs +1 -0
- package/dist/chunk-WJHSY5T6.mjs.map +1 -0
- package/dist/chunk-XW3ICO4S.mjs +25 -0
- package/dist/chunk-XW3ICO4S.mjs.map +1 -0
- package/dist/chunk-YLFAIYRY.mjs +50 -0
- package/dist/chunk-YLFAIYRY.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.css +9 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.css.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +114 -49
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +36 -1687
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.d.ts +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +4 -48
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.d.ts +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +4 -46
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +4 -2
- 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 +5 -81
- 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.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +4 -54
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.css +9 -0
- package/dist/components/copilot-textarea/copilot-textarea.css.map +1 -0
- package/dist/components/copilot-textarea/copilot-textarea.d.ts +9 -3
- package/dist/components/copilot-textarea/copilot-textarea.js +116 -51
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +44 -2212
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +5 -13
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +2 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js +21 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +9 -111
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js +94 -31
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +19 -808
- 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.d.ts +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +65 -21
- 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 +14 -520
- 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.d.ts +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +68 -24
- 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 +15 -543
- 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.d.ts +16 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +133 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +12 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +68 -24
- 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 +16 -543
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.css +9 -0
- package/dist/components/index.css.map +1 -0
- package/dist/components/index.js +116 -51
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +46 -2211
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.d.ts +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +2 -0
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.d.ts +1 -1
- package/dist/components/source-search-box/source-search-box.js +4 -2
- package/dist/components/source-search-box/source-search-box.js.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +8 -200
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.mjs +6 -76
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/command.mjs +14 -233
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +11 -135
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +5 -51
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.mjs +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +7 -152
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +5 -165
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +6 -141
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.mjs +1 -0
- 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 +4 -139
- 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.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +4 -221
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +4 -12
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.css +644 -1
- package/dist/index.css.map +1 -0
- package/dist/index.js +116 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -2218
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.d.ts +1 -1
- package/dist/lib/debouncer.js.map +1 -1
- package/dist/lib/debouncer.mjs +4 -48
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +4 -40
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.d.ts +1 -1
- package/dist/lib/get-text-around-cursor.mjs +7 -96
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +4 -14
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +4 -22
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +4 -17
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +4 -24
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.d.ts +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +5 -102
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.js.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +4 -44
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +8 -58
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.d.ts +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +9 -258
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.d.ts +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +6 -75
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +10 -258
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.d.ts +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +6 -68
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.ts +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +6 -56
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.d.ts +1 -1
- package/dist/types/base/autosuggestions-bare-function.d.ts +1 -1
- package/dist/types/base/base-autosuggestions-config.d.ts +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +4 -25
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/custom-editor.d.ts +1 -1
- package/dist/types/base/editor-autocomplete-state.d.ts +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +5 -9
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.d.ts +1 -1
- package/dist/types/base/index.mjs +5 -25
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.d.ts +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +14 -258
- package/dist/types/index.mjs.map +1 -1
- package/package.json +11 -17
- package/src/components/base-copilot-textarea/base-copilot-textarea.css +9 -0
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +1 -0
- package/src/components/copilot-textarea/copilot-textarea.tsx +8 -2
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +17 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +7 -4
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +55 -0
- package/src/styles.css +2 -9
- package/tsup.config.ts +15 -63
- package/dist/components/base-copilot-textarea/base-copilot-textarea.d.mts +0 -43
- package/dist/components/base-copilot-textarea/render-element.d.mts +0 -6
- package/dist/components/base-copilot-textarea/render-placeholder.d.mts +0 -6
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.mts +0 -8
- package/dist/components/base-copilot-textarea/use-add-branding-css.d.mts +0 -3
- package/dist/components/copilot-textarea/copilot-textarea.d.mts +0 -165
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.mts +0 -18
- package/dist/components/hovering-toolbar/hovering-toolbar-components.d.mts +0 -17
- package/dist/components/hovering-toolbar/hovering-toolbar.d.mts +0 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.d.mts +0 -16
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.mts +0 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.mts +0 -4
- package/dist/components/index.d.mts +0 -15
- package/dist/components/manual-ui/chip-with-icon.d.mts +0 -10
- package/dist/components/source-search-box/source-search-box.d.mts +0 -16
- package/dist/components/ui/button.d.mts +0 -14
- package/dist/components/ui/command.d.mts +0 -53
- package/dist/components/ui/dialog.d.mts +0 -19
- package/dist/components/ui/label.d.mts +0 -8
- package/dist/context/index.d.mts +0 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.mts +0 -15
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.d.mts +0 -8
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.mts +0 -7
- package/dist/hooks/index.d.mts +0 -2
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.mts +0 -22
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.mts +0 -23
- package/dist/hooks/misc/use-autosize-textarea.d.mts +0 -5
- package/dist/index.d.mts +0 -15
- package/dist/lib/debouncer.d.mts +0 -11
- package/dist/lib/editor-to-text.d.mts +0 -7
- package/dist/lib/get-text-around-cursor.d.mts +0 -15
- package/dist/lib/retry.d.mts +0 -3
- package/dist/lib/slatejs-edits/add-autocompletions.d.mts +0 -8
- package/dist/lib/slatejs-edits/clear-autocompletions.d.mts +0 -8
- package/dist/lib/slatejs-edits/replace-text.d.mts +0 -5
- package/dist/lib/slatejs-edits/with-partial-history.d.mts +0 -8
- package/dist/lib/stream-promise-flatten.d.mts +0 -12
- package/dist/lib/utils.d.mts +0 -9
- package/dist/lib/utils.test.d.mts +0 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.mts +0 -23
- package/dist/types/autosuggestions-config/autosuggestions-config.d.mts +0 -20
- package/dist/types/autosuggestions-config/editing-api-config.d.mts +0 -15
- package/dist/types/autosuggestions-config/index.d.mts +0 -10
- package/dist/types/autosuggestions-config/insertions-api-config.d.mts +0 -15
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.mts +0 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.d.mts +0 -14
- package/dist/types/base/autosuggestion-state.d.mts +0 -8
- package/dist/types/base/autosuggestions-bare-function.d.mts +0 -19
- package/dist/types/base/base-autosuggestions-config.d.mts +0 -83
- package/dist/types/base/base-copilot-textarea-props.d.mts +0 -5
- package/dist/types/base/custom-editor.d.mts +0 -29
- package/dist/types/base/editor-autocomplete-state.d.mts +0 -10
- package/dist/types/base/index.d.mts +0 -54
- package/dist/types/html-copilot-textarea-element.d.mts +0 -7
- package/dist/types/index.d.mts +0 -13
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addAutocompletionsToEditor
|
|
3
|
+
} from "./chunk-2C7O2EVM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
clearAutocompletionsFromEditor
|
|
6
|
+
} from "./chunk-GQN2HYFJ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useAutosuggestions
|
|
9
|
+
} from "./chunk-23Q6A46J.mjs";
|
|
10
|
+
import {
|
|
11
|
+
useCopilotTextareaEditor
|
|
12
|
+
} from "./chunk-DRV2FOHZ.mjs";
|
|
13
|
+
import {
|
|
14
|
+
usePopulateCopilotTextareaRef
|
|
15
|
+
} from "./chunk-QJNFNPWH.mjs";
|
|
16
|
+
import {
|
|
17
|
+
replaceEditorText
|
|
18
|
+
} from "./chunk-5UNJXFUO.mjs";
|
|
19
|
+
import {
|
|
20
|
+
TrackerTextEditedSinceLastCursorMovement
|
|
21
|
+
} from "./chunk-LQ2OWQU7.mjs";
|
|
22
|
+
import {
|
|
23
|
+
useAddBrandingCss
|
|
24
|
+
} from "./chunk-7LSRNPNI.mjs";
|
|
25
|
+
import {
|
|
26
|
+
HoveringToolbar
|
|
27
|
+
} from "./chunk-4AMCUMC7.mjs";
|
|
28
|
+
import {
|
|
29
|
+
HoveringEditorProvider,
|
|
30
|
+
useHoveringEditorContext
|
|
31
|
+
} from "./chunk-LYB4B6MK.mjs";
|
|
32
|
+
import {
|
|
33
|
+
defaultBaseAutosuggestionsConfig
|
|
34
|
+
} from "./chunk-4CVSOOJY.mjs";
|
|
35
|
+
import {
|
|
36
|
+
makeRenderElementFunction
|
|
37
|
+
} from "./chunk-224UKA7C.mjs";
|
|
38
|
+
import {
|
|
39
|
+
makeRenderPlaceholderFunction
|
|
40
|
+
} from "./chunk-XW3ICO4S.mjs";
|
|
41
|
+
import {
|
|
42
|
+
getFullEditorTextWithNewlines,
|
|
43
|
+
getTextAroundCollapsedCursor
|
|
44
|
+
} from "./chunk-ECR45NSD.mjs";
|
|
45
|
+
import {
|
|
46
|
+
__objRest,
|
|
47
|
+
__spreadProps,
|
|
48
|
+
__spreadValues
|
|
49
|
+
} from "./chunk-MRXNTQOX.mjs";
|
|
50
|
+
|
|
51
|
+
// src/components/base-copilot-textarea/base-copilot-textarea.tsx
|
|
52
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
53
|
+
import { Editor } from "slate";
|
|
54
|
+
import { Editable, Slate } from "slate-react";
|
|
55
|
+
import { twMerge } from "tailwind-merge";
|
|
56
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
57
|
+
var BaseCopilotTextarea = React.forwardRef(
|
|
58
|
+
(props, ref) => {
|
|
59
|
+
return /* @__PURE__ */ jsx(HoveringEditorProvider, { children: /* @__PURE__ */ jsx(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
var BaseCopilotTextareaWithHoveringContext = React.forwardRef(
|
|
63
|
+
(props, ref) => {
|
|
64
|
+
const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
|
|
65
|
+
const valueOnInitialRender = useMemo(() => {
|
|
66
|
+
var _a2;
|
|
67
|
+
return (_a2 = props.value) != null ? _a2 : "";
|
|
68
|
+
}, []);
|
|
69
|
+
const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);
|
|
70
|
+
const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);
|
|
71
|
+
const initialValue = useMemo(() => {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
type: "paragraph",
|
|
75
|
+
children: [{ text: valueOnInitialRender }]
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
}, [valueOnInitialRender]);
|
|
79
|
+
const editor = useCopilotTextareaEditor();
|
|
80
|
+
const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
|
|
81
|
+
const insertText = useCallback(
|
|
82
|
+
(autosuggestion) => {
|
|
83
|
+
Editor.insertText(editor, autosuggestion.text, {
|
|
84
|
+
at: autosuggestion.point
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
[editor]
|
|
88
|
+
);
|
|
89
|
+
const shouldDisableAutosuggestions = (
|
|
90
|
+
// textarea is manually disabled:
|
|
91
|
+
autosuggestionsConfig.disabled || // hovering editor is displayed:
|
|
92
|
+
hoveringEditorIsDisplayed || // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:
|
|
93
|
+
cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText
|
|
94
|
+
);
|
|
95
|
+
const {
|
|
96
|
+
currentAutocompleteSuggestion,
|
|
97
|
+
onChangeHandler: onChangeHandlerForAutocomplete,
|
|
98
|
+
onKeyDownHandler: onKeyDownHandlerForAutocomplete,
|
|
99
|
+
onTouchStartHandler: onTouchStartHandlerForAutocomplete
|
|
100
|
+
} = useAutosuggestions(
|
|
101
|
+
autosuggestionsConfig.debounceTime,
|
|
102
|
+
autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,
|
|
103
|
+
autosuggestionsConfig.shouldAcceptAutosuggestionOnTouch,
|
|
104
|
+
autosuggestionsConfig.apiConfig.autosuggestionsFunction,
|
|
105
|
+
insertText,
|
|
106
|
+
autosuggestionsConfig.disableWhenEmpty,
|
|
107
|
+
shouldDisableAutosuggestions
|
|
108
|
+
);
|
|
109
|
+
const onKeyDownHandlerForHoveringEditor = useCallback(
|
|
110
|
+
(event) => {
|
|
111
|
+
var _a2;
|
|
112
|
+
if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, (_a2 = props.shortcut) != null ? _a2 : "k")) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[
|
|
118
|
+
hoveringEditorIsDisplayed,
|
|
119
|
+
setHoveringEditorIsDisplayed,
|
|
120
|
+
autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
|
|
121
|
+
]
|
|
122
|
+
);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
clearAutocompletionsFromEditor(editor);
|
|
125
|
+
if (currentAutocompleteSuggestion) {
|
|
126
|
+
addAutocompletionsToEditor(
|
|
127
|
+
editor,
|
|
128
|
+
currentAutocompleteSuggestion.text,
|
|
129
|
+
currentAutocompleteSuggestion.point
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}, [currentAutocompleteSuggestion]);
|
|
133
|
+
const suggestionStyleAugmented = useMemo(() => {
|
|
134
|
+
return __spreadValues({
|
|
135
|
+
fontStyle: "italic",
|
|
136
|
+
color: "gray"
|
|
137
|
+
}, props.suggestionsStyle);
|
|
138
|
+
}, [props.suggestionsStyle]);
|
|
139
|
+
const renderElementMemoized = useMemo(() => {
|
|
140
|
+
return makeRenderElementFunction(suggestionStyleAugmented);
|
|
141
|
+
}, [suggestionStyleAugmented]);
|
|
142
|
+
const renderPlaceholderMemoized = useMemo(() => {
|
|
143
|
+
const placeholderStyleSlatejsOverrides = {
|
|
144
|
+
top: void 0
|
|
145
|
+
};
|
|
146
|
+
const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
|
|
147
|
+
return makeRenderPlaceholderFunction(placeholderStyleAugmented);
|
|
148
|
+
}, [props.placeholderStyle]);
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
var _a2, _b;
|
|
151
|
+
if (props.value === lastKnownFullEditorText) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
setLastKnownFullEditorText((_a2 = props.value) != null ? _a2 : "");
|
|
155
|
+
replaceEditorText(editor, (_b = props.value) != null ? _b : "");
|
|
156
|
+
}, [props.value]);
|
|
157
|
+
const _a = props, {
|
|
158
|
+
placeholderStyle,
|
|
159
|
+
value,
|
|
160
|
+
hoverMenuClassname,
|
|
161
|
+
onValueChange,
|
|
162
|
+
baseAutosuggestionsConfig: autosuggestionsConfigFromProps,
|
|
163
|
+
className,
|
|
164
|
+
onChange,
|
|
165
|
+
onKeyDown,
|
|
166
|
+
disableBranding
|
|
167
|
+
} = _a, propsToForward = __objRest(_a, [
|
|
168
|
+
"placeholderStyle",
|
|
169
|
+
"value",
|
|
170
|
+
"hoverMenuClassname",
|
|
171
|
+
"onValueChange",
|
|
172
|
+
"baseAutosuggestionsConfig",
|
|
173
|
+
"className",
|
|
174
|
+
"onChange",
|
|
175
|
+
"onKeyDown",
|
|
176
|
+
"disableBranding"
|
|
177
|
+
]);
|
|
178
|
+
useAddBrandingCss(suggestionStyleAugmented, disableBranding);
|
|
179
|
+
usePopulateCopilotTextareaRef(editor, ref);
|
|
180
|
+
const moddedClassName = (() => {
|
|
181
|
+
const baseClassName = "copilot-textarea";
|
|
182
|
+
const brandingClass = disableBranding ? "no-branding" : "with-branding";
|
|
183
|
+
const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
|
|
184
|
+
const mergedClassName = twMerge(defaultTailwindClassName, className != null ? className : "");
|
|
185
|
+
return `${baseClassName} ${brandingClass} ${mergedClassName}`;
|
|
186
|
+
})();
|
|
187
|
+
return /* @__PURE__ */ jsxs(
|
|
188
|
+
Slate,
|
|
189
|
+
{
|
|
190
|
+
editor,
|
|
191
|
+
initialValue,
|
|
192
|
+
onChange: (value2) => {
|
|
193
|
+
var _a2, _b;
|
|
194
|
+
const newEditorState = getTextAroundCollapsedCursor(editor);
|
|
195
|
+
const fullEditorText = newEditorState ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor : getFullEditorTextWithNewlines(editor);
|
|
196
|
+
setLastKnownFullEditorText((prev) => {
|
|
197
|
+
if (prev !== fullEditorText) {
|
|
198
|
+
setCursorMovedSinceLastTextChange(false);
|
|
199
|
+
}
|
|
200
|
+
return fullEditorText;
|
|
201
|
+
});
|
|
202
|
+
onChangeHandlerForAutocomplete(newEditorState);
|
|
203
|
+
(_a2 = props.onValueChange) == null ? void 0 : _a2.call(props, fullEditorText);
|
|
204
|
+
(_b = props.onChange) == null ? void 0 : _b.call(props, makeSemiFakeReactTextAreaEvent(fullEditorText));
|
|
205
|
+
},
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx(
|
|
208
|
+
TrackerTextEditedSinceLastCursorMovement,
|
|
209
|
+
{
|
|
210
|
+
setCursorMovedSinceLastTextChange
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
HoveringToolbar,
|
|
215
|
+
{
|
|
216
|
+
apiConfig: autosuggestionsConfig.apiConfig,
|
|
217
|
+
contextCategories: autosuggestionsConfig.contextCategories,
|
|
218
|
+
hoverMenuClassname
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
Editable,
|
|
223
|
+
__spreadValues({
|
|
224
|
+
renderElement: renderElementMemoized,
|
|
225
|
+
renderPlaceholder: renderPlaceholderMemoized,
|
|
226
|
+
onKeyDown: (event) => {
|
|
227
|
+
var _a2;
|
|
228
|
+
onKeyDownHandlerForHoveringEditor(event);
|
|
229
|
+
onKeyDownHandlerForAutocomplete(event);
|
|
230
|
+
(_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
|
|
231
|
+
},
|
|
232
|
+
onTouchStart: (event) => {
|
|
233
|
+
onTouchStartHandlerForAutocomplete(event);
|
|
234
|
+
},
|
|
235
|
+
className: moddedClassName,
|
|
236
|
+
onBlur: (ev) => {
|
|
237
|
+
var _a2;
|
|
238
|
+
(_a2 = props.onBlur) == null ? void 0 : _a2.call(props, ev);
|
|
239
|
+
clearAutocompletionsFromEditor(editor);
|
|
240
|
+
}
|
|
241
|
+
}, propsToForward)
|
|
242
|
+
)
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
249
|
+
return {
|
|
250
|
+
target: {
|
|
251
|
+
value: currentText,
|
|
252
|
+
type: "copilot-textarea"
|
|
253
|
+
},
|
|
254
|
+
currentTarget: {
|
|
255
|
+
value: currentText,
|
|
256
|
+
type: "copilot-textarea"
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export {
|
|
262
|
+
BaseCopilotTextarea
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=chunk-J62KUPFZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/base-copilot-textarea.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Descendant, Editor } from \"slate\";\nimport { Editable, Slate } from \"slate-react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useAutosuggestions } from \"../../hooks/base-copilot-textarea-implementation/use-autosuggestions\";\nimport { useCopilotTextareaEditor } from \"../../hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor\";\nimport { usePopulateCopilotTextareaRef } from \"../../hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundCollapsedCursor,\n} from \"../../lib/get-text-around-cursor\";\nimport { addAutocompletionsToEditor } from \"../../lib/slatejs-edits/add-autocompletions\";\nimport { clearAutocompletionsFromEditor } from \"../../lib/slatejs-edits/clear-autocompletions\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from \"../../types/base\";\nimport { AutosuggestionState } from \"../../types/base/autosuggestion-state\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport \"./base-copilot-textarea.css\";\nimport { HoveringToolbar } from \"../hovering-toolbar/hovering-toolbar\";\nimport { makeRenderElementFunction } from \"./render-element\";\nimport { makeRenderPlaceholderFunction } from \"./render-placeholder\";\nimport { useAddBrandingCss } from \"./use-add-branding-css\";\nimport {\n HoveringEditorProvider,\n useHoveringEditorContext,\n} from \"../hovering-toolbar/hovering-editor-provider\";\nimport { TrackerTextEditedSinceLastCursorMovement } from \"./track-cursor-moved-since-last-text-change\";\n\n/**\n * Purpose: to be used as the `ref` type for `CopilotTextarea` and `BaseCopilotTextarea`.\n *\n * This interface extends `HTMLElement`, and is the subset of `HTMLTextAreaElement` that \"actually matters\".\n * It provides the core functionality that consumers of `HTMLTextAreaElement` need 99.9% of the time:\n * - `value`: the current value of the textarea\n * - `focus`: make the textarea focused\n * - `blur`: make the textarea unfocused\n */\nexport interface HTMLCopilotTextAreaElement extends HTMLElement {\n /**\n * The current value of the textarea.\n */\n value: string;\n\n /**\n * focus on the textarea\n */\n focus: () => void;\n\n /**\n * unfocus the textarea.\n *\n * Called `blur` for syntactic compatibility with `HTMLTextAreaElement`.\n */\n blur: () => void;\n}\n\n/**\n * Not intended for direct use. Use CopilotTextarea instead.\n *\n * The `BaseCopilotTextarea` includes the basic UX component,\n * without the business logic / AI logic that makes the content useful and coherent.\n *\n * It is useful if you want to build your own backend, with fully custom business logic\n * for figuring out which contnet to fill in.\n */\nexport const BaseCopilotTextarea = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n return (\n <HoveringEditorProvider>\n <BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />\n </HoveringEditorProvider>\n );\n },\n);\n\n/**\n * Not intended for direct use. Use `CopilotTextarea` instead.\n *\n * This is the private core of the `BaseCopilotTextarea` component.\n * For practical purposes the implementation is cleaner assuming containment in a `HoveringEditorProviderContext`.\n *\n * Therefore we separate the core logic into this component,\n * and wrap it in a `HoveringEditorProviderContext` in `BaseCopilotTextarea`.\n */\nconst BaseCopilotTextareaWithHoveringContext = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n const autosuggestionsConfig: BaseAutosuggestionsConfig = {\n ...defaultBaseAutosuggestionsConfig,\n ...props.baseAutosuggestionsConfig,\n };\n\n const valueOnInitialRender = useMemo(() => props.value ?? \"\", []);\n const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);\n const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);\n\n // // When the editor text changes, we want to reset the `textEditedSinceLastCursorMovement` state.\n // useEffect(() => {\n // setCursorMovedSinceLastTextChange(false);\n // }, [lastKnownFullEditorText]);\n\n const initialValue: Descendant[] = useMemo(() => {\n return [\n {\n type: \"paragraph\",\n children: [{ text: valueOnInitialRender }],\n },\n ];\n }, [valueOnInitialRender]);\n\n const editor = useCopilotTextareaEditor();\n\n const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } =\n useHoveringEditorContext();\n\n const insertText = useCallback(\n (autosuggestion: AutosuggestionState) => {\n Editor.insertText(editor, autosuggestion.text, {\n at: autosuggestion.point,\n });\n },\n [editor],\n );\n\n const shouldDisableAutosuggestions =\n // textarea is manually disabled:\n autosuggestionsConfig.disabled ||\n // hovering editor is displayed:\n hoveringEditorIsDisplayed ||\n // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:\n (cursorMovedSinceLastTextChange &&\n autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText);\n\n const {\n currentAutocompleteSuggestion,\n onChangeHandler: onChangeHandlerForAutocomplete,\n onKeyDownHandler: onKeyDownHandlerForAutocomplete,\n onTouchStartHandler: onTouchStartHandlerForAutocomplete,\n } = useAutosuggestions(\n autosuggestionsConfig.debounceTime,\n autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,\n autosuggestionsConfig.shouldAcceptAutosuggestionOnTouch,\n autosuggestionsConfig.apiConfig.autosuggestionsFunction,\n insertText,\n autosuggestionsConfig.disableWhenEmpty,\n shouldDisableAutosuggestions,\n );\n\n const onKeyDownHandlerForHoveringEditor = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (\n autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event, props.shortcut ?? \"k\")\n ) {\n event.preventDefault();\n setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);\n }\n },\n [\n hoveringEditorIsDisplayed,\n setHoveringEditorIsDisplayed,\n autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress,\n ],\n );\n\n // sync autosuggestions state with the editor\n useEffect(() => {\n clearAutocompletionsFromEditor(editor);\n if (currentAutocompleteSuggestion) {\n addAutocompletionsToEditor(\n editor,\n currentAutocompleteSuggestion.text,\n currentAutocompleteSuggestion.point,\n );\n }\n }, [currentAutocompleteSuggestion]);\n\n const suggestionStyleAugmented: React.CSSProperties = useMemo(() => {\n return {\n fontStyle: \"italic\",\n color: \"gray\",\n ...props.suggestionsStyle,\n };\n }, [props.suggestionsStyle]);\n\n const renderElementMemoized = useMemo(() => {\n return makeRenderElementFunction(suggestionStyleAugmented);\n }, [suggestionStyleAugmented]);\n\n const renderPlaceholderMemoized = useMemo(() => {\n // For some reason slateJS specifies a top value of 0, which makes for strange styling. We override this here.\n const placeholderStyleSlatejsOverrides: React.CSSProperties = {\n top: undefined,\n };\n\n const placeholderStyleAugmented: React.CSSProperties = {\n ...placeholderStyleSlatejsOverrides,\n ...props.placeholderStyle,\n };\n\n return makeRenderPlaceholderFunction(placeholderStyleAugmented);\n }, [props.placeholderStyle]);\n\n // update the editor text, but only when the value changes from outside the component\n useEffect(() => {\n if (props.value === lastKnownFullEditorText) {\n return;\n }\n\n setLastKnownFullEditorText(props.value ?? \"\");\n replaceEditorText(editor, props.value ?? \"\");\n }, [props.value]);\n\n // separate into TextareaHTMLAttributes<HTMLDivElement> and CopilotTextareaProps\n const {\n placeholderStyle,\n value,\n hoverMenuClassname,\n onValueChange,\n baseAutosuggestionsConfig: autosuggestionsConfigFromProps,\n className,\n onChange,\n onKeyDown,\n disableBranding,\n ...propsToForward\n } = props;\n\n useAddBrandingCss(suggestionStyleAugmented, disableBranding);\n usePopulateCopilotTextareaRef(editor, ref);\n\n const moddedClassName = (() => {\n const baseClassName = \"copilot-textarea\";\n const brandingClass = disableBranding ? \"no-branding\" : \"with-branding\";\n const defaultTailwindClassName = \"bg-white overflow-y-auto resize-y\";\n const mergedClassName = twMerge(defaultTailwindClassName, className ?? \"\");\n return `${baseClassName} ${brandingClass} ${mergedClassName}`;\n })();\n\n return (\n <Slate\n editor={editor}\n initialValue={initialValue}\n onChange={(value) => {\n const newEditorState = getTextAroundCollapsedCursor(editor);\n\n const fullEditorText = newEditorState\n ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor\n : getFullEditorTextWithNewlines(editor); // we don't double-parse the editor. When `newEditorState` is null, we didn't parse the editor yet.\n\n setLastKnownFullEditorText((prev) => {\n if (prev !== fullEditorText) {\n setCursorMovedSinceLastTextChange(false);\n }\n return fullEditorText;\n });\n onChangeHandlerForAutocomplete(newEditorState);\n\n props.onValueChange?.(fullEditorText);\n props.onChange?.(makeSemiFakeReactTextAreaEvent(fullEditorText));\n }}\n >\n <TrackerTextEditedSinceLastCursorMovement\n setCursorMovedSinceLastTextChange={setCursorMovedSinceLastTextChange}\n />\n <HoveringToolbar\n apiConfig={autosuggestionsConfig.apiConfig}\n contextCategories={autosuggestionsConfig.contextCategories}\n hoverMenuClassname={hoverMenuClassname}\n />\n <Editable\n renderElement={renderElementMemoized}\n renderPlaceholder={renderPlaceholderMemoized}\n onKeyDown={(event) => {\n onKeyDownHandlerForHoveringEditor(event); // forward the event for internal use\n onKeyDownHandlerForAutocomplete(event); // forward the event for internal use\n props.onKeyDown?.(event); // forward the event for external use\n }}\n onTouchStart={(event) => {\n onTouchStartHandlerForAutocomplete(event); // forward the event for internal use\n }}\n className={moddedClassName}\n onBlur={(ev) => {\n // clear autocompletion on blur\n props.onBlur?.(ev);\n clearAutocompletionsFromEditor(editor);\n }}\n {...propsToForward}\n />\n </Slate>\n );\n },\n);\n\n// Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.\n// This is *extremely* common, and we want to support it.\n//\n// We can't support the full functionality, but in 99% of cases, the consumer only cares about the `event.target.value` property --\n// that's how they get the new value of the textarea.\n//\n// So, the tradeoff we are making is minimizing compiler complaint, with a small chance of runtime error.\n// The alternative would be defining a different onChange entrypoint (we actually do have that in `onValueChange`),\n// And starting to explain subtleties to users the moment they try to use the component for the first time for very basic functionality.\n//\n// If this proves problematic, we can always revisit this decision.\nfunction makeSemiFakeReactTextAreaEvent(\n currentText: string,\n): React.ChangeEvent<HTMLTextAreaElement> {\n return {\n target: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n currentTarget: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n } as React.ChangeEvent<HTMLTextAreaElement>;\n}\n"],"mappings":"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","names":["_a","value"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-D47EKHIF.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
6
|
+
import Chip from "@mui/material/Chip/Chip.js";
|
|
7
|
+
import Avatar from "@mui/material/Avatar/Avatar.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var IncludedFilesPreview = ({
|
|
10
|
+
includedFiles,
|
|
11
|
+
setIncludedFiles
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 mt-2", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Label, { className: "", children: "Included context:" }),
|
|
15
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
FileChipPreview,
|
|
18
|
+
{
|
|
19
|
+
filePointer,
|
|
20
|
+
onDelete: () => {
|
|
21
|
+
setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
`file-${filePointer.sourceApplication}.${filePointer.name}`
|
|
25
|
+
);
|
|
26
|
+
}) })
|
|
27
|
+
] });
|
|
28
|
+
};
|
|
29
|
+
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
Chip,
|
|
32
|
+
{
|
|
33
|
+
label: filePointer.name,
|
|
34
|
+
onDelete,
|
|
35
|
+
avatar: /* @__PURE__ */ jsx(
|
|
36
|
+
Avatar,
|
|
37
|
+
{
|
|
38
|
+
src: filePointer.iconImageUri,
|
|
39
|
+
alt: filePointer.sourceApplication,
|
|
40
|
+
sx: { backgroundColor: "transparent" }
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
IncludedFilesPreview,
|
|
49
|
+
FileChipPreview
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-KMVGEY7Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx"],"sourcesContent":["import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n"],"mappings":";;;;;AAGA,OAAO,UAAU;AACjB,OAAO,YAAY;AAYf,SACE,KADF;AALG,IAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AACF,MAAiC;AAC/B,SACE,qBAAC,SAAI,WAAU,4BACb;AAAA,wBAAC,SAAM,WAAU,IAAG,+BAAiB;AAAA,IACrC,oBAAC,SAAI,WAAU,wBACZ,wBAAc,IAAI,CAAC,aAAa,UAAU;AACzC,aACE;AAAA,QAAC;AAAA;AAAA,UAEC;AAAA,UACA,UAAU,MAAM;AACd,6BAAiB,CAAC,SAAS,KAAK,OAAO,CAAC,OAAO,OAAO,WAAW,CAAC;AAAA,UACpE;AAAA;AAAA,QAJK,QAAQ,YAAY,qBAAqB,YAAY;AAAA,MAK5D;AAAA,IAEJ,CAAC,GACH;AAAA,KACF;AAEJ;AAOO,IAAM,kBAAkB,CAAC,EAAE,aAAa,SAAS,MAA4B;AAClF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,YAAY;AAAA,MACnB;AAAA,MACA,QACE;AAAA,QAAC;AAAA;AAAA,UACC,KAAK,YAAY;AAAA,UACjB,KAAK,YAAY;AAAA,UACjB,IAAI,EAAE,iBAAiB,cAAc;AAAA;AAAA,MACtC;AAAA;AAAA,EAEL;AAEJ;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/lib/retry.tsx
|
|
2
|
+
function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
fn().then(resolve).catch((error) => {
|
|
5
|
+
if (retriesLeft === 1) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
retry(fn, retriesLeft - 1, interval * backoff, backoff).then(resolve).catch(reject);
|
|
11
|
+
}, interval);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
retry
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-KNQIEOFP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/retry.tsx"],"sourcesContent":["export function retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"],"mappings":";AAAO,SAAS,MACd,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-L7VVZH4Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
editorToText
|
|
3
|
+
} from "./chunk-T6MTDQZ7.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { useSlateSelector } from "slate-react";
|
|
8
|
+
import { Range } from "slate";
|
|
9
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
10
|
+
function TrackerTextEditedSinceLastCursorMovement(props) {
|
|
11
|
+
const cursorState = useSlateSelector((state) => ({
|
|
12
|
+
selection: state.selection,
|
|
13
|
+
text: editorToText(state)
|
|
14
|
+
}));
|
|
15
|
+
const previousState = usePrevious(cursorState);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!previousState) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (cursorChangedWithoutTextChanged(previousState, cursorState)) {
|
|
21
|
+
props.setCursorMovedSinceLastTextChange(true);
|
|
22
|
+
}
|
|
23
|
+
}, [props.setCursorMovedSinceLastTextChange, cursorState]);
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
25
|
+
}
|
|
26
|
+
var cursorChangedWithoutTextChanged = (prev, next) => {
|
|
27
|
+
const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
|
|
28
|
+
const isTextSame = prev.text === next.text;
|
|
29
|
+
return isSelectionChanged && isTextSame;
|
|
30
|
+
};
|
|
31
|
+
var isSelectionEqual = (a, b) => {
|
|
32
|
+
if (!a && !b)
|
|
33
|
+
return true;
|
|
34
|
+
if (!a || !b)
|
|
35
|
+
return false;
|
|
36
|
+
return Range.equals(a, b);
|
|
37
|
+
};
|
|
38
|
+
function usePrevious(value) {
|
|
39
|
+
const ref = useRef();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
ref.current = value;
|
|
42
|
+
});
|
|
43
|
+
return ref.current;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
TrackerTextEditedSinceLastCursorMovement
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk-LQ2OWQU7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { BaseSelection } from \"slate\";\nimport { useSlateSelector } from \"slate-react\";\nimport { Range } from \"slate\";\nimport { editorToText } from \"../../lib/editor-to-text\";\n\ninterface TrackerTextEditedSinceLastCursorMovementProps {\n setCursorMovedSinceLastTextChange: (value: boolean) => void;\n}\nexport function TrackerTextEditedSinceLastCursorMovement(\n props: TrackerTextEditedSinceLastCursorMovementProps,\n) {\n const cursorState: RelevantEditorState = useSlateSelector((state) => ({\n selection: state.selection,\n text: editorToText(state),\n }));\n\n const previousState = usePrevious(cursorState);\n\n useEffect(() => {\n if (!previousState) {\n return;\n }\n\n if (cursorChangedWithoutTextChanged(previousState, cursorState)) {\n props.setCursorMovedSinceLastTextChange(true);\n }\n }, [props.setCursorMovedSinceLastTextChange, cursorState]);\n\n return <></>;\n}\n\ntype RelevantEditorState = {\n selection: BaseSelection;\n text: string;\n};\n\nconst cursorChangedWithoutTextChanged = (\n prev: RelevantEditorState,\n next: RelevantEditorState,\n): boolean => {\n // Check if the selection has changed\n const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);\n\n // Check if the text content remains the same\n const isTextSame = prev.text === next.text;\n\n return isSelectionChanged && isTextSame;\n};\n\nconst isSelectionEqual = (a: BaseSelection, b: BaseSelection) => {\n if (!a && !b) return true;\n if (!a || !b) return false;\n return Range.equals(a, b);\n};\n\n/**\n * Easily keep track of the *previous* value of a variable.\n *\n * Example:\n * ```\n * const [count, setCount] = useState(0);\n * const prevCount = usePrevious(count);\n *\n * useEffect(() => {\n * if (count > prevCount) {\n * console.log('Now I know that count is bigger than before');\n * }\n * }, [count, prevCount]);\n * ```\n */\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,cAAc;AAElC,SAAS,wBAAwB;AACjC,SAAS,aAAa;AA0Bb;AApBF,SAAS,yCACd,OACA;AACA,QAAM,cAAmC,iBAAiB,CAAC,WAAW;AAAA,IACpE,WAAW,MAAM;AAAA,IACjB,MAAM,aAAa,KAAK;AAAA,EAC1B,EAAE;AAEF,QAAM,gBAAgB,YAAY,WAAW;AAE7C,YAAU,MAAM;AACd,QAAI,CAAC,eAAe;AAClB;AAAA,IACF;AAEA,QAAI,gCAAgC,eAAe,WAAW,GAAG;AAC/D,YAAM,kCAAkC,IAAI;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,MAAM,mCAAmC,WAAW,CAAC;AAEzD,SAAO,gCAAE;AACX;AAOA,IAAM,kCAAkC,CACtC,MACA,SACY;AAEZ,QAAM,qBAAqB,CAAC,iBAAiB,KAAK,WAAW,KAAK,SAAS;AAG3E,QAAM,aAAa,KAAK,SAAS,KAAK;AAEtC,SAAO,sBAAsB;AAC/B;AAEA,IAAM,mBAAmB,CAAC,GAAkB,MAAqB;AAC/D,MAAI,CAAC,KAAK,CAAC;AAAG,WAAO;AACrB,MAAI,CAAC,KAAK,CAAC;AAAG,WAAO;AACrB,SAAO,MAAM,OAAO,GAAG,CAAC;AAC1B;AAiBA,SAAS,YAAe,OAAyB;AAC/C,QAAM,MAAM,OAAU;AAEtB,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,IAAI;AACb;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/components/hovering-toolbar/hovering-editor-provider.tsx
|
|
2
|
+
import { createContext, useState, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var HoveringEditorContext = createContext({
|
|
5
|
+
isDisplayed: false,
|
|
6
|
+
setIsDisplayed: () => {
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
var HoveringEditorProvider = ({ children }) => {
|
|
10
|
+
const [isDisplayed, setIsDisplayed] = useState(false);
|
|
11
|
+
return /* @__PURE__ */ jsx(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
|
|
12
|
+
};
|
|
13
|
+
var useHoveringEditorContext = () => useContext(HoveringEditorContext);
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
HoveringEditorProvider,
|
|
17
|
+
useHoveringEditorContext
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-LYB4B6MK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-editor-provider.tsx"],"sourcesContent":["import { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\nexport interface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\n/**\n * A context provider for the hovering editor over the `CopilotTextarea`\n * (used to edit and insert text into the `CopilotTextarea`).\n */\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState<boolean>(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n"],"mappings":";AAAA,SAAS,eAAe,UAAU,kBAA6B;AAwB3D;AAjBJ,IAAM,wBAAwB,cAA0C;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AACzB,CAAC;AAUM,IAAM,yBAAyB,CAAC,EAAE,SAAS,MAAmC;AACnF,QAAM,CAAC,aAAa,cAAc,IAAI,SAAkB,KAAK;AAE7D,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,aAAa,eAAe,GAClE,UACH;AAEJ;AAEO,IAAM,2BAA2B,MAAM,WAAW,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/types/autosuggestions-config/insertions-api-config.tsx
|
|
2
|
+
import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
3
|
+
var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
4
|
+
return `You are a versatile writing assistant helping the user insert new text into their existing work.
|
|
5
|
+
|
|
6
|
+
The user is writing some text.
|
|
7
|
+
The purpose is: "${textareaPurpose}"
|
|
8
|
+
|
|
9
|
+
The following external context is also provided. Use it to inform your suggestions when relevant!!!
|
|
10
|
+
\`\`\`
|
|
11
|
+
${contextString}
|
|
12
|
+
\`\`\`
|
|
13
|
+
|
|
14
|
+
The user will provide you with a prompt for an INSERTION into the text they are writing.
|
|
15
|
+
Your job is to come up with an INSERTION into the text that the user would like to use, AS BEST YOU CAN.
|
|
16
|
+
Only insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.
|
|
17
|
+
|
|
18
|
+
Adjust yourself to the user's style and implied intent.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
The user will provide the text before and after the cursor, as well as the INSERTION prompt. You should use this to infer the best relevant insertion.
|
|
22
|
+
The conversation will be structured as follows:
|
|
23
|
+
<TextAfterCursor>
|
|
24
|
+
<TextBeforeCursor>
|
|
25
|
+
<InsertionPrompt>
|
|
26
|
+
|
|
27
|
+
<YourInsertionSuggestion>
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
30
|
+
var defaultInsertionsFewShotMessages = [
|
|
31
|
+
new TextMessage({
|
|
32
|
+
role: Role.User,
|
|
33
|
+
content: "<TextAfterCursor>While I was there I also picked up some apples, oranges, and bananas.</TextAfterCursor>"
|
|
34
|
+
}),
|
|
35
|
+
new TextMessage({
|
|
36
|
+
role: Role.User,
|
|
37
|
+
content: "<TextBeforeCursor>This morning I woke up and went straight to the grocery store.</TextBeforeCursor>"
|
|
38
|
+
}),
|
|
39
|
+
new TextMessage({
|
|
40
|
+
role: Role.User,
|
|
41
|
+
content: "<InsertionPrompt>I bought a big watermelon</InsertionPrompt>"
|
|
42
|
+
}),
|
|
43
|
+
new TextMessage({
|
|
44
|
+
role: Role.Assistant,
|
|
45
|
+
content: "When I arrived I went straight to the produce section and picked out a big watermelon."
|
|
46
|
+
}),
|
|
47
|
+
new TextMessage({
|
|
48
|
+
role: Role.User,
|
|
49
|
+
content: "<TextAfterCursor>and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.</TextAfterCursor>"
|
|
50
|
+
}),
|
|
51
|
+
new TextMessage({
|
|
52
|
+
role: Role.User,
|
|
53
|
+
content: `<TextBeforeCursor>The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;</TextBeforeCursor>`
|
|
54
|
+
}),
|
|
55
|
+
new TextMessage({
|
|
56
|
+
role: Role.User,
|
|
57
|
+
content: "<InsertionPrompt>add section about the optionholder's pro rata share</InsertionPrompt>"
|
|
58
|
+
}),
|
|
59
|
+
new TextMessage({
|
|
60
|
+
role: Role.Assistant,
|
|
61
|
+
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
62
|
+
})
|
|
63
|
+
];
|
|
64
|
+
var defaultInsertionsApiConfig = {
|
|
65
|
+
makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
|
|
66
|
+
fewShotMessages: defaultInsertionsFewShotMessages,
|
|
67
|
+
forwardedParams: void 0
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
defaultInsertionsMakeSystemPrompt,
|
|
72
|
+
defaultInsertionsFewShotMessages,
|
|
73
|
+
defaultInsertionsApiConfig
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=chunk-MCNXIA4Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/insertions-api-config.tsx"],"sourcesContent":["import { Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface InsertionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: Message[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant helping the user insert new text into their existing work.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to inform your suggestions when relevant!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user will provide you with a prompt for an INSERTION into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like to use, AS BEST YOU CAN.\nOnly insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\n\nThe user will provide the text before and after the cursor, as well as the INSERTION prompt. You should use this to infer the best relevant insertion.\nThe conversation will be structured as follows:\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n\n<YourInsertionSuggestion>\n`;\n};\n\nexport const defaultInsertionsFewShotMessages: Message[] = [\n new TextMessage({\n role: Role.User,\n content:\n \"<TextAfterCursor>While I was there I also picked up some apples, oranges, and bananas.</TextAfterCursor>\",\n }),\n new TextMessage({\n role: Role.User,\n content:\n \"<TextBeforeCursor>This morning I woke up and went straight to the grocery store.</TextBeforeCursor>\",\n }),\n new TextMessage({\n role: Role.User,\n content: \"<InsertionPrompt>I bought a big watermelon</InsertionPrompt>\",\n }),\n new TextMessage({\n role: Role.Assistant,\n content:\n \"When I arrived I went straight to the produce section and picked out a big watermelon.\",\n }),\n new TextMessage({\n role: Role.User,\n content:\n \"<TextAfterCursor>and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.</TextAfterCursor>\",\n }),\n new TextMessage({\n role: Role.User,\n content:\n '<TextBeforeCursor>The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;</TextBeforeCursor>',\n }),\n new TextMessage({\n role: Role.User,\n content:\n \"<InsertionPrompt>add section about the optionholder's pro rata share</InsertionPrompt>\",\n }),\n new TextMessage({\n role: Role.Assistant,\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n }),\n];\n\nexport const defaultInsertionsApiConfig: InsertionsApiConfig = {\n makeSystemPrompt: defaultInsertionsMakeSystemPrompt,\n fewShotMessages: defaultInsertionsFewShotMessages,\n forwardedParams: undefined,\n};\n"],"mappings":";AAAA,SAAkB,MAAM,mBAAmB;AASpC,IAAM,oCAAsD,CACjE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBF;AAEO,IAAM,mCAA8C;AAAA,EACzD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SAAS;AAAA,EACX,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AAAA,EACD,IAAI,YAAY;AAAA,IACd,MAAM,KAAK;AAAA,IACX,SACE;AAAA,EACJ,CAAC;AACH;AAEO,IAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-MMVDU6DF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
export {
|
|
54
|
+
__spreadValues,
|
|
55
|
+
__spreadProps,
|
|
56
|
+
__objRest,
|
|
57
|
+
__async
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-MRXNTQOX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|