@celljs/ta-web 4.48.0 → 4.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/account/account-side.js +4 -0
- package/esm/browser/account/device-account.d.ts +6 -0
- package/esm/browser/account/device-account.js +20 -5
- package/esm/browser/assistant/assistant-view.js +2 -0
- package/esm/browser/assistant/call-announcing.d.ts +25 -0
- package/esm/browser/assistant/call-announcing.js +32 -0
- package/esm/browser/assistant/call-answering.d.ts +43 -0
- package/esm/browser/assistant/call-answering.js +63 -0
- package/esm/browser/assistant/call-hearing.d.ts +53 -0
- package/esm/browser/assistant/call-hearing.js +98 -0
- package/esm/browser/assistant/call-pausing.d.ts +40 -0
- package/esm/browser/assistant/call-pausing.js +82 -0
- package/esm/browser/assistant/call-reading.d.ts +32 -0
- package/esm/browser/assistant/call-reading.js +35 -0
- package/esm/browser/assistant/call-revoicing.d.ts +33 -0
- package/esm/browser/assistant/call-revoicing.js +68 -0
- package/esm/browser/assistant/call-turns.d.ts +29 -0
- package/esm/browser/assistant/call-turns.js +33 -0
- package/esm/browser/assistant/spoken-answer.d.ts +21 -0
- package/esm/browser/assistant/spoken-answer.js +69 -0
- package/esm/browser/assistant/spoken-call.d.ts +7 -0
- package/esm/browser/assistant/spoken-call.js +16 -0
- package/esm/browser/assistant/voice-call-protocol.d.ts +5 -0
- package/esm/browser/assistant/voice-call.d.ts +47 -43
- package/esm/browser/assistant/voice-call.js +193 -219
- package/esm/browser/chat/chat-view.js +2 -1
- package/esm/browser/components/account-recovery-view.d.ts +11 -0
- package/esm/browser/components/account-recovery-view.js +81 -0
- package/esm/browser/components/account-view.d.ts +1 -2
- package/esm/browser/components/account-view.js +10 -1
- package/esm/browser/components/app-nav.js +19 -8
- package/esm/browser/components/app-shell-hooks.d.ts +5 -0
- package/esm/browser/components/app-shell-hooks.js +45 -0
- package/esm/browser/components/app-shell-state.js +2 -1
- package/esm/browser/components/app-view.js +9 -5
- package/esm/browser/components/chat-emoji.d.ts +35 -0
- package/esm/browser/components/chat-emoji.js +129 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/composer-attachments.d.ts +6 -0
- package/esm/browser/components/composer-attachments.js +12 -1
- package/esm/browser/components/composer-box-protocol.d.ts +15 -0
- package/esm/browser/components/composer-box.js +110 -87
- package/esm/browser/components/composer-drop-hooks.d.ts +26 -0
- package/esm/browser/components/composer-drop-hooks.js +36 -0
- package/esm/browser/components/composer-emoji.js +1 -1
- package/esm/browser/components/composer-faces.d.ts +16 -0
- package/esm/browser/components/composer-faces.js +37 -0
- package/esm/browser/components/composer-media.d.ts +10 -0
- package/esm/browser/components/composer-media.js +12 -1
- package/esm/browser/components/composer-target.d.ts +4 -0
- package/esm/browser/components/composer-target.js +18 -7
- package/esm/browser/components/composer-type-focus.d.ts +24 -0
- package/esm/browser/components/composer-type-focus.js +17 -0
- package/esm/browser/components/composer-voice.d.ts +24 -0
- package/esm/browser/components/composer-voice.js +37 -0
- package/esm/browser/components/composer.d.ts +2 -2
- package/esm/browser/components/composer.js +39 -8
- package/esm/browser/components/context-menu.js +2 -1
- package/esm/browser/components/emoji-panel.d.ts +11 -7
- package/esm/browser/components/emoji-panel.js +40 -22
- package/esm/browser/components/extension-settings.js +2 -2
- package/esm/browser/components/folder-new.d.ts +18 -0
- package/esm/browser/components/folder-new.js +53 -0
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +18 -6
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/image-menu.d.ts +8 -3
- package/esm/browser/components/image-menu.js +34 -9
- package/esm/browser/components/markdown.js +9 -2
- package/esm/browser/components/media.js +3 -2
- package/esm/browser/components/message-list.js +2 -2
- package/esm/browser/components/message-steps.js +20 -11
- package/esm/browser/components/message-user.js +2 -2
- package/esm/browser/components/moved-notice.js +2 -1
- package/esm/browser/components/nav-places.d.ts +2 -0
- package/esm/browser/components/nav-places.js +4 -2
- package/esm/browser/components/phone-shell.d.ts +2 -0
- package/esm/browser/components/phone-shell.js +5 -1
- package/esm/browser/components/secret-text.d.ts +1 -1
- package/esm/browser/components/secret-text.js +4 -3
- package/esm/browser/components/session-view.js +3 -0
- package/esm/browser/components/settings-choices.d.ts +2 -1
- package/esm/browser/components/settings-choices.js +13 -5
- package/esm/browser/components/settings-more.js +3 -3
- package/esm/browser/components/settings-parts.js +13 -2
- package/esm/browser/components/share-item-sheet.js +7 -1
- package/esm/browser/components/tab-title.d.ts +27 -0
- package/esm/browser/components/tab-title.js +35 -0
- package/esm/browser/components/use-composer-attachments.d.ts +28 -0
- package/esm/browser/components/use-composer-attachments.js +65 -0
- package/esm/browser/components/use-composer-files.d.ts +25 -0
- package/esm/browser/components/use-composer-files.js +52 -0
- package/esm/browser/components/web-composer.d.ts +3 -1
- package/esm/browser/components/web-composer.js +3 -2
- package/esm/browser/components/workbench-view.js +1 -0
- package/esm/browser/components/working-directory.js +2 -1
- package/esm/browser/device/drag-move.d.ts +21 -0
- package/esm/browser/device/drag-move.js +86 -0
- package/esm/browser/extension/icons.js +7 -1
- package/esm/browser/extension/web-api-desktop.d.ts +19 -0
- package/esm/browser/extension/web-api-menus.d.ts +19 -0
- package/esm/browser/extension/web-api-spec.js +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +24 -23
- package/esm/browser/extension/web-extension-context.d.ts +1 -0
- package/esm/browser/extension/web-extension-context.js +12 -5
- package/esm/browser/extension/web-extension-run.js +1 -0
- package/esm/browser/extension/web-share-ui.d.ts +1 -1
- package/esm/browser/extension/web-share-ui.js +2 -0
- package/esm/browser/extension/web-share.d.ts +13 -0
- package/esm/browser/extension/web-share.js +37 -2
- package/esm/browser/i18n/en/account.d.ts +18 -0
- package/esm/browser/i18n/en/account.js +18 -0
- package/esm/browser/i18n/en/call.js +1 -1
- package/esm/browser/i18n/en/chat.d.ts +15 -0
- package/esm/browser/i18n/en/chat.js +16 -1
- package/esm/browser/i18n/en/common.d.ts +2 -0
- package/esm/browser/i18n/en/common.js +2 -0
- package/esm/browser/i18n/en/discover.d.ts +2 -0
- package/esm/browser/i18n/en/discover.js +2 -0
- package/esm/browser/i18n/en/settings.d.ts +17 -0
- package/esm/browser/i18n/en/settings.js +17 -0
- package/esm/browser/i18n/ja/account.js +18 -0
- package/esm/browser/i18n/ja/call.js +1 -1
- package/esm/browser/i18n/ja/chat.js +16 -1
- package/esm/browser/i18n/ja/common.js +2 -0
- package/esm/browser/i18n/ja/discover.js +3 -1
- package/esm/browser/i18n/ja/settings.js +17 -0
- package/esm/browser/i18n/locales.d.ts +55 -1
- package/esm/browser/i18n/messages.d.ts +54 -0
- package/esm/browser/i18n/zh/account.js +18 -0
- package/esm/browser/i18n/zh/call.js +1 -1
- package/esm/browser/i18n/zh/chat.js +16 -1
- package/esm/browser/i18n/zh/common.js +2 -0
- package/esm/browser/i18n/zh/discover.js +3 -1
- package/esm/browser/i18n/zh/settings.js +17 -0
- package/esm/browser/i18n/zh-tw/account.js +18 -0
- package/esm/browser/i18n/zh-tw/call.js +1 -1
- package/esm/browser/i18n/zh-tw/chat.js +16 -1
- package/esm/browser/i18n/zh-tw/common.js +2 -0
- package/esm/browser/i18n/zh-tw/discover.js +3 -1
- package/esm/browser/i18n/zh-tw/settings.js +17 -0
- package/esm/browser/offline/kept-chats.d.ts +3 -1
- package/esm/browser/offline/kept-chats.js +1 -1
- package/esm/browser/partners/group-picker.d.ts +3 -2
- package/esm/browser/partners/group-picker.js +8 -3
- package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/esm/browser/sandbox/work/work-docs.js +5 -2
- package/esm/browser/sandbox/work/work-frame.d.ts +3 -0
- package/esm/browser/sandbox/work/work-frame.js +9 -3
- package/esm/browser/sandbox/work/work-gates.d.ts +77 -0
- package/esm/browser/sandbox/work/work-gates.js +182 -0
- package/esm/browser/settings/agent-settings.js +1 -1
- package/esm/browser/settings/navigation.d.ts +38 -10
- package/esm/browser/settings/navigation.js +73 -17
- package/esm/browser/settings/settings-protocol.d.ts +16 -1
- package/esm/browser/settings/settings-protocol.js +20 -2
- package/esm/browser/settings/settings.js +4 -1
- package/esm/browser/style/base.d.ts +1 -1
- package/esm/browser/style/base.js +15 -2
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +6 -3
- package/esm/browser/style/conversation-column.d.ts +1 -1
- package/esm/browser/style/conversation-column.js +28 -8
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +5 -0
- package/esm/browser/style/device.js +5 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +3 -3
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +13 -6
- package/esm/browser/style/tasks.d.ts +1 -1
- package/esm/browser/style/tasks.js +4 -2
- package/esm/browser/util/chat-emoji.d.ts +44 -0
- package/esm/browser/util/chat-emoji.js +269 -0
- package/esm/browser/util/composer-drop.d.ts +26 -0
- package/esm/browser/util/composer-drop.js +40 -0
- package/esm/browser/util/composer-files.d.ts +48 -0
- package/esm/browser/util/composer-files.js +99 -0
- package/esm/browser/util/composer.d.ts +13 -1
- package/esm/browser/util/composer.js +24 -6
- package/esm/browser/util/markdown.d.ts +5 -0
- package/esm/browser/util/markdown.js +18 -0
- package/esm/browser/util/message.d.ts +6 -1
- package/esm/browser/util/message.js +13 -2
- package/esm/browser/util/process.d.ts +10 -13
- package/esm/browser/util/process.js +31 -83
- package/esm/browser/util/turn-join.d.ts +38 -0
- package/esm/browser/util/turn-join.js +119 -0
- package/esm/browser/workbench-services.js +1 -1
- package/lib/browser/account/account-side.js +4 -0
- package/lib/browser/account/device-account.d.ts +6 -0
- package/lib/browser/account/device-account.js +20 -5
- package/lib/browser/assistant/assistant-view.js +2 -0
- package/lib/browser/assistant/call-announcing.d.ts +26 -0
- package/lib/browser/assistant/call-announcing.js +36 -0
- package/lib/browser/assistant/call-answering.d.ts +44 -0
- package/lib/browser/assistant/call-answering.js +67 -0
- package/lib/browser/assistant/call-hearing.d.ts +54 -0
- package/lib/browser/assistant/call-hearing.js +102 -0
- package/lib/browser/assistant/call-pausing.d.ts +41 -0
- package/lib/browser/assistant/call-pausing.js +86 -0
- package/lib/browser/assistant/call-reading.d.ts +33 -0
- package/lib/browser/assistant/call-reading.js +39 -0
- package/lib/browser/assistant/call-revoicing.d.ts +34 -0
- package/lib/browser/assistant/call-revoicing.js +72 -0
- package/lib/browser/assistant/call-turns.d.ts +30 -0
- package/lib/browser/assistant/call-turns.js +37 -0
- package/lib/browser/assistant/spoken-answer.d.ts +22 -0
- package/lib/browser/assistant/spoken-answer.js +73 -0
- package/lib/browser/assistant/spoken-call.d.ts +8 -0
- package/lib/browser/assistant/spoken-call.js +19 -0
- package/lib/browser/assistant/voice-call-protocol.d.ts +5 -0
- package/lib/browser/assistant/voice-call.d.ts +47 -43
- package/lib/browser/assistant/voice-call.js +192 -218
- package/lib/browser/chat/chat-view.js +2 -1
- package/lib/browser/components/account-recovery-view.d.ts +12 -0
- package/lib/browser/components/account-recovery-view.js +117 -0
- package/lib/browser/components/account-view.d.ts +1 -2
- package/lib/browser/components/account-view.js +10 -1
- package/lib/browser/components/app-nav.js +19 -8
- package/lib/browser/components/app-shell-hooks.d.ts +5 -0
- package/lib/browser/components/app-shell-hooks.js +46 -0
- package/lib/browser/components/app-shell-state.js +1 -0
- package/lib/browser/components/app-view.js +8 -4
- package/lib/browser/components/chat-emoji.d.ts +36 -0
- package/lib/browser/components/chat-emoji.js +167 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/composer-attachments.d.ts +6 -0
- package/lib/browser/components/composer-attachments.js +12 -0
- package/lib/browser/components/composer-box-protocol.d.ts +15 -0
- package/lib/browser/components/composer-box.js +107 -84
- package/lib/browser/components/composer-drop-hooks.d.ts +27 -0
- package/lib/browser/components/composer-drop-hooks.js +72 -0
- package/lib/browser/components/composer-emoji.js +1 -1
- package/lib/browser/components/composer-faces.d.ts +17 -0
- package/lib/browser/components/composer-faces.js +73 -0
- package/lib/browser/components/composer-media.d.ts +10 -0
- package/lib/browser/components/composer-media.js +13 -0
- package/lib/browser/components/composer-target.d.ts +4 -0
- package/lib/browser/components/composer-target.js +18 -7
- package/lib/browser/components/composer-type-focus.d.ts +25 -0
- package/lib/browser/components/composer-type-focus.js +20 -0
- package/lib/browser/components/composer-voice.d.ts +25 -0
- package/lib/browser/components/composer-voice.js +73 -0
- package/lib/browser/components/composer.d.ts +2 -2
- package/lib/browser/components/composer.js +38 -7
- package/lib/browser/components/context-menu.js +2 -1
- package/lib/browser/components/emoji-panel.d.ts +11 -7
- package/lib/browser/components/emoji-panel.js +40 -22
- package/lib/browser/components/extension-settings.js +1 -1
- package/lib/browser/components/folder-new.d.ts +19 -0
- package/lib/browser/components/folder-new.js +90 -0
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +17 -5
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/image-menu.d.ts +8 -3
- package/lib/browser/components/image-menu.js +34 -9
- package/lib/browser/components/markdown.js +9 -2
- package/lib/browser/components/media.js +3 -2
- package/lib/browser/components/message-list.js +2 -2
- package/lib/browser/components/message-steps.js +20 -11
- package/lib/browser/components/message-user.js +1 -1
- package/lib/browser/components/moved-notice.js +2 -1
- package/lib/browser/components/nav-places.d.ts +2 -0
- package/lib/browser/components/nav-places.js +4 -2
- package/lib/browser/components/phone-shell.d.ts +2 -0
- package/lib/browser/components/phone-shell.js +5 -1
- package/lib/browser/components/secret-text.d.ts +1 -1
- package/lib/browser/components/secret-text.js +4 -3
- package/lib/browser/components/session-view.js +3 -0
- package/lib/browser/components/settings-choices.d.ts +2 -1
- package/lib/browser/components/settings-choices.js +12 -4
- package/lib/browser/components/settings-more.js +2 -2
- package/lib/browser/components/settings-parts.js +11 -0
- package/lib/browser/components/share-item-sheet.js +7 -1
- package/lib/browser/components/tab-title.d.ts +28 -0
- package/lib/browser/components/tab-title.js +38 -0
- package/lib/browser/components/use-composer-attachments.d.ts +29 -0
- package/lib/browser/components/use-composer-attachments.js +101 -0
- package/lib/browser/components/use-composer-files.d.ts +26 -0
- package/lib/browser/components/use-composer-files.js +88 -0
- package/lib/browser/components/web-composer.d.ts +3 -1
- package/lib/browser/components/web-composer.js +3 -2
- package/lib/browser/components/workbench-view.js +1 -0
- package/lib/browser/components/working-directory.js +2 -1
- package/lib/browser/device/drag-move.d.ts +22 -0
- package/lib/browser/device/drag-move.js +122 -0
- package/lib/browser/extension/icons.js +6 -0
- package/lib/browser/extension/web-api-desktop.d.ts +19 -0
- package/lib/browser/extension/web-api-menus.d.ts +19 -0
- package/lib/browser/extension/web-api-spec.js +2 -0
- package/lib/browser/extension/web-extension-api.d.ts +24 -23
- package/lib/browser/extension/web-extension-context.d.ts +1 -0
- package/lib/browser/extension/web-extension-context.js +12 -5
- package/lib/browser/extension/web-extension-run.js +1 -0
- package/lib/browser/extension/web-share-ui.d.ts +1 -1
- package/lib/browser/extension/web-share-ui.js +2 -0
- package/lib/browser/extension/web-share.d.ts +13 -0
- package/lib/browser/extension/web-share.js +37 -2
- package/lib/browser/i18n/en/account.d.ts +18 -0
- package/lib/browser/i18n/en/account.js +18 -0
- package/lib/browser/i18n/en/call.js +1 -1
- package/lib/browser/i18n/en/chat.d.ts +15 -0
- package/lib/browser/i18n/en/chat.js +16 -1
- package/lib/browser/i18n/en/common.d.ts +2 -0
- package/lib/browser/i18n/en/common.js +2 -0
- package/lib/browser/i18n/en/discover.d.ts +2 -0
- package/lib/browser/i18n/en/discover.js +2 -0
- package/lib/browser/i18n/en/settings.d.ts +17 -0
- package/lib/browser/i18n/en/settings.js +17 -0
- package/lib/browser/i18n/ja/account.js +18 -0
- package/lib/browser/i18n/ja/call.js +1 -1
- package/lib/browser/i18n/ja/chat.js +16 -1
- package/lib/browser/i18n/ja/common.js +2 -0
- package/lib/browser/i18n/ja/discover.js +3 -1
- package/lib/browser/i18n/ja/settings.js +17 -0
- package/lib/browser/i18n/locales.d.ts +55 -1
- package/lib/browser/i18n/messages.d.ts +54 -0
- package/lib/browser/i18n/zh/account.js +18 -0
- package/lib/browser/i18n/zh/call.js +1 -1
- package/lib/browser/i18n/zh/chat.js +16 -1
- package/lib/browser/i18n/zh/common.js +2 -0
- package/lib/browser/i18n/zh/discover.js +3 -1
- package/lib/browser/i18n/zh/settings.js +17 -0
- package/lib/browser/i18n/zh-tw/account.js +18 -0
- package/lib/browser/i18n/zh-tw/call.js +1 -1
- package/lib/browser/i18n/zh-tw/chat.js +16 -1
- package/lib/browser/i18n/zh-tw/common.js +2 -0
- package/lib/browser/i18n/zh-tw/discover.js +3 -1
- package/lib/browser/i18n/zh-tw/settings.js +17 -0
- package/lib/browser/offline/kept-chats.d.ts +3 -1
- package/lib/browser/offline/kept-chats.js +1 -1
- package/lib/browser/partners/group-picker.d.ts +3 -2
- package/lib/browser/partners/group-picker.js +8 -3
- package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/lib/browser/sandbox/work/work-docs.js +5 -2
- package/lib/browser/sandbox/work/work-frame.d.ts +3 -0
- package/lib/browser/sandbox/work/work-frame.js +9 -3
- package/lib/browser/sandbox/work/work-gates.d.ts +78 -0
- package/lib/browser/sandbox/work/work-gates.js +185 -0
- package/lib/browser/settings/agent-settings.js +1 -1
- package/lib/browser/settings/navigation.d.ts +38 -10
- package/lib/browser/settings/navigation.js +74 -18
- package/lib/browser/settings/settings-protocol.d.ts +16 -1
- package/lib/browser/settings/settings-protocol.js +21 -3
- package/lib/browser/settings/settings.js +3 -0
- package/lib/browser/style/base.d.ts +1 -1
- package/lib/browser/style/base.js +15 -2
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +6 -3
- package/lib/browser/style/conversation-column.d.ts +1 -1
- package/lib/browser/style/conversation-column.js +28 -8
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +5 -0
- package/lib/browser/style/device.js +5 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +3 -3
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +13 -6
- package/lib/browser/style/tasks.d.ts +1 -1
- package/lib/browser/style/tasks.js +4 -2
- package/lib/browser/util/chat-emoji.d.ts +45 -0
- package/lib/browser/util/chat-emoji.js +272 -0
- package/lib/browser/util/composer-drop.d.ts +27 -0
- package/lib/browser/util/composer-drop.js +43 -0
- package/lib/browser/util/composer-files.d.ts +49 -0
- package/lib/browser/util/composer-files.js +102 -0
- package/lib/browser/util/composer.d.ts +13 -1
- package/lib/browser/util/composer.js +24 -6
- package/lib/browser/util/markdown.d.ts +5 -0
- package/lib/browser/util/markdown.js +18 -0
- package/lib/browser/util/message.d.ts +6 -1
- package/lib/browser/util/message.js +13 -2
- package/lib/browser/util/process.d.ts +10 -13
- package/lib/browser/util/process.js +32 -84
- package/lib/browser/util/turn-join.d.ts +39 -0
- package/lib/browser/util/turn-join.js +122 -0
- package/lib/browser/workbench-services.js +1 -1
- package/package.json +7 -7
- package/public/emoji/wechat-v1.webp +0 -0
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import { ArrowUp, AtSign,
|
|
1
|
+
import { ArrowUp, AtSign, Plus, Slash, Square } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useDevice } from '../device/device.js';
|
|
4
4
|
import { useHeld } from '../device/hold.js';
|
|
5
|
-
import { MiniProgram } from '../device/mini-program.js';
|
|
6
5
|
import { PhotoPicker } from '../device/photo-picker.js';
|
|
7
6
|
import { RecentShots } from '../device/recent-shots.js';
|
|
8
7
|
import { VideoPicks } from '../device/video-picks.js';
|
|
9
8
|
import { useComposerDraft, useTaDrafts } from '../drafts/use-composer-draft.js';
|
|
10
9
|
import { useT } from '../i18n/use-t.js';
|
|
11
10
|
import { ComposerUtil, MAX_IMAGES } from '../util/composer.js';
|
|
11
|
+
import { ComposerFileUtil } from '../util/composer-files.js';
|
|
12
12
|
import { FileDragUtil } from '../util/file-drag.js';
|
|
13
13
|
import { Voice } from '../util/voice.js';
|
|
14
|
-
import { Attachments,
|
|
14
|
+
import { Attachments, ComposerFiles } from './composer-attachments.js';
|
|
15
15
|
import { talkTarget, useArgumentQuery, useFieldFit, usePlusMenuDismiss, useTalkWiring, useTapToType } from './composer-box-hooks.js';
|
|
16
|
+
import { useComposerDrop } from './composer-drop-hooks.js';
|
|
16
17
|
import { ComposerEmojiButton, useComposerEmoji } from './composer-emoji.js';
|
|
17
|
-
import {
|
|
18
|
+
import { useBoxFaces } from './composer-faces.js';
|
|
19
|
+
import { FileInput, fileTile, MediaInputs, mediaTiles } from './composer-media.js';
|
|
18
20
|
import { ComposerMenu } from './composer-menu.js';
|
|
21
|
+
import { useMicrophone } from './composer-voice.js';
|
|
19
22
|
import { EmojiPanel, EmojiPanelUtil } from './emoji-panel.js';
|
|
20
23
|
import { HeldTalk } from './held-talk.js';
|
|
21
24
|
import { Icon, IconButton } from './icon.js';
|
|
22
25
|
import { PlusMenu } from './plus-menu.js';
|
|
23
26
|
import { RecentShotOffer } from './recent-shot.js';
|
|
24
|
-
import {
|
|
27
|
+
import { useComposerAttachments } from './use-composer-attachments.js';
|
|
28
|
+
import { useComposerFiles } from './use-composer-files.js';
|
|
25
29
|
import { TalkBar, useVoiceTalk, VoiceTalkOverlay } from './voice-talk.js';
|
|
26
30
|
/**
|
|
27
31
|
* The message box of every conversation: Enter sends (the Send key of a phone, as in WeChat), Shift+Enter is a new line, Alt+Enter a follow-up;
|
|
@@ -32,12 +36,14 @@ import { TalkBar, useVoiceTalk, VoiceTalkOverlay } from './voice-talk.js';
|
|
|
32
36
|
let talkFirst = false;
|
|
33
37
|
export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
34
38
|
var _a;
|
|
35
|
-
const { placeholder, working = false, compacting = false, onStop, onSend, sendTitle, commands = [], onArgumentQuery, argumentItems, onMentionQuery, mentions, mentionLabel, images: takesImages, emoji: takesEmoji, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onTalkCall, talkCalls = ['keep', 'call'], onListening, autoFocus, onTextChange, draft, cwd, onError, } = props;
|
|
39
|
+
const { placeholder, working = false, compacting = false, onStop, onSend, sendTitle, commands = [], onArgumentQuery, argumentItems, onMentionQuery, mentions, mentionLabel, images: takesImages, files: takesFiles, emoji: takesEmoji, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onTalkCall, talkCalls = ['keep', 'call'], onListening, autoFocus, onTextChange, draft, cwd, droppedFiles, onError, } = props;
|
|
36
40
|
const t = useT();
|
|
37
41
|
const drafts = useTaDrafts();
|
|
38
42
|
const [text, setText] = React.useState(() => { var _a; var _b; return (_b = (draft === undefined ? undefined : (_a = drafts === null || drafts === void 0 ? void 0 : drafts.get(draft)) === null || _a === void 0 ? void 0 : _a.text)) !== null && _b !== void 0 ? _b : ''; });
|
|
39
43
|
const [caret, setCaret] = React.useState(() => text.length);
|
|
40
|
-
const
|
|
44
|
+
const uploaded = useComposerFiles(takesFiles, cwd, t, onError);
|
|
45
|
+
const images = useComposerAttachments({ images: !!takesImages, videos: props.videos, files: !!takesFiles, addFiles: uploaded.add, t, onError });
|
|
46
|
+
const attachments = images.attachments;
|
|
41
47
|
useComposerDraft(drafts, draft, {
|
|
42
48
|
text,
|
|
43
49
|
attachments,
|
|
@@ -45,10 +51,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
45
51
|
setText(next);
|
|
46
52
|
setCaret(next.length);
|
|
47
53
|
setDismissed(undefined);
|
|
48
|
-
|
|
49
|
-
ComposerUtil.release(previous.filter(attachment => !kept.includes(attachment)));
|
|
50
|
-
return kept;
|
|
51
|
-
});
|
|
54
|
+
images.set(kept);
|
|
52
55
|
},
|
|
53
56
|
});
|
|
54
57
|
const [selected, setSelected] = React.useState(0);
|
|
@@ -64,6 +67,8 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
64
67
|
setStopping(false);
|
|
65
68
|
}
|
|
66
69
|
}, [busy]);
|
|
70
|
+
// When the box last sent: the button turns to stop under the pointer, and a second click then is not a stop.
|
|
71
|
+
const sentAt = React.useRef(undefined);
|
|
67
72
|
const stop = () => {
|
|
68
73
|
if (!onStop || stopping) {
|
|
69
74
|
return;
|
|
@@ -82,6 +87,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
82
87
|
const [focused, setFocused] = React.useState(false);
|
|
83
88
|
const input = React.useRef(null);
|
|
84
89
|
const picker = React.useRef(null);
|
|
90
|
+
const documents = React.useRef(null);
|
|
85
91
|
const camera = React.useRef(null);
|
|
86
92
|
const plus = React.useRef(null);
|
|
87
93
|
const panel = React.useRef(null);
|
|
@@ -91,6 +97,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
91
97
|
setClosing(handheld);
|
|
92
98
|
}, [handheld]);
|
|
93
99
|
const emojis = useComposerEmoji(handheld, input, () => menu && setMenu(false));
|
|
100
|
+
const faces = useBoxFaces(input, text, !!takesEmoji);
|
|
94
101
|
const found = ComposerUtil.trigger(text, caret);
|
|
95
102
|
const trigger = found && `${found.kind}:${found.start}` !== dismissed ? found : undefined;
|
|
96
103
|
const query = (trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'file' ? trigger.query : undefined;
|
|
@@ -106,10 +113,10 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
106
113
|
: []
|
|
107
114
|
: [];
|
|
108
115
|
const note = (trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'file' && onMentionQuery && !items.length ? mentions === null || mentions === void 0 ? void 0 : mentions.note : undefined;
|
|
109
|
-
const sendable = text.trim().length > 0 || attachments.length > 0;
|
|
116
|
+
const sendable = text.trim().length > 0 || attachments.length > 0 || uploaded.files.length > 0;
|
|
110
117
|
const action = ComposerUtil.action(working, sendable, compacting);
|
|
111
|
-
// An image still being read holds the message back, rather than leaving without it.
|
|
112
|
-
const reading = !ComposerUtil.ready(attachments);
|
|
118
|
+
// An image still being read, or a file still uploading, holds the message back, rather than leaving without it.
|
|
119
|
+
const reading = !ComposerUtil.ready(attachments) || !uploaded.ready;
|
|
113
120
|
useFieldFit(input, text, talkMode);
|
|
114
121
|
usePlusMenuDismiss(menu, closeMenu, plus, panel);
|
|
115
122
|
const toggleMenu = () => {
|
|
@@ -138,7 +145,8 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
138
145
|
requestAnimationFrame(() => {
|
|
139
146
|
var _a, _b;
|
|
140
147
|
(_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
141
|
-
|
|
148
|
+
const at = faces.shownCaret(next, position);
|
|
149
|
+
(_b = input.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(at, at);
|
|
142
150
|
});
|
|
143
151
|
};
|
|
144
152
|
/** An emoji or a delete of the panel: on a phone the keyboard stays down, the caret where it was. */
|
|
@@ -156,12 +164,24 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
156
164
|
// What a talk finds as it ends, long after it began.
|
|
157
165
|
const latestCaret = React.useRef(caret);
|
|
158
166
|
latestCaret.current = caret;
|
|
167
|
+
// What a drop or a paste brings: the pictures into the box as ever, every other file under `uploads/` of the
|
|
168
|
+
// conversation, named where the caret is (useComposerDrop).
|
|
169
|
+
const drop = useComposerDrop({
|
|
170
|
+
files: !!takesFiles,
|
|
171
|
+
videos: !!props.videos,
|
|
172
|
+
droppedFiles,
|
|
173
|
+
addImages: images.add,
|
|
174
|
+
text: () => latest.current,
|
|
175
|
+
caret: () => latestCaret.current,
|
|
176
|
+
insert: edit,
|
|
177
|
+
onError,
|
|
178
|
+
});
|
|
159
179
|
const readingNow = React.useRef(reading);
|
|
160
180
|
readingNow.current = reading;
|
|
161
181
|
React.useImperativeHandle(ref, () => ({
|
|
162
182
|
text: () => latest.current,
|
|
163
183
|
setText: next => edit(next, next.length),
|
|
164
|
-
...(takesImages ? { addFiles: (files) =>
|
|
184
|
+
...(takesImages || takesFiles ? { addFiles: (files) => images.add(files) } : {}),
|
|
165
185
|
shown: () => { var _a; return !!((_a = input.current) === null || _a === void 0 ? void 0 : _a.isConnected) && input.current.getClientRects().length > 0; },
|
|
166
186
|
}));
|
|
167
187
|
const pick = (item) => {
|
|
@@ -176,17 +196,23 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
176
196
|
const typed = (item) => ((trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'command' && (item === null || item === void 0 ? void 0 : item.label) === text.trim()) || ((trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'argument' && (item === null || item === void 0 ? void 0 : item.key.trim()) === trigger.query.trim());
|
|
177
197
|
/** Sends; the sending, which fails as it does (what was sent back in the box), or nothing when there is nothing to send. */
|
|
178
198
|
const send = (key, message = text.trim()) => {
|
|
179
|
-
if ((!message && !attachments.length) || reading) {
|
|
199
|
+
if ((!message && !attachments.length && !uploaded.files.length) || reading) {
|
|
180
200
|
return undefined;
|
|
181
201
|
}
|
|
182
202
|
const attached = attachments;
|
|
203
|
+
const files = uploaded.files;
|
|
204
|
+
sentAt.current = performance.now();
|
|
183
205
|
setText('');
|
|
184
206
|
setCaret(0);
|
|
185
|
-
|
|
186
|
-
|
|
207
|
+
images.set([]);
|
|
208
|
+
uploaded.clear();
|
|
209
|
+
// Where the files are, after what was typed: the agent opens them with its tools.
|
|
210
|
+
const said = files.length ? [message, ComposerFileUtil.references(files)].filter(part => part.trim()).join('\n\n') : message;
|
|
211
|
+
const sent = onSend(said, ComposerUtil.images(attached), key);
|
|
187
212
|
sent.then(() => ComposerUtil.release(attached), error => {
|
|
188
213
|
setText(message);
|
|
189
|
-
|
|
214
|
+
images.set(attached);
|
|
215
|
+
uploaded.restore(files);
|
|
190
216
|
onError(error);
|
|
191
217
|
});
|
|
192
218
|
return sent;
|
|
@@ -226,16 +252,6 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
226
252
|
}
|
|
227
253
|
}, onError, hints, onTalkCall ? talkCalls : []);
|
|
228
254
|
const talking = useTalkWiring(talk, onListening, talkPlace);
|
|
229
|
-
// Speech goes where the caret was when listening began, between what was typed.
|
|
230
|
-
const spoken = React.useRef({ before: '', after: '' });
|
|
231
|
-
const listen = (on) => {
|
|
232
|
-
if (on) {
|
|
233
|
-
spoken.current = { before: text.slice(0, caret), after: text.slice(caret) };
|
|
234
|
-
}
|
|
235
|
-
setListening(on);
|
|
236
|
-
onListening === null || onListening === void 0 ? void 0 : onListening(on);
|
|
237
|
-
};
|
|
238
|
-
const speech = (words) => `${spoken.current.before}${words}${spoken.current.after}`;
|
|
239
255
|
const switchTalk = (on) => {
|
|
240
256
|
var _a;
|
|
241
257
|
talkFirst = on;
|
|
@@ -248,14 +264,31 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
248
264
|
requestAnimationFrame(() => { var _a; return (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
249
265
|
}
|
|
250
266
|
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
/** Listening began or ended: the box shows it, and the microphone too. */
|
|
268
|
+
const listen = (on) => {
|
|
269
|
+
setListening(on);
|
|
270
|
+
onListening === null || onListening === void 0 ? void 0 : onListening(on);
|
|
271
|
+
};
|
|
272
|
+
const microphone = useMicrophone({
|
|
273
|
+
touch,
|
|
274
|
+
talkMode,
|
|
275
|
+
hints,
|
|
276
|
+
voiceSends: !!voiceSends,
|
|
277
|
+
said: () => ({ text: latest.current, caret: latestCaret.current }),
|
|
278
|
+
onHear: (words, at) => {
|
|
279
|
+
if (voiceSends) {
|
|
280
|
+
send('enter', words.trim());
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
setText(words);
|
|
284
|
+
setCaret(at);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
onInsert: words => edit(...ComposerUtil.insert(latest.current, latestCaret.current, words)),
|
|
288
|
+
onListening: listen,
|
|
289
|
+
onTalkKey: switchTalk,
|
|
290
|
+
onError,
|
|
291
|
+
});
|
|
259
292
|
// A finger held on the box while the keyboard is down talks (the field takes no finger then, .ta-talkable: a tap
|
|
260
293
|
// on it is the box's, which types in it). With the keyboard up, the field and the box are the system's.
|
|
261
294
|
const held = useHeld();
|
|
@@ -271,43 +304,9 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
271
304
|
: undefined);
|
|
272
305
|
const box = React.useRef(null);
|
|
273
306
|
useTapToType(box, input, talkable);
|
|
274
|
-
const remove = (id) => {
|
|
275
|
-
ComposerUtil.release(attachments.filter(attachment => attachment.id === id));
|
|
276
|
-
setAttachments(previous => previous.filter(attachment => attachment.id !== id));
|
|
277
|
-
};
|
|
278
|
-
// The previews of a box that goes away go with it.
|
|
279
|
-
const shown = React.useRef(attachments);
|
|
280
|
-
shown.current = attachments;
|
|
281
|
-
React.useEffect(() => () => ComposerUtil.release(shown.current), []);
|
|
282
|
-
/** Shows each image at once from its file, and reads them all at the same time. */
|
|
283
|
-
const addFiles = (list) => {
|
|
284
|
-
const added = [];
|
|
285
|
-
for (const file of VideoPicks.take(list, props.videos)) {
|
|
286
|
-
const reason = ComposerUtil.rejectImage(file, attachments.length + added.length);
|
|
287
|
-
if (reason) {
|
|
288
|
-
onError(new Error(t(`ta.composer.image.${reason}`, { name: file.name })));
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
added.push({ attachment: { id: crypto.randomUUID(), preview: URL.createObjectURL(file) }, file });
|
|
292
|
-
}
|
|
293
|
-
if (!added.length) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
setAttachments(previous => [...previous, ...added.map(({ attachment }) => attachment)]);
|
|
297
|
-
for (const { attachment, file } of added) {
|
|
298
|
-
void readImage(file).then(image => {
|
|
299
|
-
if (!image) {
|
|
300
|
-
ComposerUtil.release([attachment]);
|
|
301
|
-
}
|
|
302
|
-
setAttachments(previous => image
|
|
303
|
-
? previous.map(other => (other.id === attachment.id ? { ...other, image } : other))
|
|
304
|
-
: previous.filter(other => other.id !== attachment.id));
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
307
|
const onPicked = (event) => {
|
|
309
308
|
if (event.target.files) {
|
|
310
|
-
|
|
309
|
+
images.add(event.target.files);
|
|
311
310
|
}
|
|
312
311
|
event.target.value = '';
|
|
313
312
|
};
|
|
@@ -336,10 +335,21 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
336
335
|
}
|
|
337
336
|
};
|
|
338
337
|
const onPaste = (event) => {
|
|
339
|
-
const pasted =
|
|
338
|
+
const pasted = takesFiles || droppedFiles
|
|
339
|
+
? Array.from(event.clipboardData.files)
|
|
340
|
+
: takesImages
|
|
341
|
+
? VideoPicks.pasted(event.clipboardData.files, !!props.videos)
|
|
342
|
+
: [];
|
|
340
343
|
if (pasted.length) {
|
|
341
344
|
event.preventDefault();
|
|
342
|
-
|
|
345
|
+
drop.take(pasted);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
/** A copy of the field with faces: their names in brackets, and what is cut away. */
|
|
349
|
+
const copyFaces = (event, cut) => {
|
|
350
|
+
const left = faces.copied(event, cut);
|
|
351
|
+
if (left !== undefined) {
|
|
352
|
+
edit(left, left.length);
|
|
343
353
|
}
|
|
344
354
|
};
|
|
345
355
|
const onDrop = (event) => {
|
|
@@ -350,9 +360,10 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
350
360
|
edit(...ComposerUtil.insert(text, caret, `${FileDragUtil.references(files, cwd)} `));
|
|
351
361
|
return;
|
|
352
362
|
}
|
|
353
|
-
|
|
363
|
+
const dropped = Array.from(event.dataTransfer.files);
|
|
364
|
+
if (dropped.length) {
|
|
354
365
|
event.preventDefault();
|
|
355
|
-
|
|
366
|
+
drop.take(dropped);
|
|
356
367
|
}
|
|
357
368
|
};
|
|
358
369
|
const own = [];
|
|
@@ -360,7 +371,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
360
371
|
var _a, _b, _c;
|
|
361
372
|
// The Ta app on iOS opens its library at once (and asks for the photos, for the screenshots, once picked).
|
|
362
373
|
if (PhotoPicker.available()) {
|
|
363
|
-
PhotoPicker.pickInto(MAX_IMAGES - attachments.length,
|
|
374
|
+
PhotoPicker.pickInto(MAX_IMAGES - attachments.length, images.add, props.videos);
|
|
364
375
|
return;
|
|
365
376
|
}
|
|
366
377
|
if (recentShots) {
|
|
@@ -371,6 +382,9 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
371
382
|
if (takesImages) {
|
|
372
383
|
own.push(...mediaTiles({ phone: handheld && touch, videos: !!props.videos, t, pick: pickImages, shoot: () => { var _a; return (_a = camera.current) === null || _a === void 0 ? void 0 : _a.click(); } }));
|
|
373
384
|
}
|
|
385
|
+
if (takesFiles) {
|
|
386
|
+
own.push(fileTile(t, () => { var _a; return (_a = documents.current) === null || _a === void 0 ? void 0 : _a.click(); }));
|
|
387
|
+
}
|
|
374
388
|
if (mentionLabel) {
|
|
375
389
|
own.push({ key: 'mention', label: mentionLabel, icon: React.createElement(Icon, { icon: AtSign, size: 16 }), run: () => edit(...ComposerUtil.insert(text, caret, '@')) });
|
|
376
390
|
}
|
|
@@ -390,7 +404,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
390
404
|
above,
|
|
391
405
|
head && React.createElement("div", { className: "ta-console-head" }, head),
|
|
392
406
|
React.createElement("div", { ref: box, className: `ta-console-box${dragging ? ' ta-dragging' : ''}${talkable ? ' ta-talkable' : ''}`, ...boxHold, onDragOver: event => {
|
|
393
|
-
if (FileDragUtil.has(event.dataTransfer) || (takesImages && event.dataTransfer.types.includes('Files'))) {
|
|
407
|
+
if (FileDragUtil.has(event.dataTransfer) || ((takesImages || takesFiles || droppedFiles) && event.dataTransfer.types.includes('Files'))) {
|
|
394
408
|
event.preventDefault();
|
|
395
409
|
setDragging(true);
|
|
396
410
|
}
|
|
@@ -402,20 +416,28 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
402
416
|
(_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
403
417
|
}
|
|
404
418
|
} },
|
|
405
|
-
attachments.length > 0 && React.createElement(Attachments, { attachments: attachments, onRemove: remove }),
|
|
419
|
+
attachments.length > 0 && React.createElement(Attachments, { attachments: attachments, onRemove: images.remove }),
|
|
420
|
+
uploaded.files.length > 0 && React.createElement(ComposerFiles, { files: uploaded.files, onRemove: uploaded.remove }),
|
|
406
421
|
React.createElement("div", { className: "ta-console-row ta-conversation" },
|
|
407
422
|
sections.length > 0 && (React.createElement("div", { className: "ta-plus", ref: plus },
|
|
408
423
|
React.createElement(IconButton, { icon: Plus, label: t('ta.composer.more'), className: `ta-attach ta-plus-button ${menu ? 'ta-on' : ''}`, onClick: toggleMenu }),
|
|
409
424
|
menu && !handheld && React.createElement(PlusMenu, { sections: sections, onClose: closeMenu }),
|
|
410
|
-
takesImages && recentShots && (React.createElement(RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file =>
|
|
425
|
+
takesImages && recentShots && (React.createElement(RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file => images.add([file]) })))),
|
|
411
426
|
takesImages && React.createElement(MediaInputs, { picker: picker, camera: handheld && touch ? camera : undefined, videos: !!props.videos, onChange: onPicked }),
|
|
427
|
+
takesFiles && React.createElement(FileInput, { picker: documents, onChange: onPicked }),
|
|
412
428
|
talkMode && React.createElement(TalkBar, { talk: talk }),
|
|
413
|
-
React.createElement("textarea", { ref: input, hidden: talkMode, rows: 1, value:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
429
|
+
React.createElement("textarea", { ref: input, hidden: talkMode, rows: 1, value: faces.shown, className: faces.mirror ? 'ta-faced' : undefined, autoFocus: autoFocus, enterKeyHint: "send", "aria-label": t('ta.composer.label'), "aria-controls": items.length ? menuId : undefined, "aria-activedescendant": items.length ? `${menuId}-${selected}` : undefined, placeholder: listening ? t('ta.composer.listening') : placeholder, onChange: event => {
|
|
430
|
+
const [next, position] = faces.typed(event.target.value, event.target.selectionStart);
|
|
431
|
+
setText(next);
|
|
432
|
+
onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(next);
|
|
433
|
+
setCaret(position);
|
|
417
434
|
setSelected(0);
|
|
418
|
-
|
|
435
|
+
// A face typed out by its name ([微笑]) turns into the face: the caret stays where it was,
|
|
436
|
+
// the browser told so, that it does not put its own back before the face.
|
|
437
|
+
if (faces.shown !== event.target.value) {
|
|
438
|
+
faces.settle(event.target, next, position);
|
|
439
|
+
}
|
|
440
|
+
}, onSelect: event => setCaret(faces.saidCaret(event.currentTarget.value, event.currentTarget.selectionStart)), onCopy: faces.mirror ? event => copyFaces(event, false) : undefined, onCut: faces.mirror ? event => copyFaces(event, true) : undefined, onKeyDown: onKeyDown, onPaste: onPaste, onFocus: () => {
|
|
419
441
|
setFocused(true);
|
|
420
442
|
// The keyboard comes in place of the panel.
|
|
421
443
|
if (menu && handheld) {
|
|
@@ -425,6 +447,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
425
447
|
emojis.close();
|
|
426
448
|
}
|
|
427
449
|
}, onBlur: () => setFocused(false) }),
|
|
450
|
+
faces.mirror && !talkMode && faces.mirror,
|
|
428
451
|
takesEmoji && (React.createElement(ComposerEmojiButton, { emoji: emojis, handheld: handheld, onPick: emoji => type(...EmojiPanelUtil.insert(text, caret, emoji)) })),
|
|
429
452
|
after,
|
|
430
453
|
microphone,
|
|
@@ -436,7 +459,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
|
|
|
436
459
|
? sendTitle
|
|
437
460
|
: t('ta.send'), "aria-label": action === 'stop' ? t(stopping ? 'ta.composer.stopping' : 'ta.stop') : t('ta.send'), "aria-busy": action === 'stop' && stopping, "data-ta-action": action === 'stop' ? 'stop' : 'send',
|
|
438
461
|
// Pressed with the keyboard open, the box keeps the focus and the keyboard stays, as in WeChat.
|
|
439
|
-
onPointerDown: event => document.activeElement === input.current && event.preventDefault(), onClick: () => (action === 'stop' ? stop() : send('enter')) }, action === 'stop' && stopping ? (React.createElement("span", { className: "ta-spinner" })) : (React.createElement(Icon, { icon: action === 'stop' ? Square : ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
|
|
462
|
+
onPointerDown: event => document.activeElement === input.current && event.preventDefault(), onClick: () => (action === 'stop' ? !ComposerUtil.accidentalStop(sentAt.current, performance.now()) && stop() : send('enter')) }, action === 'stop' && stopping ? (React.createElement("span", { className: "ta-spinner" })) : (React.createElement(Icon, { icon: action === 'stop' ? Square : ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
|
|
440
463
|
takesEmoji && handheld && (emojis.open || emojis.closing) && (React.createElement(EmojiPanel, { ref: emojis.panel, docked: true, closing: !emojis.open, onClosed: emojis.closed, onPick: emoji => type(...EmojiPanelUtil.insert(text, caret, emoji)), onDelete: () => type(...EmojiPanelUtil.deleteBack(text, caret)), sendable: sendable && !reading, onSend: () => void send('enter') })),
|
|
441
464
|
handheld && (menu || closing) && sections.length > 0 && (React.createElement(PlusMenu, { ref: panel, sections: sections, docked: true, closing: !menu, onClosed: () => setClosing(false), onClose: closeMenu }))));
|
|
442
465
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What a drop or a paste into the box is given: the files, where the box puts the text they name. */
|
|
2
|
+
export interface ComposerDropHook {
|
|
3
|
+
/** Takes what came, as the box takes it: the pictures into it as ever, every other file where it takes none. */
|
|
4
|
+
take(files: File[]): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The files of a drop or a paste into the message box (ComposerBoxProps.droppedFiles): the pictures (and the videos the
|
|
8
|
+
* box takes) into it as ever, and every other file where the box takes none, written by its owner under `uploads/` of
|
|
9
|
+
* the conversation and named as an `@` reference put where the caret is (ComposerDropUtil). A box that takes files of
|
|
10
|
+
* its own (files) keeps them as it did; one with neither hands them to the pictures, which says what it cannot send.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useComposerDrop(options: {
|
|
13
|
+
/** The box takes files of its own (ComposerBoxProps.files): they go there, pictures and all. */
|
|
14
|
+
files: boolean;
|
|
15
|
+
videos: boolean;
|
|
16
|
+
droppedFiles: ComposerBoxPropsFiles;
|
|
17
|
+
addImages(files: File[]): void;
|
|
18
|
+
/** Where the text typed so far is, as it is now: a file written a moment later still lands where the caret was. */
|
|
19
|
+
text(): string;
|
|
20
|
+
caret(): number;
|
|
21
|
+
insert(text: string, position: number): void;
|
|
22
|
+
onError(error: unknown): void;
|
|
23
|
+
}): ComposerDropHook;
|
|
24
|
+
/** ComposerBoxProps.droppedFiles, as the hook takes it. */
|
|
25
|
+
type ComposerBoxPropsFiles = ((files: File[]) => Promise<string[]>) | undefined;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComposerUtil } from '../util/composer.js';
|
|
3
|
+
import { ComposerDropUtil } from '../util/composer-drop.js';
|
|
4
|
+
/**
|
|
5
|
+
* The files of a drop or a paste into the message box (ComposerBoxProps.droppedFiles): the pictures (and the videos the
|
|
6
|
+
* box takes) into it as ever, and every other file where the box takes none, written by its owner under `uploads/` of
|
|
7
|
+
* the conversation and named as an `@` reference put where the caret is (ComposerDropUtil). A box that takes files of
|
|
8
|
+
* its own (files) keeps them as it did; one with neither hands them to the pictures, which says what it cannot send.
|
|
9
|
+
*/
|
|
10
|
+
export function useComposerDrop(options) {
|
|
11
|
+
const { files, videos, droppedFiles, addImages, text, caret, insert, onError } = options;
|
|
12
|
+
return {
|
|
13
|
+
take: React.useCallback((coming) => {
|
|
14
|
+
const write = files ? undefined : droppedFiles;
|
|
15
|
+
if (!coming.length) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!write) {
|
|
19
|
+
addImages(coming);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const { pictures, others } = ComposerDropUtil.part(coming, videos);
|
|
23
|
+
if (pictures.length) {
|
|
24
|
+
addImages(pictures);
|
|
25
|
+
}
|
|
26
|
+
if (!others.length) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// As the files come: what was typed a moment before they are written is still there.
|
|
30
|
+
void write(others)
|
|
31
|
+
.then(paths => insert(...ComposerUtil.insert(text(), caret(), `${ComposerDropUtil.references(paths)} `)))
|
|
32
|
+
.catch(error => onError(error));
|
|
33
|
+
}, [files, videos, droppedFiles, addImages, text, caret, insert, onError]),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=composer-drop-hooks.js.map
|
|
@@ -41,7 +41,7 @@ export function ComposerEmojiButton({ emoji, handheld, onPick }) {
|
|
|
41
41
|
const t = useT();
|
|
42
42
|
const keyboard = emoji.open && handheld;
|
|
43
43
|
return (React.createElement("div", { className: "ta-emoji-anchor", ref: emoji.anchor },
|
|
44
|
-
React.createElement("button", { type: "button", className: `ta-
|
|
44
|
+
React.createElement("button", { type: "button", className: `ta-emoji-button${emoji.open ? ' ta-on' : ''}`, title: t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-label": t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-expanded": emoji.open,
|
|
45
45
|
// On a computer the field keeps the focus while the popover opens.
|
|
46
46
|
onPointerDown: event => !handheld && event.preventDefault(), onClick: emoji.toggle },
|
|
47
47
|
React.createElement(Icon, { icon: keyboard ? Keyboard : Smile, size: 20 })),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The faces of the field of a box (ComposerBoxProps.emoji), as WeChat's box shows them: the text is still said the way
|
|
4
|
+
* it is sent (`[微笑]`), and the field shows each face as one character of its own font, drawn as the face (FaceField),
|
|
5
|
+
* which the caret steps over and Delete takes whole. Everything here is between the two.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useBoxFaces(field: React.RefObject<HTMLTextAreaElement | null>, text: string, takes: boolean): {
|
|
8
|
+
shown: string;
|
|
9
|
+
taken: boolean;
|
|
10
|
+
shownCaret: (said: string, position: number) => number;
|
|
11
|
+
saidCaret: (value: string, position: number) => number;
|
|
12
|
+
typed: (value: string, position: number) => [string, number];
|
|
13
|
+
settle: (field: HTMLTextAreaElement, said: string, position: number) => void;
|
|
14
|
+
copied: (event: React.ClipboardEvent<HTMLTextAreaElement>, cut: boolean) => string | undefined;
|
|
15
|
+
mirror: React.JSX.Element | undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChatEmojiUtil, FaceField } from './chat-emoji.js';
|
|
3
|
+
/**
|
|
4
|
+
* The faces of the field of a box (ComposerBoxProps.emoji), as WeChat's box shows them: the text is still said the way
|
|
5
|
+
* it is sent (`[微笑]`), and the field shows each face as one character of its own font, drawn as the face (FaceField),
|
|
6
|
+
* which the caret steps over and Delete takes whole. Everything here is between the two.
|
|
7
|
+
*/
|
|
8
|
+
export function useBoxFaces(field, text, takes) {
|
|
9
|
+
// What the field holds: each face one character.
|
|
10
|
+
const shown = takes ? ChatEmojiUtil.glyphs(text) : text;
|
|
11
|
+
/** Where a place of the text is in the field, and back. */
|
|
12
|
+
const shownCaret = React.useCallback((said, position) => (takes ? ChatEmojiUtil.shownCaret(said, position) : position), [takes]);
|
|
13
|
+
const saidCaret = React.useCallback((value, position) => (takes ? ChatEmojiUtil.saidCaret(value, position) : position), [takes]);
|
|
14
|
+
/** What the field was given: the text as it is said, and where the caret is in it. */
|
|
15
|
+
const typed = React.useCallback((value, position) => [takes ? ChatEmojiUtil.codes(value) : value, saidCaret(value, position)], [takes, saidCaret]);
|
|
16
|
+
/** A face typed out by its name ([微笑]) turned into the face: the caret put where it was, after it. */
|
|
17
|
+
const settle = (field, said, position) => {
|
|
18
|
+
const at = ChatEmojiUtil.shownCaret(said, position);
|
|
19
|
+
field.setSelectionRange(at, at);
|
|
20
|
+
};
|
|
21
|
+
/** Copied or cut, faces go as their names in brackets, as WeChat pastes them; what comes back is the text left. */
|
|
22
|
+
const copied = (event, cut) => {
|
|
23
|
+
const element = event.currentTarget;
|
|
24
|
+
const from = element.selectionStart;
|
|
25
|
+
const to = element.selectionEnd;
|
|
26
|
+
if (!takes || from === to) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
event.clipboardData.setData('text/plain', ChatEmojiUtil.codes(element.value.slice(from, to)));
|
|
31
|
+
return cut ? ChatEmojiUtil.codes(element.value.slice(0, from) + element.value.slice(to)) : undefined;
|
|
32
|
+
};
|
|
33
|
+
/** The faces of what the field shows, over it. */
|
|
34
|
+
const mirror = shown === text ? undefined : React.createElement(FaceField, { field: field, text: shown });
|
|
35
|
+
return { shown, taken: takes, shownCaret, saidCaret, typed, settle, copied, mirror };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=composer-faces.js.map
|
|
@@ -24,3 +24,13 @@ export declare function MediaInputs({ picker, camera, videos, onChange, }: {
|
|
|
24
24
|
videos: boolean;
|
|
25
25
|
onChange(event: React.ChangeEvent<HTMLInputElement>): void;
|
|
26
26
|
}): React.JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* The tile of the + that adds files at all (ComposerBoxProps.files): a PDF, a sheet, a picture a model cannot see.
|
|
29
|
+
* They go to `uploads/` of the conversation, which the message names as `@` references.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fileTile(t: ReturnType<typeof useT>, pick: () => void): ComposerAction;
|
|
32
|
+
/** The field of those files, hidden: they are anything, so it takes anything. */
|
|
33
|
+
export declare function FileInput({ picker, onChange }: {
|
|
34
|
+
picker: React.Ref<HTMLInputElement>;
|
|
35
|
+
onChange(event: React.ChangeEvent<HTMLInputElement>): void;
|
|
36
|
+
}): React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Camera, ImagePlus, Images } from 'lucide-react';
|
|
1
|
+
import { Camera, FilePlus2, ImagePlus, Images } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { VideoPicks } from '../device/video-picks.js';
|
|
4
4
|
import { IMAGE_TYPES } from '../util/composer.js';
|
|
@@ -34,4 +34,15 @@ export function MediaInputs({ picker, camera, videos, onChange, }) {
|
|
|
34
34
|
React.createElement("input", { ref: picker, type: "file", accept: VideoPicks.accept(IMAGE_TYPES, videos), multiple: true, hidden: true, onChange: onChange }),
|
|
35
35
|
camera && React.createElement("input", { ref: camera, type: "file", accept: videos ? 'image/*,video/*' : 'image/*', capture: "environment", hidden: true, onChange: onChange })));
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The tile of the + that adds files at all (ComposerBoxProps.files): a PDF, a sheet, a picture a model cannot see.
|
|
39
|
+
* They go to `uploads/` of the conversation, which the message names as `@` references.
|
|
40
|
+
*/
|
|
41
|
+
export function fileTile(t, pick) {
|
|
42
|
+
return { key: 'file', label: t('ta.composer.addFile'), icon: React.createElement(Icon, { icon: FilePlus2, size: 16 }), run: pick };
|
|
43
|
+
}
|
|
44
|
+
/** The field of those files, hidden: they are anything, so it takes anything. */
|
|
45
|
+
export function FileInput({ picker, onChange }) {
|
|
46
|
+
return React.createElement("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: onChange });
|
|
47
|
+
}
|
|
37
48
|
//# sourceMappingURL=composer-media.js.map
|
|
@@ -18,6 +18,10 @@ export interface ComposerDraft {
|
|
|
18
18
|
export declare namespace ComposerTarget {
|
|
19
19
|
/** A box shown; returns what forgets it. */
|
|
20
20
|
function set(handle: ComposerBoxHandle): () => void;
|
|
21
|
+
/** Whether a box is in front to type in. */
|
|
22
|
+
function present(): boolean;
|
|
23
|
+
/** Types a key pressed on the page at the end of what the box in front holds, and focuses it; false when none is shown. */
|
|
24
|
+
function type(key: string): boolean;
|
|
21
25
|
/** Puts the draft in the box in front, and focuses it; false when no box is shown. */
|
|
22
26
|
function add(draft: ComposerDraft): boolean;
|
|
23
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComposerUtil } from '../util/composer.js';
|
|
1
2
|
import { QuoteUtil } from '../util/quote.js';
|
|
2
3
|
/**
|
|
3
4
|
* The message box in front of the user, which extensions put things in (a conversation's, or one of an extension's
|
|
@@ -17,16 +18,26 @@ export var ComposerTarget;
|
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
ComposerTarget.set = set;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const extension = ((_a = mimeType.split('/')[1]) === null || _a === void 0 ? void 0 : _a.replace('jpeg', 'jpg')) || 'png';
|
|
24
|
-
return new File([bytes], `picked-${index + 1}.${extension}`, { type: mimeType });
|
|
21
|
+
/** The box in front: the last one shown that is on the screen. */
|
|
22
|
+
function front() {
|
|
23
|
+
return [...shown].reverse().find(each => each.shown());
|
|
25
24
|
}
|
|
25
|
+
/** Whether a box is in front to type in. */
|
|
26
|
+
function present() {
|
|
27
|
+
return !!front();
|
|
28
|
+
}
|
|
29
|
+
ComposerTarget.present = present;
|
|
30
|
+
/** Types a key pressed on the page at the end of what the box in front holds, and focuses it; false when none is shown. */
|
|
31
|
+
function type(key) {
|
|
32
|
+
const box = front();
|
|
33
|
+
box === null || box === void 0 ? void 0 : box.setText(box.text() + key);
|
|
34
|
+
return !!box;
|
|
35
|
+
}
|
|
36
|
+
ComposerTarget.type = type;
|
|
26
37
|
/** Puts the draft in the box in front, and focuses it; false when no box is shown. */
|
|
27
38
|
function add(draft) {
|
|
28
39
|
var _a, _b;
|
|
29
|
-
const box =
|
|
40
|
+
const box = front();
|
|
30
41
|
if (!box) {
|
|
31
42
|
return false;
|
|
32
43
|
}
|
|
@@ -38,7 +49,7 @@ export var ComposerTarget;
|
|
|
38
49
|
box.setText(`${held}${held && !/\s$/.test(held) ? ' ' : ''}${draft.text}`);
|
|
39
50
|
}
|
|
40
51
|
if (((_b = draft.images) === null || _b === void 0 ? void 0 : _b.length) && box.addFiles) {
|
|
41
|
-
box.addFiles(draft.images.map(
|
|
52
|
+
box.addFiles(draft.images.map(ComposerUtil.imageFile));
|
|
42
53
|
}
|
|
43
54
|
return true;
|
|
44
55
|
}
|