@copilotkit/react-textarea 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454
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 +2456 -0
- package/README.md +46 -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-2VMZ5ZWT.mjs +229 -0
- package/dist/chunk-2VMZ5ZWT.mjs.map +1 -0
- package/dist/chunk-3PQ7GSFE.mjs +17 -0
- package/dist/chunk-3PQ7GSFE.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-4XXU5BSA.mjs +125 -0
- package/dist/chunk-4XXU5BSA.mjs.map +1 -0
- package/dist/chunk-5UNJXFUO.mjs +29 -0
- package/dist/chunk-5UNJXFUO.mjs.map +1 -0
- package/dist/chunk-7L6GIHDM.mjs +39 -0
- package/dist/chunk-7L6GIHDM.mjs.map +1 -0
- package/dist/chunk-7LSRNPNI.mjs +59 -0
- package/dist/chunk-7LSRNPNI.mjs.map +1 -0
- package/dist/chunk-ABYCGF77.mjs +31 -0
- package/dist/chunk-ABYCGF77.mjs.map +1 -0
- package/dist/chunk-AJ5OMEXM.mjs +13 -0
- package/dist/chunk-AJ5OMEXM.mjs.map +1 -0
- package/dist/chunk-BNBGJBBM.mjs +60 -0
- package/dist/chunk-BNBGJBBM.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-F6GMWOLE.mjs +93 -0
- package/dist/chunk-F6GMWOLE.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-HDBI2WN5.mjs +113 -0
- package/dist/chunk-HDBI2WN5.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-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-MGYT7RNL.mjs +32 -0
- package/dist/chunk-MGYT7RNL.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-PZYM7K4Y.mjs +265 -0
- package/dist/chunk-PZYM7K4Y.mjs.map +1 -0
- package/dist/chunk-QFXR6DOA.mjs +64 -0
- package/dist/chunk-QFXR6DOA.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-RXV67GJN.mjs +168 -0
- package/dist/chunk-RXV67GJN.mjs.map +1 -0
- package/dist/chunk-T6MTDQZ7.mjs +45 -0
- package/dist/chunk-T6MTDQZ7.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 +43 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +1795 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +40 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/render-element.d.ts +6 -0
- package/dist/components/base-copilot-textarea/render-element.js +75 -0
- package/dist/components/base-copilot-textarea/render-element.js.map +1 -0
- package/dist/components/base-copilot-textarea/render-element.mjs +8 -0
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/render-placeholder.d.ts +6 -0
- package/dist/components/base-copilot-textarea/render-placeholder.js +72 -0
- package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -0
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +8 -0
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +8 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +112 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +9 -0
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/use-add-branding-css.d.ts +3 -0
- package/dist/components/base-copilot-textarea/use-add-branding-css.js +83 -0
- package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -0
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +8 -0
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -0
- 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 +171 -0
- package/dist/components/copilot-textarea/copilot-textarea.js +2289 -0
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -0
- package/dist/components/copilot-textarea/copilot-textarea.mjs +49 -0
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +18 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.js +44 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +10 -0
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +18 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js +174 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +16 -0
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +12 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.js +912 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +23 -0
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.d.ts +16 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +606 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +18 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +14 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +629 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +19 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -0
- 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.d.ts +4 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +629 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +20 -0
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -0
- package/dist/components/index.css +9 -0
- package/dist/components/index.css.map +1 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.js +2293 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +53 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/manual-ui/chip-with-icon.d.ts +10 -0
- package/dist/components/manual-ui/chip-with-icon.js +38 -0
- package/dist/components/manual-ui/chip-with-icon.js.map +1 -0
- package/dist/components/manual-ui/chip-with-icon.mjs +15 -0
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -0
- package/dist/components/source-search-box/source-search-box.d.ts +16 -0
- package/dist/components/source-search-box/source-search-box.js +240 -0
- package/dist/components/source-search-box/source-search-box.js.map +1 -0
- package/dist/components/source-search-box/source-search-box.mjs +13 -0
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/button.js +114 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/button.mjs +11 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/command.d.ts +53 -0
- package/dist/components/ui/command.js +285 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/command.mjs +26 -0
- package/dist/components/ui/command.mjs.map +1 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +183 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dialog.mjs +21 -0
- package/dist/components/ui/dialog.mjs.map +1 -0
- package/dist/components/ui/label.d.ts +8 -0
- package/dist/components/ui/label.js +87 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/label.mjs +9 -0
- package/dist/components/ui/label.mjs.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +19 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +15 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +180 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +11 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.d.ts +8 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js +194 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +9 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts +7 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js +180 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +10 -0
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +22 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +153 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +9 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +23 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +228 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +9 -0
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -0
- package/dist/hooks/misc/use-autosize-textarea.d.ts +5 -0
- package/dist/hooks/misc/use-autosize-textarea.js +37 -0
- package/dist/hooks/misc/use-autosize-textarea.js.map +1 -0
- package/dist/hooks/misc/use-autosize-textarea.mjs +8 -0
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -0
- package/dist/index.css +644 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2298 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +64 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/debouncer.d.ts +11 -0
- package/dist/lib/debouncer.js +76 -0
- package/dist/lib/debouncer.js.map +1 -0
- package/dist/lib/debouncer.mjs +8 -0
- package/dist/lib/debouncer.mjs.map +1 -0
- package/dist/lib/editor-to-text.d.ts +7 -0
- package/dist/lib/editor-to-text.js +69 -0
- package/dist/lib/editor-to-text.js.map +1 -0
- package/dist/lib/editor-to-text.mjs +8 -0
- package/dist/lib/editor-to-text.mjs.map +1 -0
- package/dist/lib/get-text-around-cursor.d.ts +15 -0
- package/dist/lib/get-text-around-cursor.js +131 -0
- package/dist/lib/get-text-around-cursor.js.map +1 -0
- package/dist/lib/get-text-around-cursor.mjs +14 -0
- package/dist/lib/get-text-around-cursor.mjs.map +1 -0
- package/dist/lib/retry.d.ts +3 -0
- package/dist/lib/retry.js +43 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/lib/retry.mjs +8 -0
- package/dist/lib/retry.mjs.map +1 -0
- package/dist/lib/slatejs-edits/add-autocompletions.d.ts +8 -0
- package/dist/lib/slatejs-edits/add-autocompletions.js +51 -0
- package/dist/lib/slatejs-edits/add-autocompletions.js.map +1 -0
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +8 -0
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -0
- package/dist/lib/slatejs-edits/clear-autocompletions.d.ts +8 -0
- package/dist/lib/slatejs-edits/clear-autocompletions.js +46 -0
- package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -0
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +8 -0
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -0
- package/dist/lib/slatejs-edits/replace-text.d.ts +5 -0
- package/dist/lib/slatejs-edits/replace-text.js +53 -0
- package/dist/lib/slatejs-edits/replace-text.js.map +1 -0
- package/dist/lib/slatejs-edits/replace-text.mjs +8 -0
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -0
- package/dist/lib/slatejs-edits/with-partial-history.d.ts +8 -0
- package/dist/lib/slatejs-edits/with-partial-history.js +133 -0
- package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -0
- package/dist/lib/slatejs-edits/with-partial-history.mjs +10 -0
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -0
- package/dist/lib/stream-promise-flatten.d.ts +12 -0
- package/dist/lib/stream-promise-flatten.js +72 -0
- package/dist/lib/stream-promise-flatten.js.map +1 -0
- package/dist/lib/stream-promise-flatten.mjs +8 -0
- package/dist/lib/stream-promise-flatten.mjs.map +1 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.js +94 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +16 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/lib/utils.test.d.ts +2 -0
- package/dist/lib/utils.test.js +9 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/lib/utils.test.mjs +7 -0
- package/dist/lib/utils.test.mjs.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +23 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js +19 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +20 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.js +287 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +13 -0
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -0
- package/dist/types/autosuggestions-config/editing-api-config.d.ts +15 -0
- package/dist/types/autosuggestions-config/editing-api-config.js +108 -0
- package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -0
- package/dist/types/autosuggestions-config/editing-api-config.mjs +12 -0
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -0
- package/dist/types/autosuggestions-config/index.d.ts +10 -0
- package/dist/types/autosuggestions-config/index.js +287 -0
- package/dist/types/autosuggestions-config/index.js.map +1 -0
- package/dist/types/autosuggestions-config/index.mjs +14 -0
- package/dist/types/autosuggestions-config/index.mjs.map +1 -0
- package/dist/types/autosuggestions-config/insertions-api-config.d.ts +15 -0
- package/dist/types/autosuggestions-config/insertions-api-config.js +101 -0
- package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -0
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +12 -0
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.ts +3 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +19 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +1 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +15 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.js +90 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +12 -0
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -0
- package/dist/types/base/autosuggestion-state.d.ts +8 -0
- package/dist/types/base/autosuggestion-state.js +19 -0
- package/dist/types/base/autosuggestion-state.js.map +1 -0
- package/dist/types/base/autosuggestion-state.mjs +1 -0
- package/dist/types/base/autosuggestion-state.mjs.map +1 -0
- package/dist/types/base/autosuggestions-bare-function.d.ts +19 -0
- package/dist/types/base/autosuggestions-bare-function.js +19 -0
- package/dist/types/base/autosuggestions-bare-function.js.map +1 -0
- package/dist/types/base/autosuggestions-bare-function.mjs +1 -0
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -0
- package/dist/types/base/base-autosuggestions-config.d.ts +83 -0
- package/dist/types/base/base-autosuggestions-config.js +54 -0
- package/dist/types/base/base-autosuggestions-config.js.map +1 -0
- package/dist/types/base/base-autosuggestions-config.mjs +8 -0
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -0
- package/dist/types/base/base-copilot-textarea-props.d.ts +5 -0
- package/dist/types/base/base-copilot-textarea-props.js +19 -0
- package/dist/types/base/base-copilot-textarea-props.js.map +1 -0
- package/dist/types/base/base-copilot-textarea-props.mjs +1 -0
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -0
- package/dist/types/base/custom-editor.d.ts +29 -0
- package/dist/types/base/custom-editor.js +19 -0
- package/dist/types/base/custom-editor.js.map +1 -0
- package/dist/types/base/custom-editor.mjs +1 -0
- package/dist/types/base/custom-editor.mjs.map +1 -0
- package/dist/types/base/editor-autocomplete-state.d.ts +10 -0
- package/dist/types/base/editor-autocomplete-state.js +40 -0
- package/dist/types/base/editor-autocomplete-state.js.map +1 -0
- package/dist/types/base/editor-autocomplete-state.mjs +9 -0
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -0
- package/dist/types/base/index.d.ts +54 -0
- package/dist/types/base/index.js +56 -0
- package/dist/types/base/index.js.map +1 -0
- package/dist/types/base/index.mjs +9 -0
- package/dist/types/base/index.mjs.map +1 -0
- package/dist/types/html-copilot-textarea-element.d.ts +7 -0
- package/dist/types/html-copilot-textarea-element.js +19 -0
- package/dist/types/html-copilot-textarea-element.js.map +1 -0
- package/dist/types/html-copilot-textarea-element.mjs +2 -0
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +289 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +19 -0
- package/dist/types/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +95 -0
- package/postcss.config.js +12 -0
- package/src/components/base-copilot-textarea/base-copilot-textarea.css +9 -0
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +317 -0
- package/src/components/base-copilot-textarea/render-element.tsx +39 -0
- package/src/components/base-copilot-textarea/render-placeholder.tsx +23 -0
- package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +80 -0
- package/src/components/base-copilot-textarea/use-add-branding-css.tsx +74 -0
- package/src/components/copilot-textarea/copilot-textarea.tsx +210 -0
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +31 -0
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +100 -0
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +151 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +276 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx +31 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +55 -0
- package/src/components/hovering-toolbar/text-insertion-prompt-box/index.ts +2 -0
- package/src/components/index.ts +4 -0
- package/src/components/manual-ui/chip-with-icon.tsx +17 -0
- package/src/components/source-search-box/source-search-box.tsx +117 -0
- package/src/components/ui/button.tsx +49 -0
- package/src/components/ui/command.tsx +141 -0
- package/src/components/ui/dialog.tsx +107 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/context/index.ts +1 -0
- package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +142 -0
- package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +100 -0
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +93 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +114 -0
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +214 -0
- package/src/hooks/misc/use-autosize-textarea.tsx +18 -0
- package/src/index.tsx +7 -0
- package/src/lib/debouncer.ts +36 -0
- package/src/lib/editor-to-text.ts +61 -0
- package/src/lib/get-text-around-cursor.ts +135 -0
- package/src/lib/retry.tsx +23 -0
- package/src/lib/slatejs-edits/add-autocompletions.ts +30 -0
- package/src/lib/slatejs-edits/clear-autocompletions.ts +19 -0
- package/src/lib/slatejs-edits/replace-text.ts +28 -0
- package/src/lib/slatejs-edits/with-partial-history.ts +149 -0
- package/src/lib/stream-promise-flatten.ts +33 -0
- package/src/lib/utils.test.ts +7 -0
- package/src/lib/utils.ts +49 -0
- package/src/styles.css +3 -0
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +19 -0
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +30 -0
- package/src/types/autosuggestions-config/editing-api-config.tsx +96 -0
- package/src/types/autosuggestions-config/index.ts +8 -0
- package/src/types/autosuggestions-config/insertions-api-config.tsx +87 -0
- package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +1 -0
- package/src/types/autosuggestions-config/suggestions-api-config.tsx +76 -0
- package/src/types/base/autosuggestion-state.ts +6 -0
- package/src/types/base/autosuggestions-bare-function.ts +30 -0
- package/src/types/base/base-autosuggestions-config.tsx +123 -0
- package/src/types/base/base-copilot-textarea-props.tsx +58 -0
- package/src/types/base/custom-editor.tsx +29 -0
- package/src/types/base/editor-autocomplete-state.ts +20 -0
- package/src/types/base/index.ts +6 -0
- package/src/types/html-copilot-textarea-element.ts +5 -0
- package/src/types/index.ts +3 -0
- package/tailwind.config.js +9 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +16 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DialogProps } from "@radix-ui/react-dialog";
|
|
3
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
import { Dialog, DialogContent } from "./dialog";
|
|
6
|
+
|
|
7
|
+
const Command = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<CommandPrimitive
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
));
|
|
20
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
21
|
+
|
|
22
|
+
interface CommandDialogProps extends DialogProps {}
|
|
23
|
+
|
|
24
|
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
|
25
|
+
return (
|
|
26
|
+
<Dialog {...props}>
|
|
27
|
+
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
|
28
|
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
29
|
+
{children}
|
|
30
|
+
</Command>
|
|
31
|
+
</DialogContent>
|
|
32
|
+
</Dialog>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const CommandInput = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
39
|
+
>(({ className, ...props }, ref) => (
|
|
40
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
41
|
+
{/* <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" /> */}
|
|
42
|
+
<CommandPrimitive.Input
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
));
|
|
52
|
+
|
|
53
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
54
|
+
|
|
55
|
+
const CommandList = React.forwardRef<
|
|
56
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<CommandPrimitive.List
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
67
|
+
|
|
68
|
+
const CommandEmpty = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
70
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
71
|
+
>((props, ref) => (
|
|
72
|
+
<CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
|
|
73
|
+
));
|
|
74
|
+
|
|
75
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
76
|
+
|
|
77
|
+
const CommandGroup = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
79
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
80
|
+
>(({ className, ...props }, ref) => (
|
|
81
|
+
<CommandPrimitive.Group
|
|
82
|
+
ref={ref}
|
|
83
|
+
className={cn(
|
|
84
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
85
|
+
className,
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
));
|
|
90
|
+
|
|
91
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
92
|
+
|
|
93
|
+
const CommandSeparator = React.forwardRef<
|
|
94
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
95
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
96
|
+
>(({ className, ...props }, ref) => (
|
|
97
|
+
<CommandPrimitive.Separator
|
|
98
|
+
ref={ref}
|
|
99
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
100
|
+
{...props}
|
|
101
|
+
/>
|
|
102
|
+
));
|
|
103
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
104
|
+
|
|
105
|
+
const CommandItem = React.forwardRef<
|
|
106
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
107
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
108
|
+
>(({ className, ...props }, ref) => (
|
|
109
|
+
<CommandPrimitive.Item
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
"relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
));
|
|
118
|
+
|
|
119
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
120
|
+
|
|
121
|
+
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
122
|
+
return (
|
|
123
|
+
<span
|
|
124
|
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
Command,
|
|
133
|
+
CommandDialog,
|
|
134
|
+
CommandInput,
|
|
135
|
+
CommandList,
|
|
136
|
+
CommandEmpty,
|
|
137
|
+
CommandGroup,
|
|
138
|
+
CommandItem,
|
|
139
|
+
CommandShortcut,
|
|
140
|
+
CommandSeparator,
|
|
141
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
10
|
+
|
|
11
|
+
const DialogPortal = ({
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
...props
|
|
15
|
+
}: DialogPrimitive.DialogPortalProps & { className?: string }) => (
|
|
16
|
+
<DialogPrimitive.Portal {...props}>
|
|
17
|
+
<div className={cn(className)}>{children}</div>
|
|
18
|
+
</DialogPrimitive.Portal>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
22
|
+
|
|
23
|
+
const DialogOverlay = React.forwardRef<
|
|
24
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
25
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
26
|
+
>(({ className, ...props }, ref) => (
|
|
27
|
+
<DialogPrimitive.Overlay
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cn(
|
|
30
|
+
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
));
|
|
36
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
37
|
+
|
|
38
|
+
const DialogContent = React.forwardRef<
|
|
39
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
40
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
41
|
+
>(({ className, children, ...props }, ref) => (
|
|
42
|
+
<DialogPortal>
|
|
43
|
+
<DialogOverlay />
|
|
44
|
+
<DialogPrimitive.Content
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
54
|
+
<X className="h-4 w-4" />
|
|
55
|
+
<span className="sr-only">Close</span>
|
|
56
|
+
</DialogPrimitive.Close>
|
|
57
|
+
</DialogPrimitive.Content>
|
|
58
|
+
</DialogPortal>
|
|
59
|
+
));
|
|
60
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
61
|
+
|
|
62
|
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
63
|
+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
|
64
|
+
);
|
|
65
|
+
DialogHeader.displayName = "DialogHeader";
|
|
66
|
+
|
|
67
|
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
68
|
+
<div
|
|
69
|
+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
DialogFooter.displayName = "DialogFooter";
|
|
74
|
+
|
|
75
|
+
const DialogTitle = React.forwardRef<
|
|
76
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
77
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
78
|
+
>(({ className, ...props }, ref) => (
|
|
79
|
+
<DialogPrimitive.Title
|
|
80
|
+
ref={ref}
|
|
81
|
+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
));
|
|
85
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
86
|
+
|
|
87
|
+
const DialogDescription = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
90
|
+
>(({ className, ...props }, ref) => (
|
|
91
|
+
<DialogPrimitive.Description
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
));
|
|
97
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
Dialog,
|
|
101
|
+
DialogTrigger,
|
|
102
|
+
DialogContent,
|
|
103
|
+
DialogHeader,
|
|
104
|
+
DialogFooter,
|
|
105
|
+
DialogTitle,
|
|
106
|
+
DialogDescription,
|
|
107
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const Label = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
|
16
|
+
));
|
|
17
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
18
|
+
|
|
19
|
+
export { Label };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { Debouncer } from "../../lib/debouncer";
|
|
3
|
+
import { nullableCompatibleEqualityCheck } from "../../lib/utils";
|
|
4
|
+
import { AutosuggestionsBareFunction } from "../../types/base";
|
|
5
|
+
import { AutosuggestionState } from "../../types/base/autosuggestion-state";
|
|
6
|
+
import {
|
|
7
|
+
EditorAutocompleteState,
|
|
8
|
+
areEqual_autocompleteState,
|
|
9
|
+
} from "../../types/base/editor-autocomplete-state";
|
|
10
|
+
|
|
11
|
+
export interface UseAutosuggestionsResult {
|
|
12
|
+
currentAutocompleteSuggestion: AutosuggestionState | null;
|
|
13
|
+
onChangeHandler: (newEditorState: EditorAutocompleteState | null) => void;
|
|
14
|
+
onKeyDownHandler: (event: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
15
|
+
onTouchStartHandler: (event: React.TouchEvent<HTMLDivElement>) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useAutosuggestions(
|
|
19
|
+
debounceTime: number,
|
|
20
|
+
shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean,
|
|
21
|
+
shouldAcceptAutosuggestionOnTouch: (event: React.TouchEvent<HTMLDivElement>) => boolean,
|
|
22
|
+
autosuggestionFunction: AutosuggestionsBareFunction,
|
|
23
|
+
insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,
|
|
24
|
+
disableWhenEmpty: boolean,
|
|
25
|
+
disabled: boolean,
|
|
26
|
+
): UseAutosuggestionsResult {
|
|
27
|
+
const [previousAutocompleteState, setPreviousAutocompleteState] =
|
|
28
|
+
useState<EditorAutocompleteState | null>(null);
|
|
29
|
+
|
|
30
|
+
const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] =
|
|
31
|
+
useState<AutosuggestionState | null>(null);
|
|
32
|
+
|
|
33
|
+
const awaitForAndAppendSuggestion: (
|
|
34
|
+
editorAutocompleteState: EditorAutocompleteState,
|
|
35
|
+
abortSignal: AbortSignal,
|
|
36
|
+
) => Promise<void> = useCallback(
|
|
37
|
+
async (editorAutocompleteState: EditorAutocompleteState, abortSignal: AbortSignal) => {
|
|
38
|
+
// early return if disabled
|
|
39
|
+
if (disabled) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
disableWhenEmpty &&
|
|
45
|
+
editorAutocompleteState.textBeforeCursor === "" &&
|
|
46
|
+
editorAutocompleteState.textAfterCursor === ""
|
|
47
|
+
) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// fetch the suggestion
|
|
52
|
+
const suggestion = await autosuggestionFunction(editorAutocompleteState, abortSignal);
|
|
53
|
+
|
|
54
|
+
// We'll assume for now that the autocomplete function might or might not respect the abort signal.
|
|
55
|
+
if (!suggestion || abortSignal.aborted) {
|
|
56
|
+
throw new DOMException("Aborted", "AbortError");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setCurrentAutocompleteSuggestion({
|
|
60
|
+
text: suggestion,
|
|
61
|
+
point: editorAutocompleteState.cursorPoint,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
[autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const debouncedFunction = useMemo(
|
|
68
|
+
() => new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(debounceTime),
|
|
69
|
+
[debounceTime],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// clean current state when unmounting or disabling
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
return () => {
|
|
75
|
+
debouncedFunction.cancel();
|
|
76
|
+
setCurrentAutocompleteSuggestion(null);
|
|
77
|
+
};
|
|
78
|
+
}, [debouncedFunction, disabled]);
|
|
79
|
+
|
|
80
|
+
const onChange = useCallback(
|
|
81
|
+
(newEditorState: EditorAutocompleteState | null) => {
|
|
82
|
+
const editorStateHasChanged = !nullableCompatibleEqualityCheck(
|
|
83
|
+
areEqual_autocompleteState,
|
|
84
|
+
previousAutocompleteState,
|
|
85
|
+
newEditorState,
|
|
86
|
+
);
|
|
87
|
+
setPreviousAutocompleteState(newEditorState);
|
|
88
|
+
|
|
89
|
+
// if no change, do nothing
|
|
90
|
+
if (!editorStateHasChanged) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// if change, then first null out the current suggestion
|
|
95
|
+
setCurrentAutocompleteSuggestion(null);
|
|
96
|
+
|
|
97
|
+
// then try to get a new suggestion, debouncing to avoid too many requests while typing
|
|
98
|
+
if (newEditorState) {
|
|
99
|
+
debouncedFunction.debounce(awaitForAndAppendSuggestion, newEditorState);
|
|
100
|
+
} else {
|
|
101
|
+
debouncedFunction.cancel();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
[
|
|
105
|
+
previousAutocompleteState,
|
|
106
|
+
setPreviousAutocompleteState,
|
|
107
|
+
debouncedFunction,
|
|
108
|
+
awaitForAndAppendSuggestion,
|
|
109
|
+
setCurrentAutocompleteSuggestion,
|
|
110
|
+
],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const keyDownOrTouchHandler = useCallback(
|
|
114
|
+
(event: React.KeyboardEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>) => {
|
|
115
|
+
if (currentAutocompleteSuggestion) {
|
|
116
|
+
const shouldAcceptSuggestion =
|
|
117
|
+
event.type === "touchstart"
|
|
118
|
+
? shouldAcceptAutosuggestionOnTouch(event as React.TouchEvent<HTMLDivElement>)
|
|
119
|
+
: shouldAcceptAutosuggestionOnKeyPress(event as React.KeyboardEvent<HTMLDivElement>);
|
|
120
|
+
|
|
121
|
+
if (shouldAcceptSuggestion) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
insertAutocompleteSuggestion(currentAutocompleteSuggestion);
|
|
124
|
+
setCurrentAutocompleteSuggestion(null);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
[
|
|
129
|
+
currentAutocompleteSuggestion,
|
|
130
|
+
setCurrentAutocompleteSuggestion,
|
|
131
|
+
insertAutocompleteSuggestion,
|
|
132
|
+
shouldAcceptAutosuggestionOnKeyPress,
|
|
133
|
+
],
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
currentAutocompleteSuggestion,
|
|
138
|
+
onChangeHandler: onChange,
|
|
139
|
+
onKeyDownHandler: keyDownOrTouchHandler,
|
|
140
|
+
onTouchStartHandler: keyDownOrTouchHandler,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { createEditor, Element } from "slate";
|
|
3
|
+
import { withReact } from "slate-react";
|
|
4
|
+
import {
|
|
5
|
+
defaultShouldSave,
|
|
6
|
+
ShouldSaveToHistory,
|
|
7
|
+
withPartialHistory,
|
|
8
|
+
} from "../../lib/slatejs-edits/with-partial-history";
|
|
9
|
+
import { CustomEditor } from "../../types/base/custom-editor";
|
|
10
|
+
|
|
11
|
+
const shouldSave: ShouldSaveToHistory = (op, prev) => {
|
|
12
|
+
const excludedNodeType = "suggestion";
|
|
13
|
+
// Check if the operation involves the suggestion inline node type
|
|
14
|
+
if (
|
|
15
|
+
op.type === "insert_node" &&
|
|
16
|
+
Element.isElement(op.node) &&
|
|
17
|
+
op.node.type === excludedNodeType
|
|
18
|
+
) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
op.type === "remove_node" &&
|
|
24
|
+
Element.isElement(op.node) &&
|
|
25
|
+
op.node.type === excludedNodeType
|
|
26
|
+
) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (
|
|
31
|
+
op.type === "set_node" &&
|
|
32
|
+
"type" in op.newProperties &&
|
|
33
|
+
op.newProperties.type === excludedNodeType
|
|
34
|
+
) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (op.type == "set_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
op.type === "merge_node" &&
|
|
44
|
+
"type" in op.properties &&
|
|
45
|
+
op.properties.type === excludedNodeType
|
|
46
|
+
) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
op.type === "split_node" &&
|
|
52
|
+
"type" in op.properties &&
|
|
53
|
+
op.properties.type === excludedNodeType
|
|
54
|
+
) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Otherwise, save the operation to history
|
|
59
|
+
return defaultShouldSave(op, prev);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export function useCopilotTextareaEditor(): CustomEditor {
|
|
63
|
+
const editor = useMemo(() => {
|
|
64
|
+
const editor = withPartialHistory(withReact(createEditor()), shouldSave);
|
|
65
|
+
|
|
66
|
+
const { isVoid } = editor;
|
|
67
|
+
editor.isVoid = (element) => {
|
|
68
|
+
switch (element.type) {
|
|
69
|
+
case "suggestion":
|
|
70
|
+
return true;
|
|
71
|
+
default:
|
|
72
|
+
return isVoid(element);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const { markableVoid } = editor;
|
|
77
|
+
editor.markableVoid = (element) => {
|
|
78
|
+
switch (element.type) {
|
|
79
|
+
case "suggestion":
|
|
80
|
+
return true;
|
|
81
|
+
default:
|
|
82
|
+
return markableVoid(element);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const { isInline } = editor;
|
|
87
|
+
editor.isInline = (element) => {
|
|
88
|
+
switch (element.type) {
|
|
89
|
+
case "suggestion":
|
|
90
|
+
return element.inline;
|
|
91
|
+
default:
|
|
92
|
+
return isInline(element);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return editor;
|
|
97
|
+
}, []);
|
|
98
|
+
|
|
99
|
+
return editor;
|
|
100
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Editor } from "slate";
|
|
3
|
+
import { ReactEditor } from "slate-react";
|
|
4
|
+
import { getFullEditorTextWithNewlines } from "../../lib/get-text-around-cursor";
|
|
5
|
+
import { replaceEditorText } from "../../lib/slatejs-edits/replace-text";
|
|
6
|
+
import { HTMLCopilotTextAreaElement } from "../../types";
|
|
7
|
+
import { CustomEditor } from "../../types/base/custom-editor";
|
|
8
|
+
|
|
9
|
+
export function usePopulateCopilotTextareaRef(
|
|
10
|
+
editor: Editor,
|
|
11
|
+
ref: React.Ref<HTMLCopilotTextAreaElement>,
|
|
12
|
+
) {
|
|
13
|
+
React.useImperativeHandle(ref, () => {
|
|
14
|
+
class Combined {
|
|
15
|
+
constructor(
|
|
16
|
+
private customMethods: CustomMethods,
|
|
17
|
+
private editorHtmlElement: HTMLElement,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
|
|
22
|
+
get(target: any, propKey: string): any {
|
|
23
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
24
|
+
const value = this.customMethods[propKey];
|
|
25
|
+
if (typeof value === "function") {
|
|
26
|
+
return value.bind(this.customMethods);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
30
|
+
const value = this.editorHtmlElement[propKey];
|
|
31
|
+
if (typeof value === "function") {
|
|
32
|
+
return value.bind(this.editorHtmlElement);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set(target: any, propKey: string, value: any): boolean {
|
|
39
|
+
if (this.isKeyOfCustomMethods(propKey)) {
|
|
40
|
+
(this.customMethods as any)[propKey] = value;
|
|
41
|
+
} else if (this.isKeyOfHTMLElement(propKey)) {
|
|
42
|
+
(this.editorHtmlElement as any)[propKey] = value;
|
|
43
|
+
} else {
|
|
44
|
+
// Default behavior (optional)
|
|
45
|
+
target[propKey] = value;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {
|
|
51
|
+
return key in this.customMethods;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {
|
|
55
|
+
return key in this.editorHtmlElement;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const handler = {
|
|
60
|
+
get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {
|
|
61
|
+
return target.get(target, propKey);
|
|
62
|
+
},
|
|
63
|
+
set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {
|
|
64
|
+
return target.set(target, propKey, value);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
class CustomMethods {
|
|
69
|
+
constructor(private editor: CustomEditor) {}
|
|
70
|
+
|
|
71
|
+
focus() {
|
|
72
|
+
ReactEditor.focus(this.editor);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
blur() {
|
|
76
|
+
ReactEditor.blur(this.editor);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get value() {
|
|
80
|
+
return getFullEditorTextWithNewlines(this.editor);
|
|
81
|
+
}
|
|
82
|
+
set value(value: string) {
|
|
83
|
+
replaceEditorText(this.editor, value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);
|
|
88
|
+
const customMethods = new CustomMethods(editor);
|
|
89
|
+
|
|
90
|
+
const combined = new Combined(customMethods, editorHtmlElement);
|
|
91
|
+
return new Proxy(combined, handler);
|
|
92
|
+
}, [editor]);
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|