@cometchat/chat-uikit-react-native 5.5.0 → 5.5.2

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.
Files changed (104) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  3. package/android/build.gradle +23 -89
  4. package/android/gradle.properties +5 -5
  5. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +5 -1
  6. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +52 -0
  7. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +37 -4
  8. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +9 -1
  9. package/ios/FileManager.m +77 -3
  10. package/ios/RichTextEditorView.swift +52 -1
  11. package/ios/RichTextEditorViewManager.m +1 -0
  12. package/ios/RichTextEditorViewManager.swift +8 -0
  13. package/package.json +8 -5
  14. package/react-native-cometchat-ui-kit.podspec +5 -19
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +69 -36
  16. package/src/CometChatConversations/CometChatConversations.tsx +12 -1
  17. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +2 -2
  18. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +50 -31
  19. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +10 -1
  20. package/src/CometChatMessageList/CometChatMessageList.tsx +24 -19
  21. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +7 -8
  22. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +43 -19
  23. package/src/CometChatRichTextEditor/index.tsx +6 -1
  24. package/src/CometChatRichTextEditor/types.ts +2 -0
  25. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +251 -14
  26. package/src/CometChatSearch/CometChatSearch.tsx +39 -11
  27. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +56 -17
  28. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +12 -9
  29. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -10
  30. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +34 -27
  31. package/src/extensions/Polls/Polls.tsx +7 -7
  32. package/src/extensions/Polls/PollsBubble.tsx +2 -2
  33. package/src/globals.d.ts +6 -0
  34. package/src/shared/CometChatUiKit/CometChatUIKit.ts +2 -1
  35. package/src/shared/constants/UIKitConstants.ts +3 -17
  36. package/src/shared/constants/textPatterns.ts +45 -0
  37. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +25 -259
  38. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +22 -11
  39. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +56 -32
  40. package/src/shared/formatters/CometChatTextFormatter.ts +22 -0
  41. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -0
  42. package/src/shared/formatters/applyRawFormatters.ts +31 -0
  43. package/src/shared/formatters/codeElements.ts +21 -0
  44. package/src/shared/framework/MessageDataSource.tsx +14 -8
  45. package/src/shared/helper/types/index.ts +5 -0
  46. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +4 -4
  47. package/src/shared/libs/ImageZoom/types/index.ts +2 -0
  48. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +15 -30
  49. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +138 -19
  50. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -1
  51. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +0 -1
  52. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +54 -1
  53. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +54 -1
  54. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +54 -1
  55. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +54 -1
  56. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +54 -1
  57. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +54 -1
  58. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +54 -1
  59. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +54 -1
  60. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +54 -1
  61. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +54 -1
  62. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +54 -1
  63. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +54 -1
  64. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +54 -1
  65. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +54 -1
  66. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +54 -1
  67. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +54 -1
  68. package/src/shared/resources/CometChatSoundManager/sound.js +2 -3
  69. package/src/shared/services/UploadQueueService.ts +7 -0
  70. package/src/shared/utils/CometChatMessageHelper/index.ts +3 -0
  71. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +11 -0
  72. package/src/shared/utils/MarkdownUtils.ts +42 -5
  73. package/src/shared/utils/MessageUtils.tsx +7 -5
  74. package/src/shared/utils/PinnedMessagesHelper.ts +65 -0
  75. package/src/shared/utils/SavedMessagesHelper.ts +42 -6
  76. package/src/shared/utils/__testUtils__/messagesRequestBuilderMock.ts +37 -0
  77. package/src/shared/utils/cloneRequestBuilder.ts +25 -0
  78. package/src/shared/utils/groupMemberAddedRows.ts +28 -0
  79. package/src/shared/utils/linkPreviewSelection.ts +109 -0
  80. package/src/shared/utils/mentionTokens.ts +77 -0
  81. package/src/shared/utils/runAfterInteractions.ts +26 -0
  82. package/src/shared/utils/stripRichText.ts +2 -1
  83. package/src/shared/utils/tapGesture.ts +23 -0
  84. package/src/shared/utils/videoThumbnail.ts +74 -0
  85. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +15 -4
  86. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +21 -13
  87. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +13 -15
  88. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +5 -0
  89. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -1
  90. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +8 -1
  91. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +1 -1
  92. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -1
  93. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +7 -1
  94. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +8 -26
  95. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +4 -2
  96. package/src/shared/views/CometChatList/Header.tsx +9 -3
  97. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +2 -1
  98. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +28 -8
  99. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -4
  100. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +36 -4
  101. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +2 -1
  102. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +62 -30
  103. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +5 -0
  104. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +0 -154
@@ -24,6 +24,7 @@ import { useCompTheme } from '../../../theme/hook';
24
24
  import { CometChatCaptionText } from '../CometChatCaptionText';
25
25
  import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
26
26
  import { ATTACHMENT_COLLAPSED_LIMIT } from '../../constants/UIKitConstants';
27
+ import { AdditionalParams } from "../../base/Types";
27
28
 
28
29
  const { SoundPlayer, FileManager } = NativeModules;
29
30
  const soundEvents = new NativeEventEmitter(SoundPlayer);
@@ -440,6 +441,8 @@ export interface CometChatAudiosBubbleProps {
440
441
  message: CometChat.MediaMessage;
441
442
  theme: CometChatTheme;
442
443
  style?: CometChatTheme["audiosBubbleStyles"];
444
+ /** Render-time params from the message list — carries the consumer's `textFormatters`. */
445
+ additionalParams?: AdditionalParams;
443
446
  }
444
447
 
445
448
  /**
@@ -451,6 +454,7 @@ export function CometChatAudiosBubble({
451
454
  message,
452
455
  theme,
453
456
  style,
457
+ additionalParams,
454
458
  }: CometChatAudiosBubbleProps) {
455
459
  const compTheme = useCompTheme();
456
460
  const s = deepMerge(
@@ -569,6 +573,7 @@ export function CometChatAudiosBubble({
569
573
  {Boolean(caption) && (
570
574
  <CometChatCaptionText
571
575
  message={message}
576
+ additionalParams={additionalParams}
572
577
  caption={caption}
573
578
  theme={theme}
574
579
  containerStyle={{
@@ -208,7 +208,10 @@ const CometChatBottomSheet = forwardRef(
208
208
  >
209
209
  <View
210
210
  style={{
211
- ...(doNotOccupyEntireHeight ? {} : { flex: 1 }),
211
+ // Content-sized sheets must still shrink to the sheet's maxHeight: without
212
+ // flexShrink this view keeps its full content height and overflows past the
213
+ // bottom of the screen, leaving the last rows of a scrollable child unreachable.
214
+ ...(doNotOccupyEntireHeight ? { flexShrink: 1 } : { flex: 1 }),
212
215
  paddingBottom: style.paddingBottom ?? 0,
213
216
  }}
214
217
  >
@@ -10,6 +10,7 @@ import {
10
10
  CometChatUrlsFormatter,
11
11
  CometChatRichTextFormatter,
12
12
  } from "../../formatters";
13
+ import { applyRawFormatters } from "../../formatters/applyRawFormatters";
13
14
  import { CommonUtils } from "../../utils/CommonUtils";
14
15
  import { CometChatUIKit } from "../../CometChatUiKit";
15
16
  import { MentionsTargetElement } from "../../constants/UIKitConstants";
@@ -46,9 +47,15 @@ export function CometChatCaptionText({
46
47
  () => buildCaptionFormatters(message, theme, additionalParams),
47
48
  [message, theme, additionalParams]
48
49
  );
50
+ // A consumer's own wire token becomes UI Kit markup before the chain above parses the caption —
51
+ // same order the text bubble uses, so a caption and a text message render identically.
52
+ const text = useMemo(
53
+ () => applyRawFormatters(caption, additionalParams?.textFormatters),
54
+ [caption, additionalParams]
55
+ );
49
56
  return (
50
57
  <CometChatTextBubble
51
- text={caption}
58
+ text={text}
52
59
  textStyle={textStyle}
53
60
  textContainerStyle={containerStyle}
54
61
  textFormatters={formatters}
@@ -279,7 +279,7 @@ const CometChatEmojiKeyboard: React.FC<CometChatEmojiKeyboardProps> = ({
279
279
  showsVerticalScrollIndicator={false}
280
280
  style={styles.flatList}
281
281
  initialNumToRender={80}
282
- removeClippedSubviews={true}
282
+ removeClippedSubviews={Platform.OS !== 'android'} // ENG-40210: clipping crashes Fabric on Android
283
283
  />
284
284
  );
285
285
  };
@@ -87,7 +87,8 @@ export const CometChatFileBubble = ({
87
87
  if (Platform.OS == "android") {
88
88
  listener = eventEmitter.addListener(
89
89
  "downloadComplete",
90
- (data: { downloadId: number }) => {
90
+ (event) => {
91
+ const data = event as { downloadId: number };
91
92
  if (data.downloadId && downloadIdRef.current && data.downloadId == downloadIdRef.current) {
92
93
  setProcessing(false);
93
94
  setFileExists(true);
@@ -18,6 +18,7 @@ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
18
18
  import { groupAttachments } from '../../utils/groupAttachments';
19
19
  import { CometChatUIKit } from '../../CometChatUiKit';
20
20
  import { CometChatCaptionText } from '../CometChatCaptionText';
21
+ import { AdditionalParams } from "../../base/Types";
21
22
 
22
23
  const { FileManager } = NativeModules;
23
24
  const fileEventEmitter = new NativeEventEmitter(FileManager);
@@ -53,6 +54,8 @@ export interface CometChatFilesBubbleProps {
53
54
  /** Per-instance style overrides (applied over the tokenized defaults) — same pattern as the
54
55
  * other bubbles (e.g. CometChatAudioBubble / CometChatFileBubble). */
55
56
  style?: CometChatTheme["filesBubbleStyles"];
57
+ /** Render-time params from the message list — carries the consumer's `textFormatters`. */
58
+ additionalParams?: AdditionalParams;
56
59
  }
57
60
 
58
61
  /**
@@ -64,6 +67,7 @@ export function CometChatFilesBubble({
64
67
  message,
65
68
  theme,
66
69
  style,
70
+ additionalParams,
67
71
  }: CometChatFilesBubbleProps) {
68
72
  const { t } = useCometChatTranslation();
69
73
  const compTheme = useCompTheme();
@@ -79,7 +83,8 @@ export function CometChatFilesBubble({
79
83
  const pendingOpensRef = useRef<Record<string, { url: string; name: string; key: string }>>({});
80
84
  useEffect(() => {
81
85
  if (Platform.OS !== 'android') return;
82
- const sub = fileEventEmitter.addListener('downloadComplete', (data: { downloadId: number }) => {
86
+ const sub = fileEventEmitter.addListener('downloadComplete', (event) => {
87
+ const data = event as { downloadId: number };
83
88
  const pending = pendingOpensRef.current[String(data?.downloadId)];
84
89
  if (pending) {
85
90
  FileManager?.openFile?.(pending.url, pending.name, () => {});
@@ -298,6 +303,7 @@ export function CometChatFilesBubble({
298
303
  {Boolean(caption) && (
299
304
  <CometChatCaptionText
300
305
  message={message}
306
+ additionalParams={additionalParams}
301
307
  caption={caption}
302
308
  theme={theme}
303
309
  containerStyle={{
@@ -6,11 +6,11 @@ import { useTheme } from '../../../theme';
6
6
  import { useCompTheme } from '../../../theme/hook';
7
7
  import { deepMerge } from '../../helper/helperFunctions';
8
8
  import { CometChatUIKit } from '../../CometChatUiKit';
9
- import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
10
9
  import { CometChatMediaViewer } from '../CometChatMediaViewer';
11
10
  import { CometChatCaptionText } from '../CometChatCaptionText';
12
11
  import { Icon } from '../../icons/Icon';
13
12
  import { isImageMime } from '../CometChatMediaViewer/mediaViewerUtils';
13
+ import { AdditionalParams } from "../../base/Types";
14
14
 
15
15
  // ---------------------------------------------------------------------------
16
16
  // Design doc §8.1 — ImagesBubble: renders a single-kind IMAGE message (all images after the §7 fan-out)
@@ -80,14 +80,14 @@ const ImageCell = ({
80
80
  {showPlaceholder ? (
81
81
  <View
82
82
  testID="grid-cell-nopreview"
83
- style={[StyleSheet.absoluteFillObject, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
83
+ style={[StyleSheet.absoluteFill, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
84
84
  >
85
85
  <Icon name="unknown-file-type" size={theme.spacing.spacing.s12} />
86
86
  </View>
87
87
  ) : (
88
88
  <Image
89
89
  source={{ uri: attachment.getUrl() }}
90
- style={[StyleSheet.absoluteFillObject, borderStyle]}
90
+ style={[StyleSheet.absoluteFill, borderStyle]}
91
91
  resizeMode="cover"
92
92
  onError={() => setFailed(true)}
93
93
  />
@@ -97,7 +97,7 @@ const ImageCell = ({
97
97
  <View
98
98
  testID="grid-overflow"
99
99
  pointerEvents="none"
100
- style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
100
+ style={[StyleSheet.absoluteFill, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
101
101
  >
102
102
  {/* heading1.bold = { fontSize: 24, fontWeight: '700' }; letterSpacing -0.5 is a micro-adjust. */}
103
103
  <Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
@@ -211,6 +211,8 @@ export interface CometChatImagesBubbleProps {
211
211
  theme: CometChatTheme;
212
212
  /** Per-instance style overrides — shares the `mediaGridBubbleStyles` theme key with VideosBubble. */
213
213
  style?: CometChatTheme["mediaGridBubbleStyles"];
214
+ /** Render-time params from the message list — carries the consumer's `textFormatters`. */
215
+ additionalParams?: AdditionalParams;
214
216
  }
215
217
 
216
218
  /**
@@ -221,6 +223,7 @@ export function CometChatImagesBubble({
221
223
  message: initialMessage,
222
224
  theme,
223
225
  style,
226
+ additionalParams,
224
227
  }: CometChatImagesBubbleProps) {
225
228
  const compTheme = useCompTheme();
226
229
  const s = deepMerge(theme.mediaGridBubbleStyles ?? {}, compTheme.mediaGridBubbleStyles ?? {}, style ?? {});
@@ -240,28 +243,6 @@ export function CometChatImagesBubble({
240
243
  const caption = message.getCaption() ?? '';
241
244
  const isSentByMe = message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid();
242
245
 
243
- // §8.7 — refresh the local copy when the server edits the message in.
244
- useEffect(() => {
245
- const listenerId = `ImagesBubble_${message.getId?.() ?? message.getMuid?.() ?? Date.now()}`;
246
- CometChatMessageEvents.addListener(
247
- CometChatMessageEvents.messageEdited,
248
- listenerId,
249
- (edited: CometChat.BaseMessage) => {
250
- const editedId = edited.getId?.();
251
- const editedMuid = edited.getMuid?.();
252
- const myId = message.getId?.();
253
- const myMuid = message.getMuid?.();
254
- if (
255
- edited instanceof CometChat.MediaMessage &&
256
- ((myId && editedId && myId === editedId) || (myMuid && editedMuid && myMuid === editedMuid))
257
- ) {
258
- setMessage(edited);
259
- }
260
- }
261
- );
262
- return () => CometChatMessageEvents.removeListener(CometChatMessageEvents.messageEdited, listenerId);
263
- }, []);
264
-
265
246
  useEffect(() => {
266
247
  setMessage(initialMessage);
267
248
  }, [initialMessage]);
@@ -287,6 +268,7 @@ export function CometChatImagesBubble({
287
268
  {Boolean(caption) && (
288
269
  <CometChatCaptionText
289
270
  message={message}
271
+ additionalParams={additionalParams}
290
272
  caption={caption}
291
273
  theme={theme}
292
274
  containerStyle={{
@@ -322,7 +322,8 @@ export function useAudioRecorder(): UseAudioRecorderReturn {
322
322
 
323
323
  if (reducerState.state === 'recording') {
324
324
  // Listen for native amplitude events
325
- subscription = FileManagerEmitter.addListener('audioAmplitude', (event: { amplitude: number }) => {
325
+ subscription = FileManagerEmitter.addListener('audioAmplitude', (data) => {
326
+ const event = data as { amplitude: number };
326
327
  const amplitude = event.amplitude;
327
328
 
328
329
  // WhatsApp-style amplitude processing:
@@ -371,7 +372,8 @@ export function useAudioRecorder(): UseAudioRecorderReturn {
371
372
 
372
373
  if (reducerState.state === 'playing') {
373
374
  // Listen for playback complete event from native
374
- statusSubscription = FileManagerEmitter.addListener('status', (event: { state: string }) => {
375
+ statusSubscription = FileManagerEmitter.addListener('status', (data) => {
376
+ const event = data as { state: string };
375
377
  // Ignore playback complete during seeking - it might be stale
376
378
  if (event.state === 'playbackComplete' && !isSeekingRef.current) {
377
379
  dispatch({ type: 'PLAYBACK_COMPLETE' });
@@ -12,6 +12,7 @@ import {
12
12
  ViewStyle,
13
13
  } from "react-native";
14
14
  import { useTheme } from "../../../theme";
15
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
15
16
  import { Icon } from "../../icons/Icon";
16
17
  import styles from "./styles";
17
18
 
@@ -163,7 +164,7 @@ export default function Header({
163
164
  titleStyle = {},
164
165
  titleViewStyle,
165
166
  containerStyle,
166
- searchPlaceholderText = "Search",
167
+ searchPlaceholderText,
167
168
  confirmSelectionStyle,
168
169
  selectionCancelStyle,
169
170
  titleSeparatorStyle = {},
@@ -174,7 +175,11 @@ export default function Header({
174
175
  onSearchBarClicked,
175
176
  }: HeaderProps) {
176
177
  const theme = useTheme();
177
- const inputRef = useRef<TextInput>(null);
178
+ const { t } = useCometChatTranslation();
179
+ const inputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
180
+ // Callers that pass nothing used to get a hardcoded English "Search", which
181
+ // is why the conversation list's search box stayed English in every locale.
182
+ const searchPlaceholder = searchPlaceholderText ?? t("SEARCH");
178
183
  return (
179
184
  <View style={[styles.listBaseHeaderStyle, { width: '100%' }]}>
180
185
  {/* Header section with border */}
@@ -277,6 +282,7 @@ export default function Header({
277
282
  ) : (
278
283
 
279
284
  <Pressable
285
+ testID='List.searchBar'
280
286
  onPress={onSearchBarClicked}
281
287
  disabled={!onSearchBarClicked}
282
288
  >
@@ -309,7 +315,7 @@ export default function Header({
309
315
  />
310
316
  <TextInput
311
317
  ref={inputRef}
312
- placeholder={searchPlaceholderText}
318
+ placeholder={searchPlaceholder}
313
319
  placeholderTextColor={
314
320
  searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
315
321
  }
@@ -80,7 +80,8 @@ export const CometChatAudioPreview = ({
80
80
  }, [audioUrl]);
81
81
 
82
82
  useEffect(() => {
83
- listener = eventEmitter.addListener("soundPlayStatus", (data) => {
83
+ listener = eventEmitter.addListener("soundPlayStatus", (event) => {
84
+ const data = event as { url?: string };
84
85
  if (audioUrl === data.url) {
85
86
  // playback ended for this url — reset to idle, clear interval and reset time
86
87
  setStatus("");
@@ -28,6 +28,7 @@ import Video from 'react-native-video';
28
28
  import { Icon } from '../../icons/Icon';
29
29
  import { useTheme } from '../../../theme';
30
30
  import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
31
+ import { ReactNativeZoomableView } from '../../libs/ImageZoom';
31
32
  import { clampIndex, isImageMime, isVideoMime, nextIndexForSwipe } from './mediaViewerUtils';
32
33
 
33
34
  /** Default: an item is previewable if it's an image or a video. A per-kind bubble (ImagesBubble /
@@ -108,7 +109,14 @@ export const CometChatMediaViewer = ({
108
109
  mediaItemsRef.current = mediaItems;
109
110
  }, [mediaItems]);
110
111
 
112
+ // While an image is zoomed in, drags pan the image instead of paging.
113
+ const zoomedRef = useRef(false);
114
+ const onZoomChange = (_e: unknown, _gs: unknown, zoom: { zoomLevel: number }) => {
115
+ zoomedRef.current = zoom.zoomLevel > 1.01;
116
+ };
117
+
111
118
  const goTo = (idx: number) => {
119
+ zoomedRef.current = false;
112
120
  const clamped = clampIndex(idx, mediaItemsRef.current.length);
113
121
  currentIndexRef.current = clamped;
114
122
  setCurrentIndex(clamped);
@@ -122,7 +130,9 @@ export const CometChatMediaViewer = ({
122
130
  PanResponder.create({
123
131
  // Swipe-to-page only on IMAGE pages. On video pages the native controls own all gestures
124
132
  // (scrubbing is horizontal too), so we don't hijack them — page via the on-screen arrows (B3).
125
- onMoveShouldSetPanResponder: (_, gs) => {
133
+ onMoveShouldSetPanResponder: (evt, gs) => {
134
+ // Never page during a pinch or while zoomed in.
135
+ if (zoomedRef.current || evt.nativeEvent.touches.length > 1) return false;
126
136
  const it = mediaItemsRef.current[currentIndexRef.current];
127
137
  const onVideo = it ? isVideoMime(it.getMimeType?.() ?? '') : false;
128
138
  return !onVideo && Math.abs(gs.dx) > 10 && Math.abs(gs.dx) > Math.abs(gs.dy);
@@ -288,13 +298,23 @@ export const CometChatMediaViewer = ({
288
298
  )}
289
299
  </View>
290
300
  ) : (
291
- <Image
292
- source={{ uri: current.getUrl() }}
293
- style={styles.fullMedia}
294
- resizeMode="contain"
295
- onLoad={() => setMediaLoaded(true)}
296
- onError={() => { setMediaError(true); setMediaLoaded(true); }}
297
- />
301
+ // Pinch / double-tap to zoom. `key` resets the zoom on every page change. At 1x the zoom view
302
+ // hands a horizontal drag to the pager's PanResponder above; zoomed in, it keeps it to pan.
303
+ <ReactNativeZoomableView
304
+ key={currentIndex}
305
+ disablePanOnInitialZoom
306
+ onZoomAfter={onZoomChange}
307
+ onTransform={(z: { zoomLevel: number }) => onZoomChange(null, null, z)}
308
+ onPanResponderTerminationRequest={() => !zoomedRef.current}
309
+ >
310
+ <Image
311
+ source={{ uri: current.getUrl() }}
312
+ style={styles.fullMedia}
313
+ resizeMode="contain"
314
+ onLoad={() => setMediaLoaded(true)}
315
+ onError={() => { setMediaError(true); setMediaLoaded(true); }}
316
+ />
317
+ </ReactNativeZoomableView>
298
318
  )}
299
319
  </View>
300
320
 
@@ -1,9 +1,8 @@
1
1
  import React, { JSX, RefObject } from "react";
2
2
  import {
3
3
  ColorValue,
4
- NativeSyntheticEvent,
5
4
  TextInput,
6
- TextInputSelectionChangeEventData,
5
+ TextInputProps,
7
6
  TextStyle,
8
7
  View,
9
8
  ViewStyle,
@@ -79,9 +78,9 @@ export interface CometChatMessageInputInterface {
79
78
  /**
80
79
  * Callback for when the text selection changes.
81
80
  *
82
- * @param {NativeSyntheticEvent<TextInputSelectionChangeEventData>} event - The selection change event.
81
+ * @param {NativeSyntheticEvent} event - The selection change event.
83
82
  */
84
- onSelectionChange?: (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void;
83
+ onSelectionChange?: TextInputProps["onSelectionChange"];
85
84
  /**
86
85
  * Reference for the TextInput component.
87
86
  *
@@ -9,6 +9,7 @@ import {
9
9
  LayoutChangeEvent,
10
10
  TextLayoutEvent,
11
11
  Platform,
12
+ StyleSheet,
12
13
  } from "react-native";
13
14
  import {
14
15
  CometChatMentionsFormatter,
@@ -48,6 +49,32 @@ export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
48
49
  );
49
50
  };
50
51
 
52
+ const FONT_METRIC_KEYS = ["fontWeight", "fontStyle", "fontFamily", "fontSize"] as const;
53
+
54
+ /** True when some element in the tree sets its own font (bold, italic, code, a mention chip…). */
55
+ function hasNestedFontStyle(node: React.ReactNode): boolean {
56
+ if (Array.isArray(node)) return node.some(hasNestedFontStyle);
57
+ if (!React.isValidElement(node)) return false;
58
+ const props: any = node.props;
59
+ const style = StyleSheet.flatten(props.style) as TextStyle | undefined;
60
+ if (style && FONT_METRIC_KEYS.some((key) => style[key] != null)) return true;
61
+ return hasNestedFontStyle(props.children);
62
+ }
63
+
64
+ /**
65
+ * On Android a lineHeight makes the text a wrapping (non-boring) layout, and with nested font
66
+ * styles React Native sizes the Text a fraction narrower than the styled text draws: the last
67
+ * word of `**Tom & Jerry**` wraps onto a line the bubble has no room for and "Jerry" disappears.
68
+ * Such content uses the font's own line spacing instead; plain text keeps the theme's lineHeight.
69
+ */
70
+ function withMeasurableLineHeight(
71
+ textStyle: StyleProp<TextStyle> | undefined,
72
+ content: React.ReactNode
73
+ ): StyleProp<TextStyle> | undefined {
74
+ if (Platform.OS !== "android" || !hasNestedFontStyle(content)) return textStyle;
75
+ return [textStyle, { lineHeight: undefined }];
76
+ }
77
+
51
78
  /**
52
79
  * Recursively apply textStyle to all Text elements within a tree.
53
80
  * Needed for View-based content (blockquotes, lists) where Text nodes
@@ -112,6 +139,11 @@ export const CometChatTextBubbleText = (
112
139
  return finalText as string | JSX.Element;
113
140
  }, [text, textFormatters]);
114
141
 
142
+ const contentTextStyle = useMemo(
143
+ () => withMeasurableLineHeight(textStyle, formattedText),
144
+ [textStyle, formattedText]
145
+ );
146
+
115
147
  // Reset state only when text actually changes
116
148
  useLayoutEffect(() => {
117
149
  if (lastTextRef.current !== text) {
@@ -192,9 +224,9 @@ export const CometChatTextBubbleText = (
192
224
  if (!viewChildren) return null;
193
225
  return viewChildren.map((child) => {
194
226
  if (!React.isValidElement(child)) return child;
195
- return applyTextStyleDeep(child as React.ReactElement<any>, textStyle);
227
+ return applyTextStyleDeep(child as React.ReactElement<any>, contentTextStyle);
196
228
  });
197
- }, [viewChildren, textStyle]);
229
+ }, [viewChildren, contentTextStyle]);
198
230
 
199
231
  // Only measure string content via onTextLayout — View-based uses child count instead
200
232
  const needsMeasurement = containerWidth !== null && !isViewBased && !measuredCacheRef.current[hiddenTextKey];
@@ -207,7 +239,7 @@ export const CometChatTextBubbleText = (
207
239
  key={hiddenTextKey}
208
240
  style={[
209
241
  { position: "absolute", left: 0, top: -10000, width: containerWidth!, opacity: 0 },
210
- textStyle as any,
242
+ contentTextStyle as any,
211
243
  ]}
212
244
  onTextLayout={onMeasuredTextLayout}
213
245
  accessible={false}
@@ -224,7 +256,7 @@ export const CometChatTextBubbleText = (
224
256
  </View>
225
257
  ) : (
226
258
  <Text
227
- style={textStyle}
259
+ style={contentTextStyle}
228
260
  numberOfLines={isExpanded ? undefined : collapseLines}
229
261
  ellipsizeMode='tail'
230
262
  >
@@ -115,7 +115,8 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
115
115
  };
116
116
 
117
117
  useEffect(() => {
118
- statusListener = eventEmitter.addListener("status", (data) => {
118
+ statusListener = eventEmitter.addListener("status", (event) => {
119
+ const data = event as { url?: string; state?: string };
119
120
  if (data["url"] == videoUrl && data["state"] == "downloading") {
120
121
  setOpening(true);
121
122
  }