@azure/communication-react 1.19.0-alpha-202408020014 → 1.19.0-alpha-202408070015
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 +7 -0
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-DM13Kp5W.js → ChatMessageComponentAsRichTextEditBox-BMVUY7HX.js} +2 -2
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-DM13Kp5W.js.map → ChatMessageComponentAsRichTextEditBox-BMVUY7HX.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-8FsFMpKF.js → RichTextSendBoxWrapper-UkjXSVQH.js} +2 -2
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-8FsFMpKF.js.map → RichTextSendBoxWrapper-UkjXSVQH.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{index-D84PSTZV.js → index-D46R0M5v.js} +207 -180
- package/dist/dist-cjs/communication-react/index-D46R0M5v.js.map +1 -0
- package/dist/dist-cjs/communication-react/index.js +1 -1
- 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/handlers/createCommonHandlers.d.ts +1 -0
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js +31 -9
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/utils/videoGalleryUtils.d.ts +5 -1
- package/dist/dist-esm/calling-component-bindings/src/utils/videoGalleryUtils.js +6 -2
- package/dist/dist-esm/calling-component-bindings/src/utils/videoGalleryUtils.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/videoGallerySelector.js +2 -1
- package/dist/dist-esm/calling-component-bindings/src/videoGallerySelector.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.d.ts +2 -5
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js +48 -31
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/LocalScreenShare.d.ts +5 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/LocalScreenShare.js +15 -12
- package/dist/dist-esm/react-components/src/components/VideoGallery/LocalScreenShare.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/RemoteScreenShare.d.ts +9 -0
- package/dist/dist-esm/react-components/src/components/VideoGallery/RemoteScreenShare.js +7 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/RemoteScreenShare.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery.d.ts +4 -0
- package/dist/dist-esm/react-components/src/components/VideoGallery.js +4 -4
- package/dist/dist-esm/react-components/src/components/VideoGallery.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js +3 -1
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js +1 -0
- package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +7 -3
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/locales/en-US/strings.json +1 -0
- package/dist/dist-esm/react-components/src/types/VideoGalleryParticipant.d.ts +2 -0
- package/dist/dist-esm/react-components/src/types/VideoGalleryParticipant.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js +6 -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/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/ChatComposite/ImageUpload/ImageUploadUtils.js +4 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js.map +1 -1
- package/package.json +6 -6
- package/dist/dist-cjs/communication-react/index-D84PSTZV.js.map +0 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/styles/LocalScreenShare.styles.d.ts +0 -22
- package/dist/dist-esm/react-components/src/components/VideoGallery/styles/LocalScreenShare.styles.js +0 -44
- package/dist/dist-esm/react-components/src/components/VideoGallery/styles/LocalScreenShare.styles.js.map +0 -1
@@ -125,6 +125,9 @@ const createCompositeHandlers = memoizeOne((adapter, capabilities) => {
|
|
125
125
|
onDisposeRemoteScreenShareStreamView: (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
126
126
|
return adapter.disposeScreenShareStreamView(userId);
|
127
127
|
}),
|
128
|
+
onDisposeLocalScreenShareStreamView: () => __awaiter(void 0, void 0, void 0, function* () {
|
129
|
+
return adapter.disposeScreenShareStreamView('');
|
130
|
+
}),
|
128
131
|
onDisposeRemoteVideoStreamView: (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
129
132
|
return adapter.disposeRemoteVideoStreamView(userId);
|
130
133
|
}),
|
package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useHandlers.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/CallComposite/hooks/useHandlers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAIlC,OAAO,EAAoB,6BAA6B,EAAE,yCAAgC;AAE1F,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,UAAU,EAAE,MAAM,gCA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,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,CAAC,SAAS;YACjE,CAAC,CAAC,GAAwB,EAAE;gBACxB,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YACjC,CAAC,CAAA;YACH,CAAC,CAAC,SAAS;QACb,oBAAoB,EAAE,GAAwB,EAAE;YAC9C,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC;QAChC,CAAC,CAAA;QACD,sBAAsB,EAAE,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,CAAC,SAAS;YAClE,CAAC,CAAC,CAAO,OAAkB,EAAiB,EAAE;gBAC1C,MAAM,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC,CAAA;YACH,CAAC,CAAC,SAAS;QACb,qBAAqB,EAAE,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,2BAA2B,CAAC,SAAS;YACxE,CAAC,CAAC,CAAO,OAAkB,EAAiB,EAAE;gBAC1C,MAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC,CAAA;YACH,CAAC,CAAC,SAAS;QACb,4CAA4C;QAC5C,iBAAiB,EAAE,CAAO,MAAc,EAAiB,EAAE;YACzD,MAAM,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC,CAAA;QACD,4CAA4C;QAC5C,2BAA2B,EAAE,GAAwB,EAAE;YACrD,MAAM,OAAO,CAAC,yBAAyB,EAAE,CAAC;QAC5C,CAAC,CAAA;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonCallingHandlers } from '@internal/calling-component-bindings';\nimport { _ComponentCallingHandlers } from '@internal/calling-component-bindings';\nimport { CommonProperties, toFlatCommunicationIdentifier } from '@internal/acs-ui-common';\nimport { ReactElement } from 'react';\nimport memoizeOne from 'memoize-one';\nimport { CommonCallAdapter } from '..';\n\nimport { VideoBackgroundBlurEffect, VideoBackgroundReplacementEffect } from '..';\nimport { useAdapter } from '../adapter/CallAdapterProvider';\nimport { isCameraOn } from '../utils';\nimport { DtmfTone } from '@azure/communication-calling';\n/* @conditional-compile-remove(PSTN-calls) */\nimport { AddPhoneNumberOptions } from '@azure/communication-calling';\nimport { Reaction } from '@azure/communication-calling';\n\nimport type {\n BackgroundReplacementConfig,\n BackgroundBlurConfig,\n ParticipantCapabilities\n} from '@azure/communication-calling';\nimport { CallSurvey, CallSurveyResponse } from '@azure/communication-calling';\n/* @conditional-compile-remove(PSTN-calls) */\nimport {\n CommunicationIdentifier,\n CommunicationUserIdentifier,\n PhoneNumberIdentifier\n} from '@azure/communication-common';\n/* @conditional-compile-remove(PSTN-calls) */\nimport { _toCommunicationIdentifier } from '@internal/acs-ui-common';\n\n/**\n * @private\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nexport const useHandlers = <PropsT>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _component: (props: PropsT) => ReactElement | null\n): Pick<CommonCallingHandlers, CommonProperties<CommonCallingHandlers, PropsT>> &\n Partial<_ComponentCallingHandlers> => {\n const adapter = useAdapter();\n const capabilities = adapter.getState().call?.capabilitiesFeature?.capabilities;\n return createCompositeHandlers(adapter, capabilities);\n};\n\nconst createCompositeHandlers = memoizeOne(\n (\n adapter: CommonCallAdapter,\n capabilities?: ParticipantCapabilities\n ): CommonCallingHandlers & Partial<_ComponentCallingHandlers> => {\n return {\n onCreateLocalStreamView: async (options) => {\n return await adapter.createStreamView(undefined, options);\n },\n onCreateRemoteStreamView: async (userId, options) => {\n return await adapter.createStreamView(userId, options);\n },\n onHangUp: async (forEveryone?: boolean) => {\n await adapter.leaveCall(forEveryone);\n },\n /* @conditional-compile-remove(PSTN-calls) */\n onToggleHold: async () => {\n return adapter.getState().call?.state === 'LocalHold' ? await adapter.resumeCall() : await adapter.holdCall();\n },\n /* @conditional-compile-remove(PSTN-calls) */\n onAddParticipant: async (\n participant: Partial<CommunicationUserIdentifier & PhoneNumberIdentifier>,\n options?: AddPhoneNumberOptions\n ) => {\n if ('communicationUserId' in participant) {\n return await adapter.addParticipant(participant as CommunicationUserIdentifier);\n } else if ('phoneNumber' in participant) {\n return await adapter.addParticipant(participant as PhoneNumberIdentifier, options);\n }\n },\n onSendDtmfTone: async (dtmfTone: DtmfTone) => {\n await adapter.sendDtmfTone(dtmfTone);\n },\n onRemoveParticipant: async (\n userId: string | /* @conditional-compile-remove(PSTN-calls) */ CommunicationIdentifier\n ) => {\n if (typeof userId === 'string') {\n await adapter.removeParticipant(userId);\n } else {\n /* @conditional-compile-remove(PSTN-calls) */\n await adapter.removeParticipant(_toCommunicationIdentifier(userId));\n }\n },\n onRaiseHand: async () => {\n await adapter.raiseHand();\n },\n onLowerHand: async () => {\n await adapter.lowerHand();\n },\n onToggleRaiseHand: async () => {\n adapter.getState().call?.raiseHand.localParticipantRaisedHand\n ? await adapter.lowerHand()\n : await adapter.raiseHand();\n },\n onReactionClick: async (reaction: Reaction) => {\n await adapter.onReactionClick(reaction);\n },\n onSelectCamera: async (deviceInfo, options) => {\n await adapter.setCamera(deviceInfo, options);\n },\n onSelectMicrophone: async (deviceInfo) => {\n await adapter.setMicrophone(deviceInfo);\n },\n onSelectSpeaker: async (deviceInfo) => {\n await adapter.setSpeaker(deviceInfo);\n },\n onStartCall: (participants, options?) => {\n const rawIds = participants.map((participant) => toFlatCommunicationIdentifier(participant));\n return adapter.startCall(rawIds, options);\n },\n onStartScreenShare: async () => {\n await adapter.startScreenShare();\n },\n onStopScreenShare: async () => {\n await adapter.stopScreenShare();\n },\n onToggleCamera: async (options) => {\n isCameraOn(adapter.getState()) ? await adapter.stopCamera() : await adapter.startCamera(options);\n },\n onToggleMicrophone: async () => {\n return adapter.getState().call?.isMuted ? await adapter.unmute() : await adapter.mute();\n },\n onToggleScreenShare: async () => {\n return adapter.getState().call?.isScreenSharingOn\n ? await adapter.stopScreenShare()\n : await adapter.startScreenShare();\n },\n onStartLocalVideo: async () => {\n if (adapter.getState().call) {\n return adapter.startCamera();\n }\n },\n onDisposeLocalStreamView: async () => {\n return adapter.disposeLocalVideoStreamView();\n },\n onDisposeRemoteStreamView: async (userId) => {\n return adapter.disposeStreamView(userId);\n },\n onDisposeRemoteScreenShareStreamView: async (userId) => {\n return adapter.disposeScreenShareStreamView(userId);\n },\n onDisposeRemoteVideoStreamView: async (userId) => {\n return adapter.disposeRemoteVideoStreamView(userId);\n },\n /* @conditional-compile-remove(call-readiness) */\n askDevicePermission: async (constrain) => {\n return adapter.askDevicePermission(constrain);\n },\n\n onRemoveVideoBackgroundEffects: async () => {\n return await adapter.stopVideoBackgroundEffects();\n },\n\n onBlurVideoBackground: async (backgroundBlurConfig?: BackgroundBlurConfig) => {\n const blurConfig: VideoBackgroundBlurEffect = {\n effectName: 'blur',\n ...backgroundBlurConfig\n };\n return await adapter.startVideoBackgroundEffect(blurConfig);\n },\n\n onReplaceVideoBackground: async (backgroundReplacementConfig: BackgroundReplacementConfig) => {\n const replacementConfig: VideoBackgroundReplacementEffect = {\n effectName: 'replacement',\n ...backgroundReplacementConfig\n };\n return await adapter.startVideoBackgroundEffect(replacementConfig);\n },\n onStartCaptions: async (options) => {\n await adapter.startCaptions(options);\n },\n onStopCaptions: async () => {\n await adapter.stopCaptions();\n },\n onSetSpokenLanguage: async (language) => {\n await adapter.setSpokenLanguage(language);\n },\n onSetCaptionLanguage: async (language) => {\n await adapter.setCaptionLanguage(language);\n },\n onSubmitSurvey: async (survey: CallSurvey): Promise<CallSurveyResponse | undefined> => {\n return await adapter.submitSurvey(survey);\n },\n onStartSpotlight: async (userIds?: string[]): Promise<void> => {\n await adapter.startSpotlight(userIds);\n },\n onStopSpotlight: async (userIds?: string[]): Promise<void> => {\n await adapter.stopSpotlight(userIds);\n },\n onStopAllSpotlight: async (): Promise<void> => {\n await adapter.stopAllSpotlight();\n },\n onStartLocalSpotlight: capabilities?.spotlightParticipant.isPresent\n ? async (): Promise<void> => {\n await adapter.startSpotlight();\n }\n : undefined,\n onStopLocalSpotlight: async (): Promise<void> => {\n await adapter.stopSpotlight();\n },\n onStartRemoteSpotlight: capabilities?.spotlightParticipant.isPresent\n ? async (userIds?: string[]): Promise<void> => {\n await adapter.startSpotlight(userIds);\n }\n : undefined,\n onStopRemoteSpotlight: capabilities?.removeParticipantsSpotlight.isPresent\n ? async (userIds?: string[]): Promise<void> => {\n await adapter.stopSpotlight(userIds);\n }\n : undefined,\n /* @conditional-compile-remove(soft-mute) */\n onMuteParticipant: async (userId: string): Promise<void> => {\n await adapter.muteParticipant(userId);\n },\n /* @conditional-compile-remove(soft-mute) */\n onMuteAllRemoteParticipants: async (): Promise<void> => {\n await adapter.muteAllRemoteParticipants();\n }\n };\n }\n);\n"]}
|
1
|
+
{"version":3,"file":"useHandlers.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/CallComposite/hooks/useHandlers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAIlC,OAAO,EAAoB,6BAA6B,EAAE,yCAAgC;AAE1F,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAkBtC,6CAA6C;AAC7C,OAAO,EAAE,0BAA0B,EAAE,yCAAgC;AAErE;;GAEG;AACH,+HAA+H;AAC/H,MAAM,CAAC,MAAM,WAAW,GAAG;AACzB,6DAA6D;AAC7D,UAAkD,EAEf,EAAE;;IACrC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,MAAA,MAAA,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,0CAAE,mBAAmB,0CAAE,YAAY,CAAC;IAChF,OAAO,uBAAuB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC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AZ,YAAY,CAAE,oBAAoB,CAAC,SAAS;YAClE,CAAC,CAAC,CAAO,OAAkB,EAAiB,EAAE;gBAC1C,MAAM,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC,CAAA;YACH,CAAC,CAAC,SAAS;QACb,qBAAqB,EAAE,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,2BAA2B,CAAC,SAAS;YACxE,CAAC,CAAC,CAAO,OAAkB,EAAiB,EAAE;gBAC1C,MAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC,CAAA;YACH,CAAC,CAAC,SAAS;QACb,4CAA4C;QAC5C,iBAAiB,EAAE,CAAO,MAAc,EAAiB,EAAE;YACzD,MAAM,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC,CAAA;QACD,4CAA4C;QAC5C,2BAA2B,EAAE,GAAwB,EAAE;YACrD,MAAM,OAAO,CAAC,yBAAyB,EAAE,CAAC;QAC5C,CAAC,CAAA;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonCallingHandlers } from '@internal/calling-component-bindings';\nimport { _ComponentCallingHandlers } from '@internal/calling-component-bindings';\nimport { CommonProperties, toFlatCommunicationIdentifier } from '@internal/acs-ui-common';\nimport { ReactElement } from 'react';\nimport memoizeOne from 'memoize-one';\nimport { CommonCallAdapter } from '..';\n\nimport { VideoBackgroundBlurEffect, VideoBackgroundReplacementEffect } from '..';\nimport { useAdapter } from '../adapter/CallAdapterProvider';\nimport { isCameraOn } from '../utils';\nimport { DtmfTone } from '@azure/communication-calling';\n/* @conditional-compile-remove(PSTN-calls) */\nimport { AddPhoneNumberOptions } from '@azure/communication-calling';\nimport { Reaction } from '@azure/communication-calling';\n\nimport type {\n BackgroundReplacementConfig,\n BackgroundBlurConfig,\n ParticipantCapabilities\n} from '@azure/communication-calling';\nimport { CallSurvey, CallSurveyResponse } from '@azure/communication-calling';\n/* @conditional-compile-remove(PSTN-calls) */\nimport {\n CommunicationIdentifier,\n CommunicationUserIdentifier,\n PhoneNumberIdentifier\n} from '@azure/communication-common';\n/* @conditional-compile-remove(PSTN-calls) */\nimport { _toCommunicationIdentifier } from '@internal/acs-ui-common';\n\n/**\n * @private\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nexport const useHandlers = <PropsT>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _component: (props: PropsT) => ReactElement | null\n): Pick<CommonCallingHandlers, CommonProperties<CommonCallingHandlers, PropsT>> &\n Partial<_ComponentCallingHandlers> => {\n const adapter = useAdapter();\n const capabilities = adapter.getState().call?.capabilitiesFeature?.capabilities;\n return createCompositeHandlers(adapter, capabilities);\n};\n\nconst createCompositeHandlers = memoizeOne(\n (\n adapter: CommonCallAdapter,\n capabilities?: ParticipantCapabilities\n ): CommonCallingHandlers & Partial<_ComponentCallingHandlers> => {\n return {\n onCreateLocalStreamView: async (options) => {\n return await adapter.createStreamView(undefined, options);\n },\n onCreateRemoteStreamView: async (userId, options) => {\n return await adapter.createStreamView(userId, options);\n },\n onHangUp: async (forEveryone?: boolean) => {\n await adapter.leaveCall(forEveryone);\n },\n /* @conditional-compile-remove(PSTN-calls) */\n onToggleHold: async () => {\n return adapter.getState().call?.state === 'LocalHold' ? await adapter.resumeCall() : await adapter.holdCall();\n },\n /* @conditional-compile-remove(PSTN-calls) */\n onAddParticipant: async (\n participant: Partial<CommunicationUserIdentifier & PhoneNumberIdentifier>,\n options?: AddPhoneNumberOptions\n ) => {\n if ('communicationUserId' in participant) {\n return await adapter.addParticipant(participant as CommunicationUserIdentifier);\n } else if ('phoneNumber' in participant) {\n return await adapter.addParticipant(participant as PhoneNumberIdentifier, options);\n }\n },\n onSendDtmfTone: async (dtmfTone: DtmfTone) => {\n await adapter.sendDtmfTone(dtmfTone);\n },\n onRemoveParticipant: async (\n userId: string | /* @conditional-compile-remove(PSTN-calls) */ CommunicationIdentifier\n ) => {\n if (typeof userId === 'string') {\n await adapter.removeParticipant(userId);\n } else {\n /* @conditional-compile-remove(PSTN-calls) */\n await adapter.removeParticipant(_toCommunicationIdentifier(userId));\n }\n },\n onRaiseHand: async () => {\n await adapter.raiseHand();\n },\n onLowerHand: async () => {\n await adapter.lowerHand();\n },\n onToggleRaiseHand: async () => {\n adapter.getState().call?.raiseHand.localParticipantRaisedHand\n ? await adapter.lowerHand()\n : await adapter.raiseHand();\n },\n onReactionClick: async (reaction: Reaction) => {\n await adapter.onReactionClick(reaction);\n },\n onSelectCamera: async (deviceInfo, options) => {\n await adapter.setCamera(deviceInfo, options);\n },\n onSelectMicrophone: async (deviceInfo) => {\n await adapter.setMicrophone(deviceInfo);\n },\n onSelectSpeaker: async (deviceInfo) => {\n await adapter.setSpeaker(deviceInfo);\n },\n onStartCall: (participants, options?) => {\n const rawIds = participants.map((participant) => toFlatCommunicationIdentifier(participant));\n return adapter.startCall(rawIds, options);\n },\n onStartScreenShare: async () => {\n await adapter.startScreenShare();\n },\n onStopScreenShare: async () => {\n await adapter.stopScreenShare();\n },\n onToggleCamera: async (options) => {\n isCameraOn(adapter.getState()) ? await adapter.stopCamera() : await adapter.startCamera(options);\n },\n onToggleMicrophone: async () => {\n return adapter.getState().call?.isMuted ? await adapter.unmute() : await adapter.mute();\n },\n onToggleScreenShare: async () => {\n return adapter.getState().call?.isScreenSharingOn\n ? await adapter.stopScreenShare()\n : await adapter.startScreenShare();\n },\n onStartLocalVideo: async () => {\n if (adapter.getState().call) {\n return adapter.startCamera();\n }\n },\n onDisposeLocalStreamView: async () => {\n return adapter.disposeLocalVideoStreamView();\n },\n onDisposeRemoteStreamView: async (userId) => {\n return adapter.disposeStreamView(userId);\n },\n onDisposeRemoteScreenShareStreamView: async (userId) => {\n return adapter.disposeScreenShareStreamView(userId);\n },\n onDisposeLocalScreenShareStreamView: async () => {\n return adapter.disposeScreenShareStreamView('');\n },\n onDisposeRemoteVideoStreamView: async (userId) => {\n return adapter.disposeRemoteVideoStreamView(userId);\n },\n /* @conditional-compile-remove(call-readiness) */\n askDevicePermission: async (constrain) => {\n return adapter.askDevicePermission(constrain);\n },\n\n onRemoveVideoBackgroundEffects: async () => {\n return await adapter.stopVideoBackgroundEffects();\n },\n\n onBlurVideoBackground: async (backgroundBlurConfig?: BackgroundBlurConfig) => {\n const blurConfig: VideoBackgroundBlurEffect = {\n effectName: 'blur',\n ...backgroundBlurConfig\n };\n return await adapter.startVideoBackgroundEffect(blurConfig);\n },\n\n onReplaceVideoBackground: async (backgroundReplacementConfig: BackgroundReplacementConfig) => {\n const replacementConfig: VideoBackgroundReplacementEffect = {\n effectName: 'replacement',\n ...backgroundReplacementConfig\n };\n return await adapter.startVideoBackgroundEffect(replacementConfig);\n },\n onStartCaptions: async (options) => {\n await adapter.startCaptions(options);\n },\n onStopCaptions: async () => {\n await adapter.stopCaptions();\n },\n onSetSpokenLanguage: async (language) => {\n await adapter.setSpokenLanguage(language);\n },\n onSetCaptionLanguage: async (language) => {\n await adapter.setCaptionLanguage(language);\n },\n onSubmitSurvey: async (survey: CallSurvey): Promise<CallSurveyResponse | undefined> => {\n return await adapter.submitSurvey(survey);\n },\n onStartSpotlight: async (userIds?: string[]): Promise<void> => {\n await adapter.startSpotlight(userIds);\n },\n onStopSpotlight: async (userIds?: string[]): Promise<void> => {\n await adapter.stopSpotlight(userIds);\n },\n onStopAllSpotlight: async (): Promise<void> => {\n await adapter.stopAllSpotlight();\n },\n onStartLocalSpotlight: capabilities?.spotlightParticipant.isPresent\n ? async (): Promise<void> => {\n await adapter.startSpotlight();\n }\n : undefined,\n onStopLocalSpotlight: async (): Promise<void> => {\n await adapter.stopSpotlight();\n },\n onStartRemoteSpotlight: capabilities?.spotlightParticipant.isPresent\n ? async (userIds?: string[]): Promise<void> => {\n await adapter.startSpotlight(userIds);\n }\n : undefined,\n onStopRemoteSpotlight: capabilities?.removeParticipantsSpotlight.isPresent\n ? async (userIds?: string[]): Promise<void> => {\n await adapter.stopSpotlight(userIds);\n }\n : undefined,\n /* @conditional-compile-remove(soft-mute) */\n onMuteParticipant: async (userId: string): Promise<void> => {\n await adapter.muteParticipant(userId);\n },\n /* @conditional-compile-remove(soft-mute) */\n onMuteAllRemoteParticipants: async (): Promise<void> => {\n await adapter.muteAllRemoteParticipants();\n }\n };\n }\n);\n"]}
|
package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js
CHANGED
@@ -205,8 +205,10 @@ export const cancelInlineImageUpload = (imageAttributes, imageUploads, messageId
|
|
205
205
|
id: imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.id,
|
206
206
|
messageId
|
207
207
|
});
|
208
|
-
if ((imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.progress) === 1) {
|
209
|
-
|
208
|
+
if ((imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.progress) === 1 && (imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.url)) {
|
209
|
+
// The image id that we got back from the ChatSDK response is stored in the image src attribute,
|
210
|
+
// while the metadata id is the internal image id that we assigned to the image when it was pasted in.
|
211
|
+
deleteInlineImageFromServer(imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.url, adapter);
|
210
212
|
}
|
211
213
|
};
|
212
214
|
/* @conditional-compile-remove(rich-text-editor-image-upload) */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ImageUploadUtils.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,gEAAgE;AAChE,OAAO,EAAgC,2CAA2C,EAAE,yCAAgC;AACpH,gEAAgE;AAChE,OAAO,EAAoB,0BAA0B,EAAwB,MAAM,kCAAkC,CAAC;AACtH,gEAAgE;AAChE,OAAO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AC,SAAS,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,gEAAgE;AAChE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,eAAuC,EAAU,EAAE;IAChG,MAAM,QAAQ,GAAG,eAAe,CAAC,2CAA2C,CAAC,CAAC;IAC9E,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACpF,OAAO,+BAA+B,CAAC;IACzC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { AttachmentMetadataInProgress, _IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY } from '@internal/acs-ui-common';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { AttachmentUpload, AttachmentUploadActionType, AttachmentUploadTask } from '../file-sharing/AttachmentUpload';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { _DEFAULT_INLINE_IMAGE_FILE_NAME, SEND_BOX_UPLOADS_KEY_VALUE } from '../../common/constants';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ChatAdapter } from '../adapter/ChatAdapter';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { Dispatch } from 'react';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ImageActions } from './ImageUploadReducer';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { nanoid } from 'nanoid';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ChatCompositeStrings } from '../Strings';\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst MAX_INLINE_IMAGE_UPLOAD_SIZE_MB = 20;\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst fetchBlobData = async (\n resource: string | URL | Request,\n options: { timeout?: number; headers?: Headers; abortController: AbortController }\n): Promise<Response> => {\n // default timeout is 30 seconds\n const { timeout = 30000, abortController } = options;\n\n const id = setTimeout(() => {\n abortController.abort();\n }, timeout);\n\n const response = await fetch(resource, {\n ...options,\n signal: abortController.signal\n });\n clearTimeout(id);\n return response;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @private\n */\nexport const getInlineImageData = async (image: string): Promise<Blob | undefined> => {\n if (image.startsWith('blob') || image.startsWith('http')) {\n try {\n const res = await fetchBlobData(image, { abortController: new AbortController() });\n const blobImage = await res.blob();\n return blobImage;\n } catch (error) {\n console.error('Error fetching image data', error);\n return;\n }\n }\n return;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getEditBoxMessagesInlineImages = (\n editBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined\n): Record<string, AttachmentMetadataInProgress[]> | undefined => {\n if (!editBoxInlineImageUploads) {\n return;\n }\n const messageIds = Object.keys(editBoxInlineImageUploads || {});\n const messagesInlineImagesWithProgress: Record<string, AttachmentMetadataInProgress[]> = {};\n messageIds.map((messageId) => {\n const messageUploads = editBoxInlineImageUploads[messageId].map((upload) => {\n return upload.metadata;\n });\n messagesInlineImagesWithProgress[messageId] = messageUploads;\n });\n return messagesInlineImagesWithProgress;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getSendBoxInlineImages = (\n sendBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined\n): AttachmentMetadataInProgress[] | undefined => {\n if (!sendBoxInlineImageUploads) {\n return;\n }\n return sendBoxInlineImageUploads[SEND_BOX_UPLOADS_KEY_VALUE]?.map((upload) => upload.metadata);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst inlineImageUploadHandler = async (\n uploadTasks: AttachmentUpload[],\n adapter: ChatAdapter,\n strings: ChatCompositeStrings\n): Promise<void> => {\n for (const task of uploadTasks) {\n const uploadTask = task as AttachmentUploadTask;\n const image: Blob | undefined = uploadTask.image;\n if (!image) {\n uploadTask.notifyUploadFailed(strings.uploadImageDataNotProvided);\n continue;\n }\n if (image && image.size > MAX_INLINE_IMAGE_UPLOAD_SIZE_MB * 1024 * 1024) {\n uploadTask.notifyUploadFailed(\n strings.uploadImageIsTooLarge.replace('{maxImageSize}', `${MAX_INLINE_IMAGE_UPLOAD_SIZE_MB}`)\n );\n continue;\n }\n\n const SUPPORTED_FILES: Array<string> = ['jpg', 'jpeg', 'png', 'gif', 'heic', 'webp'];\n const imageExtension = task.metadata?.name.split('.').pop() ?? '';\n if (!SUPPORTED_FILES.includes(imageExtension)) {\n uploadTask.notifyUploadFailed(\n strings.uploadImageExtensionIsNotAllowed.replace('{imageExtension}', imageExtension)\n );\n continue;\n }\n\n try {\n const response = await adapter.uploadImage(image, task.metadata?.name);\n // Use response id as the image src because we need to keep the original image id as a reference to find the image.\n // Also the html content we send to ChatSDK does not need image src,\n // it only need the response id to match the uploaded image, url is not needed.\n uploadTask.notifyUploadCompleted(task.metadata.id, response.id);\n } catch (error) {\n console.error(error);\n uploadTask.notifyUploadFailed(strings.uploadImageFailed);\n }\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst generateUploadTask = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n messageId: string,\n inlineImageUploadActionHandler: Dispatch<ImageActions>\n): Promise<AttachmentUpload | undefined> => {\n const imageData = await getInlineImageData(imageAttributes.src);\n if (!imageData) {\n return;\n }\n const taskId = nanoid();\n const uploadTask: AttachmentUpload = {\n image: imageData,\n taskId,\n metadata: {\n id: imageAttributes.id,\n name: fileName,\n url: imageAttributes.src,\n progress: 0\n },\n notifyUploadProgressChanged: (value: number) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Progress,\n taskId,\n progress: value,\n messageId\n });\n },\n notifyUploadCompleted: (id: string, url: string) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Completed,\n taskId,\n id,\n url,\n messageId\n });\n },\n notifyUploadFailed: (message: string) => {\n inlineImageUploadActionHandler({ type: AttachmentUploadActionType.Failed, taskId, message, messageId });\n // remove the failed upload task when error banner is auto dismissed after 10 seconds\n // so the banner won't be shown again on UI re-rendering.\n setTimeout(() => {\n inlineImageUploadActionHandler({ type: AttachmentUploadActionType.Remove, id: taskId, messageId });\n }, 10 * 1000);\n }\n };\n return uploadTask;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const onInsertInlineImageForEditBox = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n messageId: string,\n adapter: ChatAdapter,\n handleEditBoxInlineImageUploadAction: Dispatch<ImageActions>,\n chatCompositeStrings: ChatCompositeStrings\n): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(\n imageAttributes,\n fileName,\n messageId,\n handleEditBoxInlineImageUploadAction\n );\n if (!uploadTask) {\n return;\n }\n\n handleEditBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const onInsertInlineImageForSendBox = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n adapter: ChatAdapter,\n handleSendBoxInlineImageUploadAction: Dispatch<ImageActions>,\n chatCompositeStrings: ChatCompositeStrings\n): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(\n imageAttributes,\n fileName,\n SEND_BOX_UPLOADS_KEY_VALUE,\n handleSendBoxInlineImageUploadAction\n );\n\n if (!uploadTask) {\n return;\n }\n\n handleSendBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId: SEND_BOX_UPLOADS_KEY_VALUE\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const cancelInlineImageUpload = (\n imageAttributes: Record<string, string>,\n imageUploads: Record<string, AttachmentUpload[]> | undefined,\n messageId: string,\n inlineImageUploadActionHandler: Dispatch<ImageActions>,\n adapter: ChatAdapter\n): void => {\n if (!imageUploads || !imageUploads[messageId]) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n const imageUpload = imageUploads[messageId].find((upload) => upload.metadata.id === imageAttributes.id);\n\n if (!imageUpload || !imageUpload?.metadata.id) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Remove,\n id: imageUpload?.metadata.id,\n messageId\n });\n\n if (imageUpload?.metadata.progress === 1) {\n deleteInlineImageFromServer(imageUpload?.metadata.id, adapter);\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst deleteInlineImageFromServer = (imageId: string, adapter: ChatAdapter): void => {\n try {\n adapter.deleteImage(imageId);\n } catch (error) {\n console.error(error);\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n// This function is used to delete the inline image that existed before editing starts\nconst deleteExistingInlineImageForEditBox = (imageId: string, messageId: string, adapter: ChatAdapter): void => {\n messageId !== SEND_BOX_UPLOADS_KEY_VALUE && deleteInlineImageFromServer(imageId, adapter);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const updateContentStringWithUploadedInlineImages = (\n content: string,\n imageUploads: Record<string, AttachmentUpload[]> | undefined,\n messageId: string = SEND_BOX_UPLOADS_KEY_VALUE\n): string => {\n if (!imageUploads || !imageUploads[messageId]) {\n return content;\n }\n const messageUploads = imageUploads[messageId];\n const document = new DOMParser().parseFromString(content ?? '', 'text/html');\n document.querySelectorAll('img').forEach((img) => {\n const uploadInlineImage = messageUploads.find(\n (upload) => !upload.metadata.error && upload.metadata.progress === 1 && upload.metadata.id === img.id\n );\n\n if (uploadInlineImage) {\n // ChatSDK uses the respond id provided by the upload response. We store the response id in the image src attribute previously.\n img.id = uploadInlineImage.metadata.url ?? img.id;\n img.src = '';\n }\n });\n content = document.body.innerHTML;\n\n return content;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getImageFileNameFromAttributes = (imageAttributes: Record<string, string>): string => {\n const fileName = imageAttributes[_IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY];\n if (!fileName || fileName === '' || fileName === 'undefined' || fileName === 'null') {\n return _DEFAULT_INLINE_IMAGE_FILE_NAME;\n }\n return fileName;\n};\n"]}
|
1
|
+
{"version":3,"file":"ImageUploadUtils.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,gEAAgE;AAChE,OAAO,EAAgC,2CAA2C,EAAE,yCAAgC;AACpH,gEAAgE;AAChE,OAAO,EAAoB,0BAA0B,EAAwB,MAAM,kCAAkC,CAAC;AACtH,gEAAgE;AAChE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAOrG,gEAAgE;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,gEAAgE;AAChE,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,gEAAgE;AAChE,MAAM,aAAa,GAAG,CACpB,QAAgC,EAChC,OAAkF,EAC/D,EAAE;IACrB,gCAAgC;IAChC,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;QACzB,eAAe,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC,EAAE,OAAO,CAAC,CAAC;IAEZ,MAAM,Q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C;AAClB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { AttachmentMetadataInProgress, _IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY } from '@internal/acs-ui-common';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { AttachmentUpload, AttachmentUploadActionType, AttachmentUploadTask } from '../file-sharing/AttachmentUpload';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { _DEFAULT_INLINE_IMAGE_FILE_NAME, SEND_BOX_UPLOADS_KEY_VALUE } from '../../common/constants';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ChatAdapter } from '../adapter/ChatAdapter';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { Dispatch } from 'react';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ImageActions } from './ImageUploadReducer';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { nanoid } from 'nanoid';\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nimport { ChatCompositeStrings } from '../Strings';\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst MAX_INLINE_IMAGE_UPLOAD_SIZE_MB = 20;\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst fetchBlobData = async (\n resource: string | URL | Request,\n options: { timeout?: number; headers?: Headers; abortController: AbortController }\n): Promise<Response> => {\n // default timeout is 30 seconds\n const { timeout = 30000, abortController } = options;\n\n const id = setTimeout(() => {\n abortController.abort();\n }, timeout);\n\n const response = await fetch(resource, {\n ...options,\n signal: abortController.signal\n });\n clearTimeout(id);\n return response;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @private\n */\nexport const getInlineImageData = async (image: string): Promise<Blob | undefined> => {\n if (image.startsWith('blob') || image.startsWith('http')) {\n try {\n const res = await fetchBlobData(image, { abortController: new AbortController() });\n const blobImage = await res.blob();\n return blobImage;\n } catch (error) {\n console.error('Error fetching image data', error);\n return;\n }\n }\n return;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getEditBoxMessagesInlineImages = (\n editBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined\n): Record<string, AttachmentMetadataInProgress[]> | undefined => {\n if (!editBoxInlineImageUploads) {\n return;\n }\n const messageIds = Object.keys(editBoxInlineImageUploads || {});\n const messagesInlineImagesWithProgress: Record<string, AttachmentMetadataInProgress[]> = {};\n messageIds.map((messageId) => {\n const messageUploads = editBoxInlineImageUploads[messageId].map((upload) => {\n return upload.metadata;\n });\n messagesInlineImagesWithProgress[messageId] = messageUploads;\n });\n return messagesInlineImagesWithProgress;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getSendBoxInlineImages = (\n sendBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined\n): AttachmentMetadataInProgress[] | undefined => {\n if (!sendBoxInlineImageUploads) {\n return;\n }\n return sendBoxInlineImageUploads[SEND_BOX_UPLOADS_KEY_VALUE]?.map((upload) => upload.metadata);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst inlineImageUploadHandler = async (\n uploadTasks: AttachmentUpload[],\n adapter: ChatAdapter,\n strings: ChatCompositeStrings\n): Promise<void> => {\n for (const task of uploadTasks) {\n const uploadTask = task as AttachmentUploadTask;\n const image: Blob | undefined = uploadTask.image;\n if (!image) {\n uploadTask.notifyUploadFailed(strings.uploadImageDataNotProvided);\n continue;\n }\n if (image && image.size > MAX_INLINE_IMAGE_UPLOAD_SIZE_MB * 1024 * 1024) {\n uploadTask.notifyUploadFailed(\n strings.uploadImageIsTooLarge.replace('{maxImageSize}', `${MAX_INLINE_IMAGE_UPLOAD_SIZE_MB}`)\n );\n continue;\n }\n\n const SUPPORTED_FILES: Array<string> = ['jpg', 'jpeg', 'png', 'gif', 'heic', 'webp'];\n const imageExtension = task.metadata?.name.split('.').pop() ?? '';\n if (!SUPPORTED_FILES.includes(imageExtension)) {\n uploadTask.notifyUploadFailed(\n strings.uploadImageExtensionIsNotAllowed.replace('{imageExtension}', imageExtension)\n );\n continue;\n }\n\n try {\n const response = await adapter.uploadImage(image, task.metadata?.name);\n // Use response id as the image src because we need to keep the original image id as a reference to find the image.\n // Also the html content we send to ChatSDK does not need image src,\n // it only need the response id to match the uploaded image, url is not needed.\n uploadTask.notifyUploadCompleted(task.metadata.id, response.id);\n } catch (error) {\n console.error(error);\n uploadTask.notifyUploadFailed(strings.uploadImageFailed);\n }\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst generateUploadTask = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n messageId: string,\n inlineImageUploadActionHandler: Dispatch<ImageActions>\n): Promise<AttachmentUpload | undefined> => {\n const imageData = await getInlineImageData(imageAttributes.src);\n if (!imageData) {\n return;\n }\n const taskId = nanoid();\n const uploadTask: AttachmentUpload = {\n image: imageData,\n taskId,\n metadata: {\n id: imageAttributes.id,\n name: fileName,\n url: imageAttributes.src,\n progress: 0\n },\n notifyUploadProgressChanged: (value: number) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Progress,\n taskId,\n progress: value,\n messageId\n });\n },\n notifyUploadCompleted: (id: string, url: string) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Completed,\n taskId,\n id,\n url,\n messageId\n });\n },\n notifyUploadFailed: (message: string) => {\n inlineImageUploadActionHandler({ type: AttachmentUploadActionType.Failed, taskId, message, messageId });\n // remove the failed upload task when error banner is auto dismissed after 10 seconds\n // so the banner won't be shown again on UI re-rendering.\n setTimeout(() => {\n inlineImageUploadActionHandler({ type: AttachmentUploadActionType.Remove, id: taskId, messageId });\n }, 10 * 1000);\n }\n };\n return uploadTask;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const onInsertInlineImageForEditBox = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n messageId: string,\n adapter: ChatAdapter,\n handleEditBoxInlineImageUploadAction: Dispatch<ImageActions>,\n chatCompositeStrings: ChatCompositeStrings\n): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(\n imageAttributes,\n fileName,\n messageId,\n handleEditBoxInlineImageUploadAction\n );\n if (!uploadTask) {\n return;\n }\n\n handleEditBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const onInsertInlineImageForSendBox = async (\n imageAttributes: Record<string, string>,\n fileName: string,\n adapter: ChatAdapter,\n handleSendBoxInlineImageUploadAction: Dispatch<ImageActions>,\n chatCompositeStrings: ChatCompositeStrings\n): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(\n imageAttributes,\n fileName,\n SEND_BOX_UPLOADS_KEY_VALUE,\n handleSendBoxInlineImageUploadAction\n );\n\n if (!uploadTask) {\n return;\n }\n\n handleSendBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId: SEND_BOX_UPLOADS_KEY_VALUE\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const cancelInlineImageUpload = (\n imageAttributes: Record<string, string>,\n imageUploads: Record<string, AttachmentUpload[]> | undefined,\n messageId: string,\n inlineImageUploadActionHandler: Dispatch<ImageActions>,\n adapter: ChatAdapter\n): void => {\n if (!imageUploads || !imageUploads[messageId]) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n const imageUpload = imageUploads[messageId].find((upload) => upload.metadata.id === imageAttributes.id);\n\n if (!imageUpload || !imageUpload?.metadata.id) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Remove,\n id: imageUpload?.metadata.id,\n messageId\n });\n\n if (imageUpload?.metadata.progress === 1 && imageUpload?.metadata.url) {\n // The image id that we got back from the ChatSDK response is stored in the image src attribute,\n // while the metadata id is the internal image id that we assigned to the image when it was pasted in.\n deleteInlineImageFromServer(imageUpload?.metadata.url, adapter);\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\nconst deleteInlineImageFromServer = (imageId: string, adapter: ChatAdapter): void => {\n try {\n adapter.deleteImage(imageId);\n } catch (error) {\n console.error(error);\n }\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n// This function is used to delete the inline image that existed before editing starts\nconst deleteExistingInlineImageForEditBox = (imageId: string, messageId: string, adapter: ChatAdapter): void => {\n messageId !== SEND_BOX_UPLOADS_KEY_VALUE && deleteInlineImageFromServer(imageId, adapter);\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const updateContentStringWithUploadedInlineImages = (\n content: string,\n imageUploads: Record<string, AttachmentUpload[]> | undefined,\n messageId: string = SEND_BOX_UPLOADS_KEY_VALUE\n): string => {\n if (!imageUploads || !imageUploads[messageId]) {\n return content;\n }\n const messageUploads = imageUploads[messageId];\n const document = new DOMParser().parseFromString(content ?? '', 'text/html');\n document.querySelectorAll('img').forEach((img) => {\n const uploadInlineImage = messageUploads.find(\n (upload) => !upload.metadata.error && upload.metadata.progress === 1 && upload.metadata.id === img.id\n );\n\n if (uploadInlineImage) {\n // ChatSDK uses the respond id provided by the upload response. We store the response id in the image src attribute previously.\n img.id = uploadInlineImage.metadata.url ?? img.id;\n img.src = '';\n }\n });\n content = document.body.innerHTML;\n\n return content;\n};\n\n/* @conditional-compile-remove(rich-text-editor-image-upload) */\n/**\n * @internal\n */\nexport const getImageFileNameFromAttributes = (imageAttributes: Record<string, string>): string => {\n const fileName = imageAttributes[_IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY];\n if (!fileName || fileName === '' || fileName === 'undefined' || fileName === 'null') {\n return _DEFAULT_INLINE_IMAGE_FILE_NAME;\n }\n return fileName;\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-react",
|
3
|
-
"version": "1.19.0-alpha-
|
3
|
+
"version": "1.19.0-alpha-202408070015",
|
4
4
|
"sideEffects": false,
|
5
5
|
"description": "React library for building modern communication user experiences utilizing Azure Communication Services",
|
6
6
|
"keywords": [
|
@@ -44,11 +44,11 @@
|
|
44
44
|
"react-linkify": "^1.0.0-alpha",
|
45
45
|
"react-use-draggable-scroll": "^0.4.7",
|
46
46
|
"reselect": "^4.0.0",
|
47
|
-
"roosterjs-content-model-api": "^9.
|
48
|
-
"roosterjs-content-model-core": "^9.
|
49
|
-
"roosterjs-content-model-dom": "^9.
|
50
|
-
"roosterjs-content-model-plugins": "^9.
|
51
|
-
"roosterjs-content-model-types": "^9.
|
47
|
+
"roosterjs-content-model-api": "^9.9.0",
|
48
|
+
"roosterjs-content-model-core": "^9.9.0",
|
49
|
+
"roosterjs-content-model-dom": "^9.9.0",
|
50
|
+
"roosterjs-content-model-plugins": "^9.9.0",
|
51
|
+
"roosterjs-content-model-types": "^9.9.0",
|
52
52
|
"textarea-caret-ts": "^4.1.1",
|
53
53
|
"use-debounce": "^10.0.2",
|
54
54
|
"uuid": "^9.0.0"
|