@azure/communication-react 1.30.0 → 1.31.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/communication-react.d.ts +1373 -24
- package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-DdSFdo_m.js +213 -0
- package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-DdSFdo_m.js.map +1 -0
- package/dist/dist-cjs/communication-react/RichTextSendBoxWrapper-C2HrwCVY.js +49 -0
- package/dist/dist-cjs/communication-react/RichTextSendBoxWrapper-C2HrwCVY.js.map +1 -0
- package/dist/dist-cjs/communication-react/index-CH39vOsT.js +46344 -0
- package/dist/dist-cjs/communication-react/index-CH39vOsT.js.map +1 -0
- package/dist/dist-cjs/communication-react/index.js +174 -40373
- package/dist/dist-cjs/communication-react/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/common.d.ts +13 -0
- package/dist/dist-esm/acs-ui-common/src/common.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/constants.d.ts +5 -0
- package/dist/dist-esm/acs-ui-common/src/constants.js +5 -0
- package/dist/dist-esm/acs-ui-common/src/constants.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/dataConversion.d.ts +6 -0
- package/dist/dist-esm/acs-ui-common/src/dataConversion.js +20 -0
- package/dist/dist-esm/acs-ui-common/src/dataConversion.js.map +1 -0
- package/dist/dist-esm/acs-ui-common/src/index.d.ts +4 -0
- package/dist/dist-esm/acs-ui-common/src/index.js +3 -0
- package/dist/dist-esm/acs-ui-common/src/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/removeImageTags.d.ts +7 -0
- package/dist/dist-esm/acs-ui-common/src/removeImageTags.js +18 -0
- package/dist/dist-esm/acs-ui-common/src/removeImageTags.js.map +1 -0
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js +2 -0
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.d.ts +2 -0
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js +6 -0
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/handlers/createTeamsCallHandlers.js +25 -1
- package/dist/dist-esm/calling-component-bindings/src/handlers/createTeamsCallHandlers.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/participantListSelector.d.ts +1 -0
- package/dist/dist-esm/calling-component-bindings/src/participantListSelector.js +3 -1
- package/dist/dist-esm/calling-component-bindings/src/participantListSelector.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallAgentDeclarativeCommon.js +4 -0
- package/dist/dist-esm/calling-stateful-client/src/CallAgentDeclarativeCommon.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.d.ts +42 -2
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallContext.d.ts +6 -0
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js +35 -0
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.d.ts +4 -0
- package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js +24 -4
- package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/Converter.js +3 -0
- package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.d.ts +17 -0
- package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.js +33 -0
- package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.js.map +1 -0
- package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.d.ts +1 -0
- package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.js +7 -1
- package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/TeamsCallDeclarative.js +17 -0
- package/dist/dist-esm/calling-stateful-client/src/TeamsCallDeclarative.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/index-public.d.ts +1 -0
- package/dist/dist-esm/calling-stateful-client/src/index-public.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.d.ts +6 -2
- package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js +36 -2
- package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.d.ts +2 -1
- package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.js +4 -0
- package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +25 -2
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.d.ts +6 -0
- package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.js +20 -0
- package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.js.map +1 -0
- package/dist/dist-esm/chat-component-bindings/src/utils/updateMessagesWithAttached.js +3 -3
- package/dist/dist-esm/chat-component-bindings/src/utils/updateMessagesWithAttached.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/ChatClientState.d.ts +15 -1
- package/dist/dist-esm/chat-stateful-client/src/ChatClientState.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js +2 -1
- package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/index.d.ts +1 -0
- package/dist/dist-esm/chat-stateful-client/src/index.js.map +1 -1
- package/dist/dist-esm/communication-react/src/index.d.ts +21 -0
- package/dist/dist-esm/communication-react/src/index.js +3 -0
- package/dist/dist-esm/communication-react/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.d.ts +2 -0
- package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.js +1 -0
- package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.d.ts +13 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js +9 -3
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.d.ts +11 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +32 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.d.ts +10 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.js +15 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.d.ts +8 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js +9 -5
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.d.ts +2 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.js +4 -4
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.d.ts +4 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js +31 -6
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.d.ts +15 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js +9 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.d.ts +24 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +203 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.d.ts +23 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js +17 -6
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.d.ts +8 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js +10 -6
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/FluentChatMyMessageComponent.js +5 -5
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/FluentChatMyMessageComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.d.ts +69 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.js +36 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.d.ts +75 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.js +67 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.d.ts +105 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.js +51 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.d.ts +86 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.js +40 -0
- package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/ImageOverlay.js +2 -0
- package/dist/dist-esm/react-components/src/components/ImageOverlay.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/InputBoxComponent.d.ts +2 -0
- package/dist/dist-esm/react-components/src/components/InputBoxComponent.js +15 -0
- package/dist/dist-esm/react-components/src/components/InputBoxComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/MentionPopover.d.ts +121 -0
- package/dist/dist-esm/react-components/src/components/MentionPopover.js +119 -0
- package/dist/dist-esm/react-components/src/components/MentionPopover.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/MessageThread.d.ts +81 -5
- package/dist/dist-esm/react-components/src/components/MessageThread.js +13 -3
- package/dist/dist-esm/react-components/src/components/MessageThread.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ParticipantList.d.ts +15 -0
- package/dist/dist-esm/react-components/src/components/ParticipantList.js +12 -3
- package/dist/dist-esm/react-components/src/components/ParticipantList.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.d.ts +9 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js +29 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.d.ts +30 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js +98 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.d.ts +19 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js +43 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.d.ts +15 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js +42 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.d.ts +24 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js +64 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.d.ts +20 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js +45 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.d.ts +14 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.js +42 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.d.ts +30 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js +99 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.d.ts +59 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js +334 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.d.ts +37 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js +78 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.d.ts +215 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +184 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.d.ts +16 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js +75 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.d.ts +9 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.js +16 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.d.ts +19 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js +229 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.d.ts +7 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js +51 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.d.ts +15 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.js +64 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.d.ts +6 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js +13 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/SendBox.d.ts +51 -1
- package/dist/dist-esm/react-components/src/components/SendBox.js +58 -6
- package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.d.ts +56 -0
- package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.js +75 -0
- package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.d.ts +14 -0
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.js +18 -0
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.d.ts +24 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js +550 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.d.ts +152 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.js +819 -0
- package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/index.d.ts +21 -0
- package/dist/dist-esm/react-components/src/components/index.js +8 -0
- package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/styles/AttachmentCardGroup.styles.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.d.ts +58 -0
- package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.js +144 -0
- package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.d.ts +26 -0
- package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.js +69 -0
- package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.d.ts +3 -3
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js +8 -0
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.d.ts +82 -0
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js +328 -0
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.d.ts +21 -0
- package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.js +38 -0
- package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.d.ts +38 -0
- package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.js +99 -0
- package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/styles/Stack.style.d.ts +5 -0
- package/dist/dist-esm/react-components/src/components/styles/Stack.style.js +32 -0
- package/dist/dist-esm/react-components/src/components/styles/Stack.style.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.d.ts +38 -1
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js +30 -3
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.d.ts +4 -2
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js +9 -2
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.d.ts +73 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js +178 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.d.ts +33 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js +119 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +47 -1
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +154 -4
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.js +2 -0
- package/dist/dist-esm/react-components/src/components/utils/common.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/getParticipantsWhoHaveReadMessage.d.ts +2 -1
- package/dist/dist-esm/react-components/src/components/utils/getParticipantsWhoHaveReadMessage.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/merge.d.ts +7 -0
- package/dist/dist-esm/react-components/src/components/utils/merge.js +16 -0
- package/dist/dist-esm/react-components/src/components/utils/merge.js.map +1 -0
- package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.d.ts +4 -0
- package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.js +3 -1
- package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.js.map +1 -1
- package/dist/dist-esm/react-components/src/index.d.ts +1 -0
- package/dist/dist-esm/react-components/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/LocalizationProvider.d.ts +45 -0
- package/dist/dist-esm/react-components/src/localization/LocalizationProvider.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/icons.d.ts +24 -0
- package/dist/dist-esm/react-components/src/theming/icons.js +67 -0
- package/dist/dist-esm/react-components/src/theming/icons.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/icons.styles.d.ts +6 -0
- package/dist/dist-esm/react-components/src/theming/icons.styles.js +25 -0
- package/dist/dist-esm/react-components/src/theming/icons.styles.js.map +1 -0
- package/dist/dist-esm/react-components/src/theming/themes.d.ts +6 -0
- package/dist/dist-esm/react-components/src/theming/themes.js +9 -0
- package/dist/dist-esm/react-components/src/theming/themes.js.map +1 -1
- package/dist/dist-esm/react-components/src/types/Attachment.d.ts +13 -0
- package/dist/dist-esm/react-components/src/types/Attachment.js.map +1 -1
- package/dist/dist-esm/react-components/src/types/ChatMessage.d.ts +20 -1
- package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.d.ts +59 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js +15 -10
- package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.d.ts +38 -6
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js +12 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/index.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.d.ts +46 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js +200 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.js +19 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageErrorBar.js +10 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageErrorBar.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.js +19 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.d.ts +1 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.js +5 -3
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js +3 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.d.ts +3 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.d.ts +7 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.js +43 -5
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/HoldPage.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/HoldPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/LobbyPage.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/LobbyPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/TransferPage.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/TransferPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.d.ts +8 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.js +68 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.d.ts +52 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js +10 -4
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +10 -3
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +20 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +16 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +10 -4
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +14 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.d.ts +15 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.js +23 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.d.ts +27 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js +2 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +189 -11
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.d.ts +18 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.js +18 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.d.ts +49 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.js +44 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.d.ts +39 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js +267 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.d.ts +20 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +6 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +36 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +12 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.d.ts +80 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js +36 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.d.ts +38 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js +66 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.d.ts +5 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js +5 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js +13 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.d.ts +4 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js +4 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ParticipantContainer.js +2 -1
- package/dist/dist-esm/react-composites/src/composites/common/ParticipantContainer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.d.ts +10 -0
- package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.js +16 -0
- package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.d.ts +41 -2
- package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.js +21 -0
- package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/constants.d.ts +5 -0
- package/dist/dist-esm/react-composites/src/composites/common/constants.js +5 -0
- package/dist/dist-esm/react-composites/src/composites/common/constants.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/icons.d.ts +26 -1
- package/dist/dist-esm/react-composites/src/composites/common/icons.js +2 -0
- package/dist/dist-esm/react-composites/src/composites/common/icons.js.map +1 -1
- package/package.json +4 -4
@@ -0,0 +1,203 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
import { mergeStyles, Stack } from '@fluentui/react';
|
4
|
+
import { ChatMyMessage } from '@fluentui-contrib/react-chat';
|
5
|
+
import { mergeClasses } from '@fluentui/react-components';
|
6
|
+
import { useTheme } from '../../../theming';
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
8
|
+
import { useReducer } from 'react';
|
9
|
+
import { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '../../styles/EditBox.styles';
|
10
|
+
import { InputBoxButton } from '../../InputBoxButton';
|
11
|
+
import { useChatMyMessageStyles } from '../../styles/MessageThread.styles';
|
12
|
+
import { _AttachmentUploadCards } from '../../Attachment/AttachmentUploadCards';
|
13
|
+
import { useChatMessageRichTextEditContainerStyles } from '../../styles/ChatMessageComponent.styles';
|
14
|
+
import { modifyInlineImagesInContentString } from '../../utils/SendBoxUtils';
|
15
|
+
import { hasIncompleteAttachmentUploads, removeBrokenImageContentAndClearImageSizeStyles, getContentWithUpdatedInlineImagesInfo, isMessageTooLong, inlineImageIds } from '../../utils/SendBoxUtils';
|
16
|
+
import { getMessageState, onRenderCancelIcon, onRenderSubmitIcon, getTextValidationErrorMessage } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
17
|
+
import { attachmentMetadataReducer, getMessageWithAttachmentMetadata, doesMessageContainMultipleAttachments } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
18
|
+
import { RichTextInputBoxComponent } from '../../RichTextEditor/RichTextInputBoxComponent';
|
19
|
+
import { editBoxRichTextEditorStyle, richTextActionButtonsStyle } from '../../styles/RichTextEditor.styles';
|
20
|
+
import { RichTextSendBoxErrors } from '../../RichTextEditor/RichTextSendBoxErrors';
|
21
|
+
import { useLocale } from '../../../localization';
|
22
|
+
import { FluentV9ThemeProvider } from '../../../theming/FluentV9ThemeProvider';
|
23
|
+
import { attachmentUploadCardsStyles } from '../../styles/SendBox.styles';
|
24
|
+
import { SendBoxErrorBarType } from '../../SendBoxErrorBar';
|
25
|
+
import { BROKEN_IMAGE_SVG_DATA } from '../../styles/Common.style';
|
26
|
+
import { getPreviousInlineImages } from '../../utils/RichTextEditorUtils';
|
27
|
+
/**
|
28
|
+
* @private
|
29
|
+
*/
|
30
|
+
export const ChatMessageComponentAsRichTextEditBox = (props) => {
|
31
|
+
var _a;
|
32
|
+
const { onCancel, onSubmit, strings, message, onPaste, onInsertInlineImage, inlineImagesWithProgress, onRemoveInlineImage } = props;
|
33
|
+
const [initialInlineImages, setInitialInlineImages] = useState([]);
|
34
|
+
const initialContent = useMemo(() => {
|
35
|
+
const content = message.content;
|
36
|
+
setInitialInlineImages(getPreviousInlineImages(content));
|
37
|
+
const document = new DOMParser().parseFromString(content !== null && content !== void 0 ? content : '', 'text/html');
|
38
|
+
// The broken image element is a div element with all the attributes of the original image element.
|
39
|
+
// We need to convert it to a img element so the Rooster knows how to render it.
|
40
|
+
// And we need to copy over all the attributes such as id, width, etc.
|
41
|
+
// which is needed for sending the message with the images correctly.
|
42
|
+
document.querySelectorAll('.broken-image-wrapper').forEach(brokenImage => {
|
43
|
+
var _a;
|
44
|
+
const imageElement = document.createElement('img');
|
45
|
+
const attributes = brokenImage.attributes;
|
46
|
+
for (const attribute of attributes) {
|
47
|
+
imageElement.setAttribute(attribute.name, attribute.value);
|
48
|
+
}
|
49
|
+
imageElement.src = BROKEN_IMAGE_SVG_DATA;
|
50
|
+
imageElement.style.width = '3rem';
|
51
|
+
imageElement.style.height = '3rem';
|
52
|
+
(_a = brokenImage.parentElement) === null || _a === void 0 ? void 0 : _a.replaceChild(imageElement, brokenImage);
|
53
|
+
});
|
54
|
+
return document.body.innerHTML;
|
55
|
+
return message.content;
|
56
|
+
}, [message]);
|
57
|
+
const [contentValue, setContentValue] = useState(initialContent || '');
|
58
|
+
const [contentValueWithInlineImagesOverflow, setContentValueWithInlineImagesOverflow] = useState(false);
|
59
|
+
const [attachmentMetadata, handleAttachmentAction] = useReducer(attachmentMetadataReducer, (_a = getMessageWithAttachmentMetadata(message)) !== null && _a !== void 0 ? _a : []);
|
60
|
+
const [attachmentUploadsPendingError, setAttachmentUploadsPendingError] = useState(undefined);
|
61
|
+
const editTextFieldRef = React.useRef(null);
|
62
|
+
const theme = useTheme();
|
63
|
+
const messageState = useMemo(() => {
|
64
|
+
var _a, _b;
|
65
|
+
// get plain text content from the editor to check if the message is empty
|
66
|
+
// as the content may contain tags even when the content is empty
|
67
|
+
const plainTextContent = (_b = (_a = editTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.getPlainContent()) !== null && _b !== void 0 ? _b : contentValue;
|
68
|
+
let messageLengthState = getMessageState(plainTextContent, attachmentMetadata !== null && attachmentMetadata !== void 0 ? attachmentMetadata : []);
|
69
|
+
const imageIds = inlineImageIds(contentValue);
|
70
|
+
if (messageLengthState !== 'OK' && imageIds.length > 0) {
|
71
|
+
// Check if too long
|
72
|
+
if (isMessageTooLong(contentValue.length)) {
|
73
|
+
messageLengthState = 'too long';
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
messageLengthState = 'OK';
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return messageLengthState;
|
80
|
+
}, [attachmentMetadata, contentValue]);
|
81
|
+
const imageUploadErrorMessage = useMemo(() => {
|
82
|
+
var _a, _b;
|
83
|
+
return (_b = (_a = inlineImagesWithProgress === null || inlineImagesWithProgress === void 0 ? void 0 : inlineImagesWithProgress.filter(image => image.error).pop()) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message;
|
84
|
+
}, [inlineImagesWithProgress]);
|
85
|
+
const editContainerStyles = useChatMessageRichTextEditContainerStyles();
|
86
|
+
const chatMyMessageStyles = useChatMyMessageStyles();
|
87
|
+
const locale = useLocale().strings;
|
88
|
+
const setContent = useCallback((newValue) => {
|
89
|
+
setContentValue(newValue !== null && newValue !== void 0 ? newValue : '');
|
90
|
+
}, []);
|
91
|
+
useEffect(() => {
|
92
|
+
var _a;
|
93
|
+
(_a = editTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
94
|
+
}, []);
|
95
|
+
const textValidationErrorMessage = useMemo(() => {
|
96
|
+
return getTextValidationErrorMessage(messageState, strings.editBoxTextLimit, strings.editBoxEmptyWarningText, contentValueWithInlineImagesOverflow);
|
97
|
+
}, [messageState, strings.editBoxTextLimit, strings.editBoxEmptyWarningText, contentValueWithInlineImagesOverflow]);
|
98
|
+
const iconClassName = useCallback((isHover) => {
|
99
|
+
const color = isHover ? theme.palette.accent : theme.palette.neutralSecondary;
|
100
|
+
return mergeStyles(richTextEditBoxActionButtonIcon, {
|
101
|
+
color
|
102
|
+
});
|
103
|
+
}, [theme.palette.accent, theme.palette.neutralSecondary]);
|
104
|
+
const onRenderThemedCancelIcon = useCallback((isHover) => {
|
105
|
+
return onRenderCancelIcon(iconClassName(isHover));
|
106
|
+
}, [iconClassName]);
|
107
|
+
const onRenderThemedSubmitIcon = useCallback((isHover) => {
|
108
|
+
return onRenderSubmitIcon(iconClassName(isHover));
|
109
|
+
}, [iconClassName]);
|
110
|
+
const hasMultipleAttachments = useMemo(() => {
|
111
|
+
return doesMessageContainMultipleAttachments(message);
|
112
|
+
}, [message]);
|
113
|
+
const onSubmitHandler = useCallback(() => {
|
114
|
+
if (messageState !== 'OK') {
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
if (inlineImagesWithProgress && inlineImagesWithProgress.length > 0) {
|
118
|
+
const contentWithUpdatedInlineImagesInfo = getContentWithUpdatedInlineImagesInfo(contentValue, inlineImagesWithProgress);
|
119
|
+
const messageTooLong = isMessageTooLong(contentWithUpdatedInlineImagesInfo.length);
|
120
|
+
// Set contentValueWithInlineImagesOverflow state to display the error bar
|
121
|
+
setContentValueWithInlineImagesOverflow(messageTooLong);
|
122
|
+
// The change from the setContentValueOverflow in the previous line will not kick in yet.
|
123
|
+
// We need to rely on the local value of messageTooLong to return early if the message is too long.
|
124
|
+
if (messageTooLong) {
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
// Don't send message until all attachments have been uploaded successfully
|
129
|
+
setAttachmentUploadsPendingError(undefined);
|
130
|
+
if (hasIncompleteAttachmentUploads(inlineImagesWithProgress)) {
|
131
|
+
setAttachmentUploadsPendingError({
|
132
|
+
message: strings.imageUploadsPendingError,
|
133
|
+
timestamp: Date.now(),
|
134
|
+
errorBarType: SendBoxErrorBarType.info
|
135
|
+
});
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
let content = contentValue;
|
139
|
+
content = removeBrokenImageContentAndClearImageSizeStyles(content);
|
140
|
+
let initInlineImages = [];
|
141
|
+
initInlineImages = initialInlineImages !== null && initialInlineImages !== void 0 ? initialInlineImages : [];
|
142
|
+
modifyInlineImagesInContentString(content, initInlineImages, (content) => {
|
143
|
+
// it's very important to pass an empty attachment here
|
144
|
+
// so when user removes all attachments, UI can reflect it instantly
|
145
|
+
// if you set it to undefined, the attachments pre-edited would still be there
|
146
|
+
// until edit message event is received
|
147
|
+
onSubmit(content, attachmentMetadata || []);
|
148
|
+
});
|
149
|
+
}, [messageState, inlineImagesWithProgress, initialInlineImages, contentValue, strings.imageUploadsPendingError, onSubmit, attachmentMetadata]);
|
150
|
+
const actionButtons = useMemo(() => {
|
151
|
+
return React.createElement(Stack, { horizontal: true },
|
152
|
+
React.createElement(InputBoxButton, { className: richTextActionButtonsStyle, ariaLabel: strings.editBoxCancelButton, tooltipContent: strings.editBoxCancelButton, onRenderIcon: onRenderThemedCancelIcon, onClick: () => {
|
153
|
+
onCancel && onCancel(message.messageId);
|
154
|
+
}, id: 'dismissIconWrapper', "data-testId": 'chat-message-rich-text-edit-box-cancel-button' }),
|
155
|
+
React.createElement(InputBoxButton, { className: richTextActionButtonsStyle, ariaLabel: strings.editBoxSubmitButton, tooltipContent: strings.editBoxSubmitButton, onRenderIcon: onRenderThemedSubmitIcon, onClick: e => {
|
156
|
+
onSubmitHandler();
|
157
|
+
e.stopPropagation();
|
158
|
+
}, id: 'submitIconWrapper', "data-testId": 'chat-message-rich-text-edit-box-submit-button' }));
|
159
|
+
}, [message.messageId, onCancel, onRenderThemedCancelIcon, onRenderThemedSubmitIcon, strings.editBoxCancelButton, strings.editBoxSubmitButton, onSubmitHandler]);
|
160
|
+
const richTextLocaleStrings = useMemo(() => {
|
161
|
+
return Object.assign(Object.assign({}, locale.richTextSendBox), strings);
|
162
|
+
return locale.sendBox;
|
163
|
+
}, [locale.richTextSendBox, strings, locale.sendBox]);
|
164
|
+
const onCancelAttachmentUpload = useCallback((attachmentId) => {
|
165
|
+
// edit box only capable of removing attachments
|
166
|
+
// we need to expand attachment actions
|
167
|
+
// if we want to support more actions e.g. add
|
168
|
+
handleAttachmentAction({
|
169
|
+
type: 'remove',
|
170
|
+
id: attachmentId
|
171
|
+
});
|
172
|
+
}, []);
|
173
|
+
const onRenderAttachmentUploads = useCallback(() => {
|
174
|
+
return React.createElement(Stack, { className: attachmentUploadCardsStyles },
|
175
|
+
React.createElement(FluentV9ThemeProvider, { v8Theme: theme },
|
176
|
+
React.createElement(_AttachmentUploadCards, { attachments: attachmentMetadata, onCancelAttachmentUpload: onCancelAttachmentUpload })));
|
177
|
+
}, [attachmentMetadata, onCancelAttachmentUpload, theme]);
|
178
|
+
const onChangeHandler = useCallback((content, removedInlineImages) => {
|
179
|
+
removedInlineImages === null || removedInlineImages === void 0 ? void 0 : removedInlineImages.forEach((removedInlineImage) => {
|
180
|
+
onRemoveInlineImage && onRemoveInlineImage(removedInlineImage, message.messageId);
|
181
|
+
});
|
182
|
+
setContent(content);
|
183
|
+
}, [setContent, onRemoveInlineImage, message.messageId]);
|
184
|
+
const getContent = () => {
|
185
|
+
return React.createElement(Stack, { className: mergeStyles(editBoxWidthStyles) },
|
186
|
+
React.createElement(RichTextSendBoxErrors, { textValidationErrorMessage: textValidationErrorMessage, systemMessage: message.failureReason, attachmentUploadsPendingError: attachmentUploadsPendingError, attachmentProgressError: imageUploadErrorMessage ? {
|
187
|
+
message: imageUploadErrorMessage,
|
188
|
+
timestamp: Date.now(),
|
189
|
+
errorBarType: SendBoxErrorBarType.error
|
190
|
+
} : undefined }),
|
191
|
+
React.createElement(RichTextInputBoxComponent, { placeholderText: strings.editBoxPlaceholderText, onChange: onChangeHandler, onEnterKeyDown: onSubmitHandler, editorComponentRef: editTextFieldRef, initialContent: initialContent, strings: richTextLocaleStrings, disabled: false, actionComponents: actionButtons, richTextEditorStyleProps: editBoxRichTextEditorStyle, isHorizontalLayoutDisabled: true, onRenderAttachmentUploads: onRenderAttachmentUploads, onPaste: onPaste, onInsertInlineImage: onInsertInlineImage ? (imageAttributes) => {
|
192
|
+
onInsertInlineImage(imageAttributes, message.messageId);
|
193
|
+
} : undefined }));
|
194
|
+
};
|
195
|
+
const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';
|
196
|
+
return React.createElement(ChatMyMessage, { attached: attached, root: {
|
197
|
+
className: mergeClasses(chatMyMessageStyles.root, hasMultipleAttachments ? chatMyMessageStyles.multipleAttachmentsInEditing : undefined)
|
198
|
+
}, body: {
|
199
|
+
className: mergeClasses(editContainerStyles.body, attached !== 'top' ? editContainerStyles.bodyAttached : undefined)
|
200
|
+
} }, getContent());
|
201
|
+
};
|
202
|
+
export default ChatMessageComponentAsRichTextEditBox;
|
203
|
+
//# sourceMappingURL=ChatMessageComponentAsRichTextEditBox.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ChatMessageComponentAsRichTextEditBox.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;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QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,IAAI,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,eAAuC,EAAE,EAAE;oBACvhB,mBAAmB,CAAC,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC,CAAC,SAAS,GAAI,CACT,CAAC;IACb,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACzG,OAAO,oBAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC9C,SAAS,EAAE,YAAY,CAAC,mBAAmB,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC,CAAC,mBAAmB,CAAC,4BAA4B,CAAC,CAAC,CAAC,SAAS,CAAC;SACzI,EAAE,IAAI,EAAE;YACP,SAAS,EAAE,YAAY,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;SACrH,IACI,UAAU,EAAE,CACC,CAAC;AACrB,CAAC,CAAC;AACF,eAAe,qCAAqC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { mergeStyles, Stack } from '@fluentui/react';\nimport { ChatMyMessage } from '@fluentui-contrib/react-chat';\nimport { mergeClasses } from '@fluentui/react-components';\nimport { _formatString } from '@internal/acs-ui-common';\nimport { AttachmentMetadataInProgress } from '@internal/acs-ui-common';\nimport { useTheme } from '../../../theming';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useReducer } from 'react';\nimport { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '../../styles/EditBox.styles';\nimport { InputBoxButton } from '../../InputBoxButton';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { useChatMyMessageStyles } from '../../styles/MessageThread.styles';\nimport { ChatMessage } from '../../../types';\nimport { _AttachmentUploadCards } from '../../Attachment/AttachmentUploadCards';\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\nimport { useChatMessageRichTextEditContainerStyles } from '../../styles/ChatMessageComponent.styles';\nimport { modifyInlineImagesInContentString } from '../../utils/SendBoxUtils';\nimport { hasIncompleteAttachmentUploads, removeBrokenImageContentAndClearImageSizeStyles, getContentWithUpdatedInlineImagesInfo, isMessageTooLong, inlineImageIds } from '../../utils/SendBoxUtils';\nimport { getMessageState, MessageState, onRenderCancelIcon, onRenderSubmitIcon, getTextValidationErrorMessage } from '../../utils/ChatMessageComponentAsEditBoxUtils';\nimport { attachmentMetadataReducer, getMessageWithAttachmentMetadata, doesMessageContainMultipleAttachments } from '../../utils/ChatMessageComponentAsEditBoxUtils';\nimport { RichTextEditorComponentRef } from '../../RichTextEditor/RichTextEditor';\nimport { RichTextInputBoxComponent } from '../../RichTextEditor/RichTextInputBoxComponent';\nimport { editBoxRichTextEditorStyle, richTextActionButtonsStyle } from '../../styles/RichTextEditor.styles';\nimport { RichTextSendBoxErrors } from '../../RichTextEditor/RichTextSendBoxErrors';\nimport { useLocale } from '../../../localization';\nimport { FluentV9ThemeProvider } from '../../../theming/FluentV9ThemeProvider';\nimport { attachmentUploadCardsStyles } from '../../styles/SendBox.styles';\nimport { SendBoxErrorBarError, SendBoxErrorBarType } from '../../SendBoxErrorBar';\nimport { BROKEN_IMAGE_SVG_DATA } from '../../styles/Common.style';\nimport { getPreviousInlineImages } from '../../utils/RichTextEditorUtils';\n\n/** @private */\nexport type ChatMessageComponentAsRichTextEditBoxProps = {\n onCancel?: (messageId: string) => void;\n onSubmit: (text: string, attachmentMetadata?: AttachmentMetadata[]) => void;\n message: ChatMessage;\n strings: MessageThreadStrings;\n onPaste?: (event: {\n content: DocumentFragment;\n }) => void;\n onRemoveInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;\n onInsertInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;\n inlineImagesWithProgress?: AttachmentMetadataInProgress[];\n};\n\n/**\n * @private\n */\nexport const ChatMessageComponentAsRichTextEditBox = (props: ChatMessageComponentAsRichTextEditBoxProps): JSX.Element => {\n const {\n onCancel,\n onSubmit,\n strings,\n message,\n onPaste,\n onInsertInlineImage,\n inlineImagesWithProgress,\n onRemoveInlineImage\n } = props;\n const [initialInlineImages, setInitialInlineImages] = useState<Record<string, string>[]>([]);\n const initialContent = useMemo(() => {\n const content = message.content;\n setInitialInlineImages(getPreviousInlineImages(content));\n const document = new DOMParser().parseFromString(content ?? '', 'text/html');\n // The broken image element is a div element with all the attributes of the original image element.\n // We need to convert it to a img element so the Rooster knows how to render it.\n // And we need to copy over all the attributes such as id, width, etc.\n // which is needed for sending the message with the images correctly.\n document.querySelectorAll('.broken-image-wrapper').forEach(brokenImage => {\n const imageElement = document.createElement('img');\n const attributes = brokenImage.attributes;\n for (const attribute of attributes) {\n imageElement.setAttribute(attribute.name, attribute.value);\n }\n imageElement.src = BROKEN_IMAGE_SVG_DATA;\n imageElement.style.width = '3rem';\n imageElement.style.height = '3rem';\n brokenImage.parentElement?.replaceChild(imageElement, brokenImage);\n });\n return document.body.innerHTML;\n return message.content;\n }, [message]);\n const [contentValue, setContentValue] = useState<string>(initialContent || '');\n const [contentValueWithInlineImagesOverflow, setContentValueWithInlineImagesOverflow] = useState(false);\n const [attachmentMetadata, handleAttachmentAction] = useReducer(attachmentMetadataReducer, getMessageWithAttachmentMetadata(message) ?? []);\n const [attachmentUploadsPendingError, setAttachmentUploadsPendingError] = useState<SendBoxErrorBarError | undefined>(undefined);\n const editTextFieldRef = React.useRef<RichTextEditorComponentRef>(null);\n const theme = useTheme();\n const messageState: MessageState = useMemo(() => {\n // get plain text content from the editor to check if the message is empty\n // as the content may contain tags even when the content is empty\n const plainTextContent = editTextFieldRef.current?.getPlainContent() ?? contentValue;\n let messageLengthState = getMessageState(plainTextContent, attachmentMetadata ?? []);\n const imageIds = inlineImageIds(contentValue);\n if (messageLengthState !== 'OK' && imageIds.length > 0) {\n // Check if too long\n if (isMessageTooLong(contentValue.length)) {\n messageLengthState = 'too long';\n } else {\n messageLengthState = 'OK';\n }\n }\n return messageLengthState;\n }, [attachmentMetadata, contentValue]);\n const imageUploadErrorMessage = useMemo(() => {\n return inlineImagesWithProgress?.filter(image => image.error).pop()?.error?.message;\n }, [inlineImagesWithProgress]);\n const editContainerStyles = useChatMessageRichTextEditContainerStyles();\n const chatMyMessageStyles = useChatMyMessageStyles();\n const locale = useLocale().strings;\n const setContent = useCallback((newValue?: string): void => {\n setContentValue(newValue ?? '');\n }, []);\n useEffect(() => {\n editTextFieldRef.current?.focus();\n }, []);\n const textValidationErrorMessage = useMemo(() => {\n return getTextValidationErrorMessage(messageState, strings.editBoxTextLimit, strings.editBoxEmptyWarningText, contentValueWithInlineImagesOverflow);\n }, [messageState, strings.editBoxTextLimit, strings.editBoxEmptyWarningText, contentValueWithInlineImagesOverflow]);\n const iconClassName = useCallback((isHover: boolean) => {\n const color = isHover ? theme.palette.accent : theme.palette.neutralSecondary;\n return mergeStyles(richTextEditBoxActionButtonIcon, {\n color\n });\n }, [theme.palette.accent, theme.palette.neutralSecondary]);\n const onRenderThemedCancelIcon = useCallback((isHover: boolean) => {\n return onRenderCancelIcon(iconClassName(isHover));\n }, [iconClassName]);\n const onRenderThemedSubmitIcon = useCallback((isHover: boolean) => {\n return onRenderSubmitIcon(iconClassName(isHover));\n }, [iconClassName]);\n const hasMultipleAttachments = useMemo(() => {\n return doesMessageContainMultipleAttachments(message);\n }, [message]);\n const onSubmitHandler = useCallback((): void => {\n if (messageState !== 'OK') {\n return;\n }\n if (inlineImagesWithProgress && inlineImagesWithProgress.length > 0) {\n const contentWithUpdatedInlineImagesInfo = getContentWithUpdatedInlineImagesInfo(contentValue, inlineImagesWithProgress);\n const messageTooLong = isMessageTooLong(contentWithUpdatedInlineImagesInfo.length);\n // Set contentValueWithInlineImagesOverflow state to display the error bar\n setContentValueWithInlineImagesOverflow(messageTooLong);\n // The change from the setContentValueOverflow in the previous line will not kick in yet.\n // We need to rely on the local value of messageTooLong to return early if the message is too long.\n if (messageTooLong) {\n return;\n }\n }\n\n // Don't send message until all attachments have been uploaded successfully\n setAttachmentUploadsPendingError(undefined);\n if (hasIncompleteAttachmentUploads(inlineImagesWithProgress)) {\n setAttachmentUploadsPendingError({\n message: strings.imageUploadsPendingError,\n timestamp: Date.now(),\n errorBarType: SendBoxErrorBarType.info\n });\n return;\n }\n let content = contentValue;\n content = removeBrokenImageContentAndClearImageSizeStyles(content);\n let initInlineImages: Record<string, string>[] = [];\n initInlineImages = initialInlineImages ?? [];\n modifyInlineImagesInContentString(content, initInlineImages, (content: string) => {\n // it's very important to pass an empty attachment here\n // so when user removes all attachments, UI can reflect it instantly\n // if you set it to undefined, the attachments pre-edited would still be there\n // until edit message event is received\n onSubmit(content, attachmentMetadata || []);\n });\n }, [messageState, inlineImagesWithProgress, initialInlineImages, contentValue, strings.imageUploadsPendingError, onSubmit, attachmentMetadata]);\n const actionButtons = useMemo(() => {\n return <Stack horizontal>\n <InputBoxButton className={richTextActionButtonsStyle} ariaLabel={strings.editBoxCancelButton} tooltipContent={strings.editBoxCancelButton} onRenderIcon={onRenderThemedCancelIcon} onClick={() => {\n onCancel && onCancel(message.messageId);\n }} id={'dismissIconWrapper'} data-testId={'chat-message-rich-text-edit-box-cancel-button'} />\n <InputBoxButton className={richTextActionButtonsStyle} ariaLabel={strings.editBoxSubmitButton} tooltipContent={strings.editBoxSubmitButton} onRenderIcon={onRenderThemedSubmitIcon} onClick={e => {\n onSubmitHandler();\n e.stopPropagation();\n }} id={'submitIconWrapper'} data-testId={'chat-message-rich-text-edit-box-submit-button'} />\n </Stack>;\n }, [message.messageId, onCancel, onRenderThemedCancelIcon, onRenderThemedSubmitIcon, strings.editBoxCancelButton, strings.editBoxSubmitButton, onSubmitHandler]);\n const richTextLocaleStrings = useMemo(() => {\n return {\n ...locale.richTextSendBox,\n ...strings\n };\n return locale.sendBox;\n }, [locale.richTextSendBox, strings, locale.sendBox]);\n const onCancelAttachmentUpload = useCallback((attachmentId: string) => {\n // edit box only capable of removing attachments\n // we need to expand attachment actions\n // if we want to support more actions e.g. add\n handleAttachmentAction({\n type: 'remove',\n id: attachmentId\n });\n }, []);\n const onRenderAttachmentUploads = useCallback(() => {\n return <Stack className={attachmentUploadCardsStyles}>\n <FluentV9ThemeProvider v8Theme={theme}>\n <_AttachmentUploadCards attachments={attachmentMetadata} onCancelAttachmentUpload={onCancelAttachmentUpload} />\n </FluentV9ThemeProvider>\n </Stack>;\n }, [attachmentMetadata, onCancelAttachmentUpload, theme]);\n const onChangeHandler = useCallback((content: string | undefined, removedInlineImages?: Record<string, string>[]) => {\n removedInlineImages?.forEach((removedInlineImage: Record<string, string>) => {\n onRemoveInlineImage && onRemoveInlineImage(removedInlineImage, message.messageId);\n });\n setContent(content);\n }, [setContent, onRemoveInlineImage, message.messageId]);\n const getContent = (): JSX.Element => {\n return <Stack className={mergeStyles(editBoxWidthStyles)}>\n <RichTextSendBoxErrors textValidationErrorMessage={textValidationErrorMessage} systemMessage={message.failureReason} attachmentUploadsPendingError={attachmentUploadsPendingError} attachmentProgressError={imageUploadErrorMessage ? {\n message: imageUploadErrorMessage,\n timestamp: Date.now(),\n errorBarType: SendBoxErrorBarType.error\n } : undefined} />\n <RichTextInputBoxComponent placeholderText={strings.editBoxPlaceholderText} onChange={onChangeHandler} onEnterKeyDown={onSubmitHandler} editorComponentRef={editTextFieldRef} initialContent={initialContent} strings={richTextLocaleStrings} disabled={false} actionComponents={actionButtons} richTextEditorStyleProps={editBoxRichTextEditorStyle} isHorizontalLayoutDisabled={true} onRenderAttachmentUploads={onRenderAttachmentUploads} onPaste={onPaste} onInsertInlineImage={onInsertInlineImage ? (imageAttributes: Record<string, string>) => {\n onInsertInlineImage(imageAttributes, message.messageId);\n } : undefined} />\n </Stack>;\n };\n const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';\n return <ChatMyMessage attached={attached} root={{\n className: mergeClasses(chatMyMessageStyles.root, hasMultipleAttachments ? chatMyMessageStyles.multipleAttachmentsInEditing : undefined)\n }} body={{\n className: mergeClasses(editContainerStyles.body, attached !== 'top' ? editContainerStyles.bodyAttached : undefined)\n }}>\n {getContent()}\n </ChatMyMessage>;\n};\nexport default ChatMessageComponentAsRichTextEditBox;"]}
|
@@ -1,14 +1,18 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { MessageThreadStrings, UpdateMessageCallback } from '../../MessageThread';
|
3
3
|
import { ChatMessage, ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';
|
4
|
+
import { BlockedMessage } from '../../../types';
|
4
5
|
import { AttachmentMenuAction } from '../../../types/Attachment';
|
5
6
|
import { AttachmentMetadata } from "../../../../../acs-ui-common/src";
|
7
|
+
import { MessageOptions } from "../../../../../acs-ui-common/src";
|
8
|
+
import { AttachmentMetadataInProgress } from "../../../../../acs-ui-common/src";
|
9
|
+
import { MentionOptions } from '../../MentionPopover';
|
6
10
|
import { InlineImageOptions } from '../ChatMessageContent';
|
7
11
|
/**
|
8
12
|
* Props for the ChatMyMessageComponent component.
|
9
13
|
*/
|
10
14
|
export type ChatMyMessageComponentProps = {
|
11
|
-
message: ChatMessage;
|
15
|
+
message: ChatMessage | BlockedMessage;
|
12
16
|
userId: string;
|
13
17
|
messageContainerStyle?: ComponentSlotStyle;
|
14
18
|
showDate?: boolean;
|
@@ -24,7 +28,7 @@ export type ChatMyMessageComponentProps = {
|
|
24
28
|
* Callback to send a message
|
25
29
|
* @param content The message content to send
|
26
30
|
*/
|
27
|
-
onSendMessage?: (content: string) => Promise<void>;
|
31
|
+
onSendMessage?: (content: string, options?: MessageOptions) => Promise<void>;
|
28
32
|
strings: MessageThreadStrings;
|
29
33
|
messageStatus?: string;
|
30
34
|
/**
|
@@ -50,6 +54,16 @@ export type ChatMyMessageComponentProps = {
|
|
50
54
|
* @param userId - user Id
|
51
55
|
*/
|
52
56
|
onRenderAvatar?: OnRenderAvatarCallback;
|
57
|
+
/**
|
58
|
+
* Optional function to provide customized date format.
|
59
|
+
* @beta
|
60
|
+
*/
|
61
|
+
onDisplayDateTimeString?: (messageDate: Date) => string;
|
62
|
+
/**
|
63
|
+
* Optional props needed to lookup suggestions and display mentions in the mention scenario.
|
64
|
+
* @beta
|
65
|
+
*/
|
66
|
+
mentionOptions?: MentionOptions;
|
53
67
|
/**
|
54
68
|
* Optional callback called when an inline image is clicked.
|
55
69
|
* @beta
|
@@ -65,6 +79,13 @@ export type ChatMyMessageComponentProps = {
|
|
65
79
|
* @beta
|
66
80
|
*/
|
67
81
|
actionsForAttachment?: (attachment: AttachmentMetadata, message?: ChatMessage) => AttachmentMenuAction[];
|
82
|
+
isRichTextEditorEnabled?: boolean;
|
83
|
+
onPaste?: (event: {
|
84
|
+
content: DocumentFragment;
|
85
|
+
}) => void;
|
86
|
+
onRemoveInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;
|
87
|
+
onInsertInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;
|
88
|
+
inlineImagesWithProgress?: AttachmentMetadataInProgress[];
|
68
89
|
};
|
69
90
|
/**
|
70
91
|
* @private
|
@@ -12,10 +12,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
12
12
|
import React, { useCallback, useState } from 'react';
|
13
13
|
import { ChatMyMessageComponentAsMessageBubble } from './ChatMyMessageComponentAsMessageBubble';
|
14
14
|
import { ChatMessageComponentAsEditBoxPicker } from './ChatMessageComponentAsEditBoxPicker';
|
15
|
+
import { removeBrokenImageContentAndClearImageSizeStyles } from '../../utils/SendBoxUtils';
|
15
16
|
/**
|
16
17
|
* @private
|
17
18
|
*/
|
18
19
|
export const ChatMyMessageComponent = (props) => {
|
20
|
+
var _a, _b;
|
19
21
|
const { onDeleteMessage, onSendMessage, message, onCancelEditMessage, onUpdateMessage } = props;
|
20
22
|
const [isEditing, setIsEditing] = useState(false);
|
21
23
|
const [focusMessageAfterEditing, setFocusMessageAfterEditing] = useState(false);
|
@@ -37,14 +39,23 @@ export const ChatMyMessageComponent = (props) => {
|
|
37
39
|
const onResendClick = useCallback(() => {
|
38
40
|
onDeleteMessage && clientMessageId && onDeleteMessage(clientMessageId);
|
39
41
|
let newContent = content !== null && content !== void 0 ? content : '';
|
40
|
-
|
41
|
-
|
42
|
+
newContent = removeBrokenImageContentAndClearImageSizeStyles(newContent);
|
43
|
+
onSendMessage && onSendMessage(newContent, {
|
44
|
+
attachments: `attachments` in message ? message.attachments : undefined,
|
45
|
+
type: props.isRichTextEditorEnabled ? 'html' : 'text'
|
46
|
+
});
|
47
|
+
}, [message, onDeleteMessage, clientMessageId, onSendMessage, content, props.isRichTextEditorEnabled]);
|
42
48
|
const onSubmitHandler = useCallback(
|
43
49
|
// due to a bug in babel, we can't use arrow function here
|
44
50
|
// affecting conditional-compile-remove(attachment-upload)
|
45
|
-
function (text) {
|
51
|
+
function (text, attachments) {
|
46
52
|
return __awaiter(this, void 0, void 0, function* () {
|
47
|
-
|
53
|
+
if (`attachments` in message && attachments) {
|
54
|
+
message.attachments = attachments;
|
55
|
+
}
|
56
|
+
yield (onUpdateMessage === null || onUpdateMessage === void 0 ? void 0 : onUpdateMessage(message.messageId, text, {
|
57
|
+
attachments: attachments
|
58
|
+
}));
|
48
59
|
setIsEditing(false);
|
49
60
|
setFocusMessageAfterEditing(true);
|
50
61
|
});
|
@@ -55,10 +66,10 @@ export const ChatMyMessageComponent = (props) => {
|
|
55
66
|
setFocusMessageAfterEditing(true);
|
56
67
|
}, [onCancelEditMessage]);
|
57
68
|
if (isEditing && message.messageType === 'chat') {
|
58
|
-
return React.createElement(ChatMessageComponentAsEditBoxPicker, { message: message, strings: props.strings, onSubmit: onSubmitHandler, onCancel: onCancelHandler });
|
69
|
+
return React.createElement(ChatMessageComponentAsEditBoxPicker, { message: message, strings: props.strings, onSubmit: onSubmitHandler, onCancel: onCancelHandler, mentionLookupOptions: (_a = props.mentionOptions) === null || _a === void 0 ? void 0 : _a.lookupOptions, isRichTextEditorEnabled: props.isRichTextEditorEnabled, onPaste: props.onPaste, onInsertInlineImage: props.onInsertInlineImage, inlineImagesWithProgress: props.inlineImagesWithProgress, onRemoveInlineImage: props.onRemoveInlineImage });
|
59
70
|
}
|
60
71
|
else {
|
61
|
-
return React.createElement(ChatMyMessageComponentAsMessageBubble, Object.assign({}, props, { onRemoveClick: onRemoveClick, onEditClick: onEditClick, onResendClick: onResendClick, onRenderAvatar: props.onRenderAvatar, strings: props.strings, inlineImageOptions: props.inlineImageOptions, shouldFocusFluentMessageBody: focusMessageAfterEditing }));
|
72
|
+
return React.createElement(ChatMyMessageComponentAsMessageBubble, Object.assign({}, props, { onRemoveClick: onRemoveClick, onEditClick: onEditClick, onResendClick: onResendClick, onRenderAvatar: props.onRenderAvatar, onDisplayDateTimeString: props.onDisplayDateTimeString, strings: props.strings, inlineImageOptions: props.inlineImageOptions, mentionDisplayOptions: (_b = props.mentionOptions) === null || _b === void 0 ? void 0 : _b.displayOptions, shouldFocusFluentMessageBody: focusMessageAfterEditing }));
|
62
73
|
}
|
63
74
|
};
|
64
75
|
//# sourceMappingURL=ChatMyMessageComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatMyMessageComponent.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAGlC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;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EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,wBAAwB,IAAI,CAAC;IACxT,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { _formatString } from '@internal/acs-ui-common';\nimport React, { useCallback, useState } from 'react';\nimport { MessageThreadStrings, UpdateMessageCallback } from '../../MessageThread';\nimport { ChatMessage, ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';\nimport { AttachmentMenuAction } from '../../../types/Attachment';\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\nimport { InlineImageOptions } from '../ChatMessageContent';\nimport { ChatMyMessageComponentAsMessageBubble } from './ChatMyMessageComponentAsMessageBubble';\nimport { ChatMessageComponentAsEditBoxPicker } from './ChatMessageComponentAsEditBoxPicker';\n/**\n * Props for the ChatMyMessageComponent component.\n */\nexport type ChatMyMessageComponentProps = {\n message: ChatMessage;\n userId: string;\n messageContainerStyle?: ComponentSlotStyle;\n showDate?: boolean;\n disableEditing?: boolean;\n onUpdateMessage?: UpdateMessageCallback;\n onCancelEditMessage?: (messageId: string) => void;\n /**\n * Callback to delete a message. Also called before resending a message that failed to send.\n * @param messageId ID of the message to delete\n */\n onDeleteMessage?: (messageId: string) => Promise<void>;\n /**\n * Callback to send a message\n * @param content The message content to send\n */\n onSendMessage?: (content: string) => Promise<void>;\n strings: MessageThreadStrings;\n messageStatus?: string;\n /**\n * Optional text to display when the message status is 'failed'.\n */\n failureReason?: string;\n /**\n * Whether the status indicator for each message is displayed or not.\n */\n showMessageStatus?: boolean;\n /**\n * Whether to overlap avatar and message when the view is width constrained.\n */\n shouldOverlapAvatarAndMessage: boolean;\n remoteParticipantsCount?: number;\n onActionButtonClick: (message: ChatMessage, setMessageReadBy: (readBy: {\n id: string;\n displayName: string;\n }[]) => void) => void;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n /**\n * Optional callback called when an inline image is clicked.\n * @beta\n */\n inlineImageOptions?: InlineImageOptions;\n /**\n * Optional callback to render message attachments in the message component.\n * @beta\n */\n onRenderAttachmentDownloads?: (message: ChatMessage) => JSX.Element;\n /**\n * Optional callback to define custom actions for attachments.\n * @beta\n */\n actionsForAttachment?: (attachment: AttachmentMetadata, message?: ChatMessage) => AttachmentMenuAction[];\n};\n\n/**\n * @private\n */\nexport const ChatMyMessageComponent = (props: ChatMyMessageComponentProps): JSX.Element => {\n const {\n onDeleteMessage,\n onSendMessage,\n message,\n onCancelEditMessage,\n onUpdateMessage\n } = props;\n const [isEditing, setIsEditing] = useState(false);\n const [focusMessageAfterEditing, setFocusMessageAfterEditing] = useState(false);\n const onEditClick = useCallback(() => {\n setIsEditing(true);\n setFocusMessageAfterEditing(false);\n }, []);\n const clientMessageId = 'clientMessageId' in message ? message.clientMessageId : undefined;\n const content = 'content' in message ? message.content : undefined;\n const onRemoveClick = useCallback(() => {\n if (onDeleteMessage && message.messageId) {\n onDeleteMessage(message.messageId);\n }\n // when fail to send, message does not have message id, delete message using clientMessageId\n else if (onDeleteMessage && message.messageType === 'chat' && clientMessageId) {\n onDeleteMessage(clientMessageId);\n }\n }, [onDeleteMessage, message.messageId, message.messageType, clientMessageId]);\n const onResendClick = useCallback(() => {\n onDeleteMessage && clientMessageId && onDeleteMessage(clientMessageId);\n let newContent = content ?? '';\n onSendMessage && onSendMessage(newContent);\n }, [message, onDeleteMessage, clientMessageId, onSendMessage, content]);\n const onSubmitHandler = useCallback(\n // due to a bug in babel, we can't use arrow function here\n // affecting conditional-compile-remove(attachment-upload)\n async function (text: string) {\n await onUpdateMessage?.(message.messageId, text);\n setIsEditing(false);\n setFocusMessageAfterEditing(true);\n }, [message, onUpdateMessage]);\n const onCancelHandler = useCallback((messageId: string) => {\n onCancelEditMessage?.(messageId);\n setIsEditing(false);\n setFocusMessageAfterEditing(true);\n }, [onCancelEditMessage]);\n if (isEditing && message.messageType === 'chat') {\n return <ChatMessageComponentAsEditBoxPicker message={message} strings={props.strings} onSubmit={onSubmitHandler} onCancel={onCancelHandler} />;\n } else {\n return <ChatMyMessageComponentAsMessageBubble {...props} onRemoveClick={onRemoveClick} onEditClick={onEditClick} onResendClick={onResendClick} onRenderAvatar={props.onRenderAvatar} strings={props.strings} inlineImageOptions={props.inlineImageOptions} shouldFocusFluentMessageBody={focusMessageAfterEditing} />;\n }\n};"]}
|
1
|
+
{"version":3,"file":"ChatMyMessageComponent.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAGlC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUrD,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,+CAA+C,EAAE,MAAM,0BAA0B,CAAC;AAkF3F;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAkC,EAAe,EAAE;;IACxF,MAAM,EACJ,eAAe,EACf,aAAa,EACb,OAAO,EACP,mBAAmB,EACnB,eAAe,EAChB,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,2BAA2B,CAAC,KAAK,CAA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K,CAAC,mBAAmB,GAAI,CAAC;IACtb,CAAC;SAAM,CAAC;QACN,OAAO,oBAAC,qCAAqC,oBAAK,KAAK,IAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,uBAAuB,EAAE,KAAK,CAAC,uBAAuB,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,MAAA,KAAK,CAAC,cAAc,0CAAE,cAAc,EAAE,4BAA4B,EAAE,wBAAwB,IAAI,CAAC;IAC7a,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { _formatString } from '@internal/acs-ui-common';\nimport React, { useCallback, useState } from 'react';\nimport { MessageThreadStrings, UpdateMessageCallback } from '../../MessageThread';\nimport { ChatMessage, ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';\nimport { BlockedMessage } from '../../../types';\nimport { AttachmentMenuAction } from '../../../types/Attachment';\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\nimport { MessageOptions } from '@internal/acs-ui-common';\nimport { AttachmentMetadataInProgress } from '@internal/acs-ui-common';\nimport { MentionOptions } from '../../MentionPopover';\nimport { InlineImageOptions } from '../ChatMessageContent';\nimport { ChatMyMessageComponentAsMessageBubble } from './ChatMyMessageComponentAsMessageBubble';\nimport { ChatMessageComponentAsEditBoxPicker } from './ChatMessageComponentAsEditBoxPicker';\nimport { removeBrokenImageContentAndClearImageSizeStyles } from '../../utils/SendBoxUtils';\n\n/**\n * Props for the ChatMyMessageComponent component.\n */\nexport type ChatMyMessageComponentProps = {\n message: ChatMessage | BlockedMessage;\n userId: string;\n messageContainerStyle?: ComponentSlotStyle;\n showDate?: boolean;\n disableEditing?: boolean;\n onUpdateMessage?: UpdateMessageCallback;\n onCancelEditMessage?: (messageId: string) => void;\n /**\n * Callback to delete a message. Also called before resending a message that failed to send.\n * @param messageId ID of the message to delete\n */\n onDeleteMessage?: (messageId: string) => Promise<void>;\n /**\n * Callback to send a message\n * @param content The message content to send\n */\n onSendMessage?: (content: string, options?: MessageOptions) => Promise<void>;\n strings: MessageThreadStrings;\n messageStatus?: string;\n /**\n * Optional text to display when the message status is 'failed'.\n */\n failureReason?: string;\n /**\n * Whether the status indicator for each message is displayed or not.\n */\n showMessageStatus?: boolean;\n /**\n * Whether to overlap avatar and message when the view is width constrained.\n */\n shouldOverlapAvatarAndMessage: boolean;\n remoteParticipantsCount?: number;\n onActionButtonClick: (message: ChatMessage, setMessageReadBy: (readBy: {\n id: string;\n displayName: string;\n }[]) => void) => void;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n /**\n * Optional function to provide customized date format.\n * @beta\n */\n onDisplayDateTimeString?: (messageDate: Date) => string;\n /**\n * Optional props needed to lookup suggestions and display mentions in the mention scenario.\n * @beta\n */\n mentionOptions?: MentionOptions;\n /**\n * Optional callback called when an inline image is clicked.\n * @beta\n */\n inlineImageOptions?: InlineImageOptions;\n /**\n * Optional callback to render message attachments in the message component.\n * @beta\n */\n onRenderAttachmentDownloads?: (message: ChatMessage) => JSX.Element;\n /**\n * Optional callback to define custom actions for attachments.\n * @beta\n */\n actionsForAttachment?: (attachment: AttachmentMetadata, message?: ChatMessage) => AttachmentMenuAction[];\n isRichTextEditorEnabled?: boolean;\n onPaste?: (event: {\n content: DocumentFragment;\n }) => void;\n onRemoveInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;\n onInsertInlineImage?: (imageAttributes: Record<string, string>, messageId: string) => void;\n inlineImagesWithProgress?: AttachmentMetadataInProgress[];\n};\n\n/**\n * @private\n */\nexport const ChatMyMessageComponent = (props: ChatMyMessageComponentProps): JSX.Element => {\n const {\n onDeleteMessage,\n onSendMessage,\n message,\n onCancelEditMessage,\n onUpdateMessage\n } = props;\n const [isEditing, setIsEditing] = useState(false);\n const [focusMessageAfterEditing, setFocusMessageAfterEditing] = useState(false);\n const onEditClick = useCallback(() => {\n setIsEditing(true);\n setFocusMessageAfterEditing(false);\n }, []);\n const clientMessageId = 'clientMessageId' in message ? message.clientMessageId : undefined;\n const content = 'content' in message ? message.content : undefined;\n const onRemoveClick = useCallback(() => {\n if (onDeleteMessage && message.messageId) {\n onDeleteMessage(message.messageId);\n }\n // when fail to send, message does not have message id, delete message using clientMessageId\n else if (onDeleteMessage && message.messageType === 'chat' && clientMessageId) {\n onDeleteMessage(clientMessageId);\n }\n }, [onDeleteMessage, message.messageId, message.messageType, clientMessageId]);\n const onResendClick = useCallback(() => {\n onDeleteMessage && clientMessageId && onDeleteMessage(clientMessageId);\n let newContent = content ?? '';\n newContent = removeBrokenImageContentAndClearImageSizeStyles(newContent);\n onSendMessage && onSendMessage(newContent, {\n attachments: `attachments` in message ? message.attachments : undefined,\n type: props.isRichTextEditorEnabled ? 'html' : 'text'\n });\n }, [message, onDeleteMessage, clientMessageId, onSendMessage, content, props.isRichTextEditorEnabled]);\n const onSubmitHandler = useCallback(\n // due to a bug in babel, we can't use arrow function here\n // affecting conditional-compile-remove(attachment-upload)\n async function (text: string, attachments?: AttachmentMetadata[] | undefined) {\n if (`attachments` in message && attachments) {\n message.attachments = attachments;\n }\n await onUpdateMessage?.(message.messageId, text, {\n attachments: attachments\n });\n setIsEditing(false);\n setFocusMessageAfterEditing(true);\n }, [message, onUpdateMessage]);\n const onCancelHandler = useCallback((messageId: string) => {\n onCancelEditMessage?.(messageId);\n setIsEditing(false);\n setFocusMessageAfterEditing(true);\n }, [onCancelEditMessage]);\n if (isEditing && message.messageType === 'chat') {\n return <ChatMessageComponentAsEditBoxPicker message={message} strings={props.strings} onSubmit={onSubmitHandler} onCancel={onCancelHandler} mentionLookupOptions={props.mentionOptions?.lookupOptions} isRichTextEditorEnabled={props.isRichTextEditorEnabled} onPaste={props.onPaste} onInsertInlineImage={props.onInsertInlineImage} inlineImagesWithProgress={props.inlineImagesWithProgress} onRemoveInlineImage={props.onRemoveInlineImage} />;\n } else {\n return <ChatMyMessageComponentAsMessageBubble {...props} onRemoveClick={onRemoveClick} onEditClick={onEditClick} onResendClick={onResendClick} onRenderAvatar={props.onRenderAvatar} onDisplayDateTimeString={props.onDisplayDateTimeString} strings={props.strings} inlineImageOptions={props.inlineImageOptions} mentionDisplayOptions={props.mentionOptions?.displayOptions} shouldFocusFluentMessageBody={focusMessageAfterEditing} />;\n }\n};"]}
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InlineImageOptions } from '../ChatMessageContent';
|
3
3
|
import { ChatMessage } from '../../../types/ChatMessage';
|
4
|
+
import { BlockedMessage } from '../../../types/ChatMessage';
|
4
5
|
import { MessageThreadStrings } from '../../MessageThread';
|
5
6
|
import { ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';
|
6
7
|
import { AttachmentMenuAction } from '../../../types/Attachment';
|
7
8
|
import { AttachmentMetadata } from "../../../../../acs-ui-common/src";
|
9
|
+
import { MentionDisplayOptions } from '../../MentionPopover';
|
8
10
|
type ChatMyMessageComponentAsMessageBubbleProps = {
|
9
|
-
message: ChatMessage;
|
11
|
+
message: ChatMessage | BlockedMessage;
|
10
12
|
messageContainerStyle?: ComponentSlotStyle;
|
11
13
|
showDate?: boolean;
|
12
14
|
disableEditing?: boolean;
|
@@ -37,6 +39,11 @@ type ChatMyMessageComponentAsMessageBubbleProps = {
|
|
37
39
|
* @beta
|
38
40
|
*/
|
39
41
|
onDisplayDateTimeString?: (messageDate: Date) => string;
|
42
|
+
/**
|
43
|
+
* Optional props needed to display suggestions in the mention scenario.
|
44
|
+
* @internal
|
45
|
+
*/
|
46
|
+
mentionDisplayOptions?: MentionDisplayOptions;
|
40
47
|
/**
|
41
48
|
* Optional callback called when an inline image is clicked.
|
42
49
|
* @beta
|
@@ -13,13 +13,14 @@ import { createStyleFromV8Style } from '../../styles/v8StyleShim';
|
|
13
13
|
import { mergeClasses } from '@fluentui/react-components';
|
14
14
|
import { useChatMyMessageStyles, useChatMessageCommonStyles, chatMyMessageActionMenuClassName } from '../../styles/MessageThread.styles';
|
15
15
|
import { generateCustomizedTimestamp, generateDefaultTimestamp, getMessageBubbleContent, getMessageEditedDetails } from '../../utils/ChatMessageComponentUtils';
|
16
|
+
import { doesMessageContainMultipleAttachments } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
16
17
|
/** @private */
|
17
18
|
const MessageBubble = (props) => {
|
18
19
|
var _a;
|
19
20
|
const ids = useIdentifiers();
|
20
21
|
const theme = useTheme();
|
21
22
|
const locale = useLocale();
|
22
|
-
const { userId, message, onRemoveClick, onResendClick, disableEditing, showDate, messageContainerStyle, strings, onEditClick, remoteParticipantsCount = 0, onRenderAvatar, showMessageStatus, messageStatus, inlineImageOptions, onDisplayDateTimeString, onRenderAttachmentDownloads, actionsForAttachment, shouldFocusFluentMessageBody } = props;
|
23
|
+
const { userId, message, onRemoveClick, onResendClick, disableEditing, showDate, messageContainerStyle, strings, onEditClick, remoteParticipantsCount = 0, onRenderAvatar, showMessageStatus, messageStatus, inlineImageOptions, mentionDisplayOptions, onDisplayDateTimeString, onRenderAttachmentDownloads, actionsForAttachment, shouldFocusFluentMessageBody } = props;
|
23
24
|
const formattedTimestamp = useMemo(() => {
|
24
25
|
const defaultTimeStamp = message.createdOn ? generateDefaultTimestamp(message.createdOn, showDate, strings) : undefined;
|
25
26
|
const customTimestamp = message.createdOn ? generateCustomizedTimestamp(message.createdOn, locale, onDisplayDateTimeString) : '';
|
@@ -35,7 +36,7 @@ const MessageBubble = (props) => {
|
|
35
36
|
const messageRef = useRef(null);
|
36
37
|
const messageActionButtonRef = useRef(null);
|
37
38
|
const [chatMessageActionFlyoutTarget, setChatMessageActionFlyoutTarget] = useState(undefined);
|
38
|
-
const chatActionsEnabled = !disableEditing && message.status !== 'sending' && !!message.mine;
|
39
|
+
const chatActionsEnabled = !disableEditing && message.status !== 'sending' && !!message.mine && message.messageType !== 'blocked';
|
39
40
|
const [messageReadBy, setMessageReadBy] = useState([]);
|
40
41
|
const actionMenuProps = chatMessageActionMenuProps({
|
41
42
|
ariaLabel: (_a = strings.actionMenuMoreOptions) !== null && _a !== void 0 ? _a : '',
|
@@ -64,6 +65,9 @@ const MessageBubble = (props) => {
|
|
64
65
|
// or not we need to set the target to undefined here to actually hide the action flyout
|
65
66
|
setChatMessageActionFlyoutTarget(undefined);
|
66
67
|
}, [setChatMessageActionFlyoutTarget]);
|
68
|
+
const hasMultipleAttachments = useMemo(() => {
|
69
|
+
return doesMessageContainMultipleAttachments(message);
|
70
|
+
}, [message]);
|
67
71
|
const getMessageDetails = useCallback(() => {
|
68
72
|
if (messageStatus === 'failed') {
|
69
73
|
return React.createElement("div", { className: chatMessageFailedTagStyle(theme) }, strings.failToSendTag);
|
@@ -74,7 +78,7 @@ const MessageBubble = (props) => {
|
|
74
78
|
}, [message, messageStatus, strings.editedTag, strings.failToSendTag, theme]);
|
75
79
|
const isBlockedMessage =
|
76
80
|
// eslint-disable-next-line no-constant-binary-expression
|
77
|
-
false;
|
81
|
+
false || message.messageType === 'blocked';
|
78
82
|
const chatMyMessageStyles = useChatMyMessageStyles();
|
79
83
|
const chatMessageCommonStyles = useChatMessageCommonStyles();
|
80
84
|
const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';
|
@@ -87,14 +91,14 @@ const MessageBubble = (props) => {
|
|
87
91
|
}, [actionMenuProps === null || actionMenuProps === void 0 ? void 0 : actionMenuProps.children, chatMessageActionFlyoutTarget, chatMyMessageStyles.menu, chatMyMessageStyles.menuHidden, chatMyMessageStyles.menuVisible, focused]);
|
88
92
|
const getContent = useCallback(() => {
|
89
93
|
return React.createElement("div", null,
|
90
|
-
getMessageBubbleContent(message, strings, userId, inlineImageOptions, onRenderAttachmentDownloads, actionsForAttachment),
|
94
|
+
getMessageBubbleContent(message, strings, userId, inlineImageOptions, mentionDisplayOptions, onRenderAttachmentDownloads, actionsForAttachment),
|
91
95
|
getActionsMenu());
|
92
|
-
}, [actionsForAttachment, getActionsMenu, inlineImageOptions, message, onRenderAttachmentDownloads, strings, userId]);
|
96
|
+
}, [actionsForAttachment, getActionsMenu, inlineImageOptions, mentionDisplayOptions, message, onRenderAttachmentDownloads, strings, userId]);
|
93
97
|
const chatMessage = React.createElement(React.Fragment, null,
|
94
98
|
React.createElement("div", { key: props.message.messageId },
|
95
99
|
React.createElement(ChatMyMessage, { attached: attached, key: props.message.messageId, body: {
|
96
100
|
// messageContainerStyle used in className and style prop as style prop can't handle CSS selectors
|
97
|
-
className: mergeClasses(chatMessageCommonStyles.body, chatMyMessageStyles.body, isBlockedMessage ? chatMessageCommonStyles.blocked : props.message.status === 'failed' ? chatMessageCommonStyles.failed : undefined, attached !== 'top' ? chatMyMessageStyles.bodyAttached : undefined, mergeStyles(messageContainerStyle)),
|
101
|
+
className: mergeClasses(chatMessageCommonStyles.body, chatMyMessageStyles.body, chatMessageCommonStyles.bodyWithPlaceholderImage, chatMyMessageStyles.bodyWithPlaceholderImage, isBlockedMessage ? chatMessageCommonStyles.blocked : props.message.status === 'failed' ? chatMessageCommonStyles.failed : undefined, attached !== 'top' ? chatMyMessageStyles.bodyAttached : undefined, hasMultipleAttachments ? chatMyMessageStyles.multipleAttachmentsInViewing : undefined, mergeStyles(messageContainerStyle)),
|
98
102
|
style: Object.assign({}, createStyleFromV8Style(messageContainerStyle)),
|
99
103
|
ref: messageRef
|
100
104
|
}, root: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatMyMessageComponentAsMessageBubble.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa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B,EAAE,uBAAuB,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,GAAI,CACzf,CAAC;IACN,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe;AACf,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Text, mergeStyles } from '@fluentui/react';\nimport { ChatMyMessage } from '@fluentui-contrib/react-chat';\nimport { _formatString } from '@internal/acs-ui-common';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { chatMessageDateStyle, chatMessageFailedTagStyle, chatMessageDateFailedStyle } from '../../styles/ChatMessageComponent.styles';\nimport { useIdentifiers } from '../../../identifiers/IdentifierProvider';\nimport { useTheme } from '../../../theming';\nimport { ChatMessageActionFlyout } from '../ChatMessageActionsFlyout';\nimport { InlineImageOptions } from '../ChatMessageContent';\nimport { ChatMessage } from '../../../types/ChatMessage';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { chatMessageActionMenuProps } from '../ChatMessageActionMenu';\nimport { ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';\nimport { AttachmentMenuAction } from '../../../types/Attachment';\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\nimport { _AttachmentDownloadCards } from '../../Attachment/AttachmentDownloadCards';\nimport { useLocale } from '../../../localization';\nimport { createStyleFromV8Style } from '../../styles/v8StyleShim';\nimport { mergeClasses } from '@fluentui/react-components';\nimport { useChatMyMessageStyles, useChatMessageCommonStyles, chatMyMessageActionMenuClassName } from '../../styles/MessageThread.styles';\nimport { generateCustomizedTimestamp, generateDefaultTimestamp, getMessageBubbleContent, getMessageEditedDetails } from '../../utils/ChatMessageComponentUtils';\ntype ChatMyMessageComponentAsMessageBubbleProps = {\n message: ChatMessage;\n messageContainerStyle?: ComponentSlotStyle;\n showDate?: boolean;\n disableEditing?: boolean;\n onEditClick: () => void;\n onRemoveClick?: () => void;\n onResendClick?: () => void;\n strings: MessageThreadStrings;\n userId: string;\n messageStatus?: string;\n /**\n * Whether the status indicator for each message is displayed or not.\n */\n showMessageStatus?: boolean;\n // Focus on the message body after the message is edited\n shouldFocusFluentMessageBody: boolean;\n remoteParticipantsCount?: number;\n onActionButtonClick: (message: ChatMessage, setMessageReadBy: (readBy: {\n id: string;\n displayName: string;\n }[]) => void) => void;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n\n /**\n * Optional function to provide customized date format.\n * @beta\n */\n onDisplayDateTimeString?: (messageDate: Date) => string;\n /**\n * Optional callback called when an inline image is clicked.\n * @beta\n */\n inlineImageOptions?: InlineImageOptions;\n /**\n * Optional callback to render message attachments in the message component.\n */\n onRenderAttachmentDownloads?: (message: ChatMessage) => JSX.Element;\n /**\n * Optional callback to define custom actions for attachments.\n */\n actionsForAttachment?: (attachment: AttachmentMetadata, message?: ChatMessage) => AttachmentMenuAction[];\n};\n\n/** @private */\nconst MessageBubble = (props: ChatMyMessageComponentAsMessageBubbleProps): JSX.Element => {\n const ids = useIdentifiers();\n const theme = useTheme();\n const locale = useLocale();\n const {\n userId,\n message,\n onRemoveClick,\n onResendClick,\n disableEditing,\n showDate,\n messageContainerStyle,\n strings,\n onEditClick,\n remoteParticipantsCount = 0,\n onRenderAvatar,\n showMessageStatus,\n messageStatus,\n inlineImageOptions,\n onDisplayDateTimeString,\n onRenderAttachmentDownloads,\n actionsForAttachment,\n shouldFocusFluentMessageBody\n } = props;\n const formattedTimestamp = useMemo(() => {\n const defaultTimeStamp = message.createdOn ? generateDefaultTimestamp(message.createdOn, showDate, strings) : undefined;\n const customTimestamp = message.createdOn ? generateCustomizedTimestamp(message.createdOn, locale, onDisplayDateTimeString) : '';\n return customTimestamp || defaultTimeStamp;\n }, [locale, message.createdOn, onDisplayDateTimeString, showDate, strings]);\n\n // Track if the action menu was opened by touch - if so we increase the touch targets for the items\n const [wasInteractionByTouch, setWasInteractionByTouch] = useState(false);\n // `focused` state is used for show/hide actionMenu\n const [focused, setFocused] = React.useState<boolean>(false);\n\n // The chat message action flyout should target the Chat.Message action menu if clicked,\n // or target the chat message if opened via touch press.\n // Undefined indicates the flyout menu should not be being shown.\n const messageRef = useRef<HTMLDivElement | null>(null);\n const messageActionButtonRef = useRef<HTMLDivElement | null>(null);\n const [chatMessageActionFlyoutTarget, setChatMessageActionFlyoutTarget] = useState<React.MutableRefObject<HTMLElement | null> | undefined>(undefined);\n const chatActionsEnabled = !disableEditing && message.status !== 'sending' && !!message.mine;\n const [messageReadBy, setMessageReadBy] = useState<{\n id: string;\n displayName: string;\n }[]>([]);\n const actionMenuProps = chatMessageActionMenuProps({\n ariaLabel: strings.actionMenuMoreOptions ?? '',\n enabled: chatActionsEnabled,\n menuButtonRef: messageActionButtonRef,\n menuExpanded: chatMessageActionFlyoutTarget === messageActionButtonRef,\n onActionButtonClick: () => {\n if (message.messageType === 'chat') {\n props.onActionButtonClick(message, setMessageReadBy);\n setChatMessageActionFlyoutTarget(messageActionButtonRef);\n }\n },\n theme\n });\n useEffect(() => {\n if (shouldFocusFluentMessageBody) {\n // set focus in the next render cycle to avoid focus being stolen by other components\n setTimeout(() => {\n messageRef.current?.focus();\n });\n }\n }, [shouldFocusFluentMessageBody]);\n const onActionFlyoutDismiss = useCallback((): void => {\n // When the flyout dismiss is called, since we control if the action flyout is visible\n // or not we need to set the target to undefined here to actually hide the action flyout\n setChatMessageActionFlyoutTarget(undefined);\n }, [setChatMessageActionFlyoutTarget]);\n const getMessageDetails = useCallback(() => {\n if (messageStatus === 'failed') {\n return <div className={chatMessageFailedTagStyle(theme)}>{strings.failToSendTag}</div>;\n } else {\n return getMessageEditedDetails(message, theme, strings.editedTag);\n }\n }, [message, messageStatus, strings.editedTag, strings.failToSendTag, theme]);\n const isBlockedMessage =\n // eslint-disable-next-line no-constant-binary-expression\n false;\n const chatMyMessageStyles = useChatMyMessageStyles();\n const chatMessageCommonStyles = useChatMessageCommonStyles();\n const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';\n const getActionsMenu = useCallback(() => {\n return <div className={mergeClasses(\n // add the static class name to use it in useChatMyMessageStyles\n chatMyMessageActionMenuClassName, chatMyMessageStyles.menu,\n // Make actions menu visible when the message is focused or the flyout is shown\n focused || chatMessageActionFlyoutTarget?.current ? chatMyMessageStyles.menuVisible : chatMyMessageStyles.menuHidden)}>\n {actionMenuProps?.children}\n </div>;\n }, [actionMenuProps?.children, chatMessageActionFlyoutTarget, chatMyMessageStyles.menu, chatMyMessageStyles.menuHidden, chatMyMessageStyles.menuVisible, focused]);\n const getContent = useCallback(() => {\n return <div>\n {getMessageBubbleContent(message, strings, userId, inlineImageOptions, onRenderAttachmentDownloads, actionsForAttachment)}\n {getActionsMenu()}\n </div>;\n }, [actionsForAttachment, getActionsMenu, inlineImageOptions, message, onRenderAttachmentDownloads, strings, userId]);\n const chatMessage = <>\n <div key={props.message.messageId}>\n <ChatMyMessage attached={attached} key={props.message.messageId} body={{\n // messageContainerStyle used in className and style prop as style prop can't handle CSS selectors\n className: mergeClasses(chatMessageCommonStyles.body, chatMyMessageStyles.body, isBlockedMessage ? chatMessageCommonStyles.blocked : props.message.status === 'failed' ? chatMessageCommonStyles.failed : undefined, attached !== 'top' ? chatMyMessageStyles.bodyAttached : undefined, mergeStyles(messageContainerStyle)),\n style: {\n ...createStyleFromV8Style(messageContainerStyle)\n },\n ref: messageRef\n }} root={{\n className: chatMyMessageStyles.root,\n onBlur: e => {\n // `focused` controls is focused the whole `ChatMessage` or any of its children. When we're navigating\n // with keyboard the focused element will be changed and there is no way to use `:focus` selector\n if (chatMessageActionFlyoutTarget?.current) {\n // doesn't dismiss action button if flyout is open, otherwise, narrator's focus will stay on the closed action menu\n return;\n }\n const shouldPreserveFocusState = e.currentTarget.contains(e.relatedTarget);\n setFocused(shouldPreserveFocusState);\n },\n onFocus: () => {\n // react onFocus is called even when nested component receives focus (i.e. it bubbles)\n // so when focus moves within actionMenu, the `focus` state in chatMessage remains true, and keeps actionMenu visible\n setFocused(true);\n }\n }} data-testid=\"chat-composite-message\" author={<Text className={chatMessageDateStyle(theme)}>{message.senderDisplayName}</Text>} timestamp={<Text className={props.message.status === 'failed' ? chatMessageDateFailedStyle(theme) : chatMessageDateStyle(theme)} data-testid={ids.messageTimestamp}>\n {formattedTimestamp}\n </Text>} details={getMessageDetails()} onTouchStart={() => setWasInteractionByTouch(true)} onPointerDown={() => setWasInteractionByTouch(false)} onKeyDown={() => setWasInteractionByTouch(false)} onClick={() => {\n if (!wasInteractionByTouch) {\n return;\n }\n // If the message was touched via touch we immediately open the menu\n // flyout (when using mouse the 3-dot menu that appears on hover\n // must be clicked to open the flyout).\n // In doing so here we set the target of the flyout to be the message and\n // not the 3-dot menu button to position the flyout correctly.\n setChatMessageActionFlyoutTarget(messageRef);\n if (message.messageType === 'chat') {\n props.onActionButtonClick(message, setMessageReadBy);\n }\n }}>\n {getContent()}\n </ChatMyMessage>\n </div>\n {chatActionsEnabled && <ChatMessageActionFlyout hidden={!chatMessageActionFlyoutTarget} target={chatMessageActionFlyoutTarget} increaseFlyoutItemSize={wasInteractionByTouch} onDismiss={onActionFlyoutDismiss} onEditClick={onEditClick} onRemoveClick={onRemoveClick} onResendClick={onResendClick} strings={strings} messageReadBy={messageReadBy} messageStatus={messageStatus ?? 'failed'} remoteParticipantsCount={remoteParticipantsCount} onRenderAvatar={onRenderAvatar} showMessageStatus={showMessageStatus} />}\n </>;\n return chatMessage;\n};\n\n/** @private */\nexport const ChatMyMessageComponentAsMessageBubble = React.memo(MessageBubble);"]}
|
1
|
+
{"version":3,"file":"ChatMyMessageComponentAsMessageBubble.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,E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,CAAC;oBAC7C,IAAI,OAAO,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;wBACnC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;oBACvD,CAAC;gBACH,CAAC,IACI,UAAU,EAAE,CACC,CACZ;QACL,kBAAkB,IAAI,oBAAC,uBAAuB,IAAC,MAAM,EAAE,CAAC,6BAA6B,EAAE,MAAM,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,SAAS,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,QAAQ,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,GAAI,CACzf,CAAC;IACN,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe;AACf,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Text, mergeStyles } from '@fluentui/react';\nimport { ChatMyMessage } from '@fluentui-contrib/react-chat';\nimport { _formatString } from '@internal/acs-ui-common';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { chatMessageDateStyle, chatMessageFailedTagStyle, chatMessageDateFailedStyle } from '../../styles/ChatMessageComponent.styles';\nimport { useIdentifiers } from '../../../identifiers/IdentifierProvider';\nimport { useTheme } from '../../../theming';\nimport { ChatMessageActionFlyout } from '../ChatMessageActionsFlyout';\nimport { InlineImageOptions } from '../ChatMessageContent';\nimport { ChatMessage } from '../../../types/ChatMessage';\nimport { BlockedMessage } from '../../../types/ChatMessage';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { chatMessageActionMenuProps } from '../ChatMessageActionMenu';\nimport { ComponentSlotStyle, OnRenderAvatarCallback } from '../../../types';\nimport { AttachmentMenuAction } from '../../../types/Attachment';\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\nimport { _AttachmentDownloadCards } from '../../Attachment/AttachmentDownloadCards';\nimport { useLocale } from '../../../localization';\nimport { MentionDisplayOptions } from '../../MentionPopover';\nimport { createStyleFromV8Style } from '../../styles/v8StyleShim';\nimport { mergeClasses } from '@fluentui/react-components';\nimport { useChatMyMessageStyles, useChatMessageCommonStyles, chatMyMessageActionMenuClassName } from '../../styles/MessageThread.styles';\nimport { generateCustomizedTimestamp, generateDefaultTimestamp, getMessageBubbleContent, getMessageEditedDetails } from '../../utils/ChatMessageComponentUtils';\nimport { doesMessageContainMultipleAttachments } from '../../utils/ChatMessageComponentAsEditBoxUtils';\ntype ChatMyMessageComponentAsMessageBubbleProps = {\n message: ChatMessage | BlockedMessage;\n messageContainerStyle?: ComponentSlotStyle;\n showDate?: boolean;\n disableEditing?: boolean;\n onEditClick: () => void;\n onRemoveClick?: () => void;\n onResendClick?: () => void;\n strings: MessageThreadStrings;\n userId: string;\n messageStatus?: string;\n /**\n * Whether the status indicator for each message is displayed or not.\n */\n showMessageStatus?: boolean;\n // Focus on the message body after the message is edited\n shouldFocusFluentMessageBody: boolean;\n remoteParticipantsCount?: number;\n onActionButtonClick: (message: ChatMessage, setMessageReadBy: (readBy: {\n id: string;\n displayName: string;\n }[]) => void) => void;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n\n /**\n * Optional function to provide customized date format.\n * @beta\n */\n onDisplayDateTimeString?: (messageDate: Date) => string;\n /**\n * Optional props needed to display suggestions in the mention scenario.\n * @internal\n */\n mentionDisplayOptions?: MentionDisplayOptions;\n /**\n * Optional callback called when an inline image is clicked.\n * @beta\n */\n inlineImageOptions?: InlineImageOptions;\n /**\n * Optional callback to render message attachments in the message component.\n */\n onRenderAttachmentDownloads?: (message: ChatMessage) => JSX.Element;\n /**\n * Optional callback to define custom actions for attachments.\n */\n actionsForAttachment?: (attachment: AttachmentMetadata, message?: ChatMessage) => AttachmentMenuAction[];\n};\n\n/** @private */\nconst MessageBubble = (props: ChatMyMessageComponentAsMessageBubbleProps): JSX.Element => {\n const ids = useIdentifiers();\n const theme = useTheme();\n const locale = useLocale();\n const {\n userId,\n message,\n onRemoveClick,\n onResendClick,\n disableEditing,\n showDate,\n messageContainerStyle,\n strings,\n onEditClick,\n remoteParticipantsCount = 0,\n onRenderAvatar,\n showMessageStatus,\n messageStatus,\n inlineImageOptions,\n mentionDisplayOptions,\n onDisplayDateTimeString,\n onRenderAttachmentDownloads,\n actionsForAttachment,\n shouldFocusFluentMessageBody\n } = props;\n const formattedTimestamp = useMemo(() => {\n const defaultTimeStamp = message.createdOn ? generateDefaultTimestamp(message.createdOn, showDate, strings) : undefined;\n const customTimestamp = message.createdOn ? generateCustomizedTimestamp(message.createdOn, locale, onDisplayDateTimeString) : '';\n return customTimestamp || defaultTimeStamp;\n }, [locale, message.createdOn, onDisplayDateTimeString, showDate, strings]);\n\n // Track if the action menu was opened by touch - if so we increase the touch targets for the items\n const [wasInteractionByTouch, setWasInteractionByTouch] = useState(false);\n // `focused` state is used for show/hide actionMenu\n const [focused, setFocused] = React.useState<boolean>(false);\n\n // The chat message action flyout should target the Chat.Message action menu if clicked,\n // or target the chat message if opened via touch press.\n // Undefined indicates the flyout menu should not be being shown.\n const messageRef = useRef<HTMLDivElement | null>(null);\n const messageActionButtonRef = useRef<HTMLDivElement | null>(null);\n const [chatMessageActionFlyoutTarget, setChatMessageActionFlyoutTarget] = useState<React.MutableRefObject<HTMLElement | null> | undefined>(undefined);\n const chatActionsEnabled = !disableEditing && message.status !== 'sending' && !!message.mine && message.messageType !== 'blocked';\n const [messageReadBy, setMessageReadBy] = useState<{\n id: string;\n displayName: string;\n }[]>([]);\n const actionMenuProps = chatMessageActionMenuProps({\n ariaLabel: strings.actionMenuMoreOptions ?? '',\n enabled: chatActionsEnabled,\n menuButtonRef: messageActionButtonRef,\n menuExpanded: chatMessageActionFlyoutTarget === messageActionButtonRef,\n onActionButtonClick: () => {\n if (message.messageType === 'chat') {\n props.onActionButtonClick(message, setMessageReadBy);\n setChatMessageActionFlyoutTarget(messageActionButtonRef);\n }\n },\n theme\n });\n useEffect(() => {\n if (shouldFocusFluentMessageBody) {\n // set focus in the next render cycle to avoid focus being stolen by other components\n setTimeout(() => {\n messageRef.current?.focus();\n });\n }\n }, [shouldFocusFluentMessageBody]);\n const onActionFlyoutDismiss = useCallback((): void => {\n // When the flyout dismiss is called, since we control if the action flyout is visible\n // or not we need to set the target to undefined here to actually hide the action flyout\n setChatMessageActionFlyoutTarget(undefined);\n }, [setChatMessageActionFlyoutTarget]);\n const hasMultipleAttachments = useMemo(() => {\n return doesMessageContainMultipleAttachments(message as ChatMessage);\n }, [message]);\n const getMessageDetails = useCallback(() => {\n if (messageStatus === 'failed') {\n return <div className={chatMessageFailedTagStyle(theme)}>{strings.failToSendTag}</div>;\n } else {\n return getMessageEditedDetails(message, theme, strings.editedTag);\n }\n }, [message, messageStatus, strings.editedTag, strings.failToSendTag, theme]);\n const isBlockedMessage =\n // eslint-disable-next-line no-constant-binary-expression\n false || message.messageType === 'blocked';\n const chatMyMessageStyles = useChatMyMessageStyles();\n const chatMessageCommonStyles = useChatMessageCommonStyles();\n const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';\n const getActionsMenu = useCallback(() => {\n return <div className={mergeClasses(\n // add the static class name to use it in useChatMyMessageStyles\n chatMyMessageActionMenuClassName, chatMyMessageStyles.menu,\n // Make actions menu visible when the message is focused or the flyout is shown\n focused || chatMessageActionFlyoutTarget?.current ? chatMyMessageStyles.menuVisible : chatMyMessageStyles.menuHidden)}>\n {actionMenuProps?.children}\n </div>;\n }, [actionMenuProps?.children, chatMessageActionFlyoutTarget, chatMyMessageStyles.menu, chatMyMessageStyles.menuHidden, chatMyMessageStyles.menuVisible, focused]);\n const getContent = useCallback(() => {\n return <div>\n {getMessageBubbleContent(message, strings, userId, inlineImageOptions, mentionDisplayOptions, onRenderAttachmentDownloads, actionsForAttachment)}\n {getActionsMenu()}\n </div>;\n }, [actionsForAttachment, getActionsMenu, inlineImageOptions, mentionDisplayOptions, message, onRenderAttachmentDownloads, strings, userId]);\n const chatMessage = <>\n <div key={props.message.messageId}>\n <ChatMyMessage attached={attached} key={props.message.messageId} body={{\n // messageContainerStyle used in className and style prop as style prop can't handle CSS selectors\n className: mergeClasses(chatMessageCommonStyles.body, chatMyMessageStyles.body, chatMessageCommonStyles.bodyWithPlaceholderImage, chatMyMessageStyles.bodyWithPlaceholderImage, isBlockedMessage ? chatMessageCommonStyles.blocked : props.message.status === 'failed' ? chatMessageCommonStyles.failed : undefined, attached !== 'top' ? chatMyMessageStyles.bodyAttached : undefined, hasMultipleAttachments ? chatMyMessageStyles.multipleAttachmentsInViewing : undefined, mergeStyles(messageContainerStyle)),\n style: {\n ...createStyleFromV8Style(messageContainerStyle)\n },\n ref: messageRef\n }} root={{\n className: chatMyMessageStyles.root,\n onBlur: e => {\n // `focused` controls is focused the whole `ChatMessage` or any of its children. When we're navigating\n // with keyboard the focused element will be changed and there is no way to use `:focus` selector\n if (chatMessageActionFlyoutTarget?.current) {\n // doesn't dismiss action button if flyout is open, otherwise, narrator's focus will stay on the closed action menu\n return;\n }\n const shouldPreserveFocusState = e.currentTarget.contains(e.relatedTarget);\n setFocused(shouldPreserveFocusState);\n },\n onFocus: () => {\n // react onFocus is called even when nested component receives focus (i.e. it bubbles)\n // so when focus moves within actionMenu, the `focus` state in chatMessage remains true, and keeps actionMenu visible\n setFocused(true);\n }\n }} data-testid=\"chat-composite-message\" author={<Text className={chatMessageDateStyle(theme)}>{message.senderDisplayName}</Text>} timestamp={<Text className={props.message.status === 'failed' ? chatMessageDateFailedStyle(theme) : chatMessageDateStyle(theme)} data-testid={ids.messageTimestamp}>\n {formattedTimestamp}\n </Text>} details={getMessageDetails()} onTouchStart={() => setWasInteractionByTouch(true)} onPointerDown={() => setWasInteractionByTouch(false)} onKeyDown={() => setWasInteractionByTouch(false)} onClick={() => {\n if (!wasInteractionByTouch) {\n return;\n }\n // If the message was touched via touch we immediately open the menu\n // flyout (when using mouse the 3-dot menu that appears on hover\n // must be clicked to open the flyout).\n // In doing so here we set the target of the flyout to be the message and\n // not the 3-dot menu button to position the flyout correctly.\n setChatMessageActionFlyoutTarget(messageRef);\n if (message.messageType === 'chat') {\n props.onActionButtonClick(message, setMessageReadBy);\n }\n }}>\n {getContent()}\n </ChatMyMessage>\n </div>\n {chatActionsEnabled && <ChatMessageActionFlyout hidden={!chatMessageActionFlyoutTarget} target={chatMessageActionFlyoutTarget} increaseFlyoutItemSize={wasInteractionByTouch} onDismiss={onActionFlyoutDismiss} onEditClick={onEditClick} onRemoveClick={onRemoveClick} onResendClick={onResendClick} strings={strings} messageReadBy={messageReadBy} messageStatus={messageStatus ?? 'failed'} remoteParticipantsCount={remoteParticipantsCount} onRenderAvatar={onRenderAvatar} showMessageStatus={showMessageStatus} />}\n </>;\n return chatMessage;\n};\n\n/** @private */\nexport const ChatMyMessageComponentAsMessageBubble = React.memo(MessageBubble);"]}
|