@cometchat/chat-uikit-react-native 4.3.2 → 4.3.4

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 (118) hide show
  1. package/android/src/main/AndroidManifest.xml +3 -4
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
  4. package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
  5. package/ios/CommonUtil.h +4 -0
  6. package/ios/CommonUtil.m +27 -0
  7. package/package.json +1 -1
  8. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
  9. package/src/CometChatConversations/CometChatConversations.tsx +151 -66
  10. package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
  11. package/src/CometChatConversations/style.ts +5 -1
  12. package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
  13. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +598 -63
  14. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
  15. package/src/CometChatMessageComposer/resources/Info.png +0 -0
  16. package/src/CometChatMessageComposer/resources/index.ts +3 -1
  17. package/src/CometChatMessageHeader/listners.ts +0 -2
  18. package/src/CometChatMessageList/CometChatMessageList.tsx +139 -30
  19. package/src/CometChatMessageList/MessageListConfiguration.ts +19 -6
  20. package/src/CometChatMessages/CometChatMessages.tsx +16 -16
  21. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +41 -3
  22. package/src/calls/CallingExtentionDecorator.tsx +5 -5
  23. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
  24. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
  25. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
  26. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
  27. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
  28. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +51 -15
  29. package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
  30. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
  31. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
  32. package/src/extensions/Polls/Polls.tsx +106 -70
  33. package/src/extensions/Polls/PollsDecorator.tsx +3 -2
  34. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
  35. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
  36. package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
  37. package/src/index.ts +29 -8
  38. package/src/shared/CometChatUiKit/CometChatUIKit.ts +146 -24
  39. package/src/shared/CometChatUiKit/index.ts +1 -1
  40. package/src/shared/base/vars.ts +13 -0
  41. package/src/shared/constants/UIKitConstants.ts +6 -0
  42. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
  43. package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
  44. package/src/shared/events/CometChatUIEvents.ts +3 -1
  45. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
  46. package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
  48. package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
  50. package/src/shared/formatters/index.ts +11 -0
  51. package/src/shared/framework/DataSource.ts +21 -16
  52. package/src/shared/framework/DataSourceDecorator.tsx +29 -13
  53. package/src/shared/framework/MessageDataSource.tsx +215 -49
  54. package/src/shared/helper/useKeyboard.tsx +20 -2
  55. package/src/shared/index.ts +31 -11
  56. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
  57. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
  58. package/src/shared/libs/ImageZoom/helper.ts +144 -0
  59. package/src/shared/libs/ImageZoom/index.tsx +13 -0
  60. package/src/shared/libs/ImageZoom/types/index.ts +186 -0
  61. package/src/shared/libs/VideoPlayer/Video.js +0 -24
  62. package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
  63. package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
  64. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
  65. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
  66. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
  67. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
  68. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
  69. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
  70. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
  71. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
  72. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
  73. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
  74. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
  75. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
  76. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
  77. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
  78. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
  79. package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
  80. package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
  81. package/src/shared/utils/NetworkUtils.tsx +5 -0
  82. package/src/shared/utils/PermissionUtil.ts +142 -0
  83. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  84. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
  85. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
  86. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
  87. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +70 -22
  88. package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
  89. package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
  90. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
  91. package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
  92. package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
  93. package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
  94. package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
  95. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  96. package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
  97. package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
  98. package/src/shared/views/CometChatReactionList/index.ts +12 -0
  99. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
  100. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
  101. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
  102. package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
  103. package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
  104. package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
  105. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
  106. package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
  107. package/src/shared/views/CometChatTextBubble/index.ts +2 -3
  108. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +6 -4
  109. package/src/shared/views/index.ts +14 -8
  110. package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
  111. package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
  112. package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
  113. package/src/shared/utils/PermissionUtilIOS.ts +0 -104
  114. package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
  115. package/src/shared/views/CometChatReactionsList/index.ts +0 -12
  116. /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
  117. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
  118. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useState } from 'react';
1
+ import React, { useContext, useEffect, useLayoutEffect } from 'react';
2
2
  import {
3
3
  View,
4
4
  Image,
@@ -8,6 +8,8 @@ import {
8
8
  KeyboardAvoidingView,
9
9
  Modal,
10
10
  KeyboardAvoidingViewProps,
11
+ Dimensions,
12
+ Text,
11
13
  } from 'react-native';
12
14
  import { Style } from './styles';
13
15
  import {
@@ -19,6 +21,13 @@ import {
19
21
  CometChatActionSheet,
20
22
  ActionSheetStyles,
21
23
  CometChatContext,
24
+ CometChatMentionsFormatter,
25
+ CometChatUrlsFormatter,
26
+ CometChatTextFormatter,
27
+ MentionTextStyle,
28
+ CometChatSuggestionList,
29
+ SuggestionItem,
30
+ CometChatUIKit,
22
31
  } from '../shared';
23
32
 
24
33
  import { CheckPropertyExists } from '../shared/helper/functions';
@@ -51,8 +60,10 @@ import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandle
51
60
  import { CometChatMessageComposerActionInterface } from '../shared/helper/types';
52
61
  import { CometChatMediaRecorder, MediaRecorderStyle } from '../shared/views/CometChatMediaRecorder';
53
62
  import { AIOptionsStyle } from '../AI/AIOptionsStyle';
54
- import { permissionUtilIOS } from '../shared/utils/PermissionUtilIOS';
55
- const { FileManager } = NativeModules;
63
+ import { CommonUtils } from '../shared/utils/CommonUtils';
64
+ import { permissionUtil } from '../shared/utils/PermissionUtil';
65
+ import { commonVars } from '../shared/base/vars';
66
+ const { FileManager, CommonUtil } = NativeModules;
56
67
 
57
68
  const uiEventListenerShow = 'uiEvent_show_' + new Date().getTime();
58
69
  const uiEventListenerHide = 'uiEvent_hide_' + new Date().getTime();
@@ -218,7 +229,7 @@ const LiveReaction = (props: any) => {
218
229
  let recordedTime = 0, timerIntervalId = null;
219
230
 
220
231
  export interface MessageComposerStyleInterface extends BaseStyle {
221
- attachIcontint?: string;
232
+ attachIconTint?: string;
222
233
  sendIconTint?: string;
223
234
  inputBackground?: string;
224
235
  inputBorder?: BorderStyleInterface;
@@ -234,6 +245,12 @@ export interface MessageComposerStyleInterface extends BaseStyle {
234
245
  actionSheetLayoutModeIconTint?: string;
235
246
  actionSheetCancelButtonIconTint?: string;
236
247
  }
248
+ type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N
249
+ ? Acc[number]
250
+ : Enumerate<N, [...Acc, Acc['length']]>
251
+
252
+ type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>
253
+
237
254
  export interface CometChatMessageComposerInterface {
238
255
  /**
239
256
  *
@@ -504,10 +521,21 @@ export interface CometChatMessageComposerInterface {
504
521
  * AI Options Style.
505
522
  */
506
523
  aiOptionsStyle?: AIOptionsStyle;
507
- /**
508
- * To override keyboardAvoidingViewProps.
509
- */
524
+ /**
525
+ * To override keyboardAvoidingViewProps.
526
+ */
510
527
  keyboardAvoidingViewProps?: KeyboardAvoidingViewProps
528
+ /**
529
+ * Collection of text formatter class
530
+ * @type {Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>}
531
+ */
532
+ textFormatters?: Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>;
533
+ disableMentions?: boolean;
534
+ /*
535
+ * To manually manage image quality taken from the camera (100 means no compression).
536
+ * @default 20
537
+ */
538
+ imageQuality?: IntRange<1, 100>
511
539
  }
512
540
  export const CometChatMessageComposer = React.forwardRef(
513
541
  (props: CometChatMessageComposerInterface, ref) => {
@@ -551,7 +579,10 @@ export const CometChatMessageComposer = React.forwardRef(
551
579
  submitIconUrl,
552
580
  AIIconURL,
553
581
  aiOptionsStyle,
554
- keyboardAvoidingViewProps
582
+ keyboardAvoidingViewProps,
583
+ textFormatters,
584
+ disableMentions,
585
+ imageQuality = 20
555
586
  } = props;
556
587
 
557
588
  const defaultAttachmentOptions =
@@ -571,8 +602,16 @@ export const CometChatMessageComposer = React.forwardRef(
571
602
  const chatWithId = React.useRef<any>(null);
572
603
  const messageInputRef = React.useRef<any>(null);
573
604
  const chatRef = React.useRef<any>(chatWith);
605
+ const inputValueRef = React.useRef<any>(null);
606
+ const plainTextInput = React.useRef<string>("");
607
+ let mentionMap = React.useRef<Map<string, SuggestionItem>>(new Map());
608
+ let trackingCharacters = React.useRef<string[]>([])
609
+ let allFormatters = React.useRef<Map<string, CometChatTextFormatter | CometChatMentionsFormatter>>(new Map());
610
+ let activeCharacter = React.useRef("")
611
+ let searchStringRef = React.useRef("");
612
+
574
613
  const [selectionPosition, setSelectionPosition] = React.useState<any>({});
575
- const [inputMessage, setInputMessage] = React.useState(text || '');
614
+ const [inputMessage, setInputMessage] = React.useState<string | JSX.Element>(text || '');
576
615
  const [showReaction, setShowReaction] = React.useState(false);
577
616
  const [showEmojiboard, setShowEmojiboard] = React.useState(false);
578
617
  const [showActionSheet, setShowActionSheet] = React.useState(false);
@@ -586,9 +625,29 @@ export const CometChatMessageComposer = React.forwardRef(
586
625
  const [CustomViewHeader, setCustomViewHeader] = React.useState(null);
587
626
  const [CustomViewFooter, setCustomViewFooter] = React.useState(null);
588
627
  const [isVisible, setIsVisible] = React.useState(false);
628
+ const [kbOffset, setKbOffset] = React.useState(59);
629
+ const [showMentionList, setShowMentionList] = React.useState(false);
630
+ const [mentionsSearchData, setMentionsSearchData] = React.useState<Array<SuggestionItem>>([]);
631
+ const [suggestionListLoader, setSuggestionListLoader] = React.useState(false);
589
632
 
590
633
  const bottomSheetRef = React.useRef<any>(null);
591
634
 
635
+ useLayoutEffect(() => {
636
+ if (Platform.OS === "ios") {
637
+ if (Number.isInteger(commonVars.safeAreaInsets.top)) {
638
+ setKbOffset(commonVars.safeAreaInsets.top)
639
+ return;
640
+ }
641
+ CommonUtil.getSafeAreaInsets().then(res => {
642
+ if (Number.isInteger(res.top)) {
643
+ commonVars.safeAreaInsets.top = res.top;
644
+ commonVars.safeAreaInsets.bottom = res.bottom;
645
+ setKbOffset(res.top)
646
+ }
647
+ })
648
+ }
649
+ }, []);
650
+
592
651
  const AIStyles = new AIOptionsStyle({
593
652
  //NEED TO ADD DEFAULT STYLE HERE
594
653
  backgroundColor: theme.palette.getBackgroundColor(),
@@ -612,50 +671,122 @@ export const CometChatMessageComposer = React.forwardRef(
612
671
 
613
672
  const previewMessage = ({ message, status }: any) => {
614
673
  if (status === messageStatus.inprogress) {
674
+
675
+ let textComponents = message?.text;
676
+
677
+ let rawText = message?.text;
678
+
679
+ let users: { key: string, value: SuggestionItem } = {};
680
+ let regexes: Array<RegExp> = [];
681
+
682
+ allFormatters.current.forEach((formatter: CometChatTextFormatter, key) => {
683
+ formatter.handleComposerPreview(message);
684
+ if (!regexes.includes(formatter.getRegexPattern())) {
685
+ regexes.push(formatter.getRegexPattern());
686
+ }
687
+ let suggestionUsers = formatter.getSuggestionItems();
688
+ suggestionUsers.forEach(item => users[item.underlyingText] = item);
689
+ let resp = formatter.getFormattedText(textComponents);
690
+ textComponents = resp;
691
+ })
692
+
693
+ let edits = [];
694
+
695
+ regexes.forEach(regex => {
696
+ let match;
697
+ while ((match = regex.exec(rawText)) !== null) {
698
+ const user = users[match[0]];
699
+ if (user) {
700
+ edits.push({
701
+ startIndex: match.index,
702
+ endIndex: regex.lastIndex,
703
+ replacement: user.promptText,
704
+ user
705
+ });
706
+ }
707
+ }
708
+ });
709
+
710
+ // Sort edits by startIndex to apply them in order
711
+ edits.sort((a, b) => a.startIndex - b.startIndex);
712
+
713
+ plainTextInput.current = getPlainString(message?.text, edits)
714
+
715
+ const hashMap = new Map();
716
+ let offset = 0; // Tracks shift in position due to replacements
717
+
718
+ edits.forEach(edit => {
719
+ const adjustedStartIndex = edit.startIndex + offset;
720
+ rawText = rawText.substring(0, adjustedStartIndex) + edit.replacement + rawText.substring(edit.endIndex);
721
+ offset += edit.replacement.length - (edit.endIndex - edit.startIndex);
722
+ const rangeKey = `${adjustedStartIndex}_${adjustedStartIndex + edit.replacement.length}`;
723
+ hashMap.set(rangeKey, edit.user);
724
+ });
725
+
726
+ mentionMap.current = hashMap;
727
+
615
728
  setMessagePreview({
616
- message: message,
729
+ message: { ...message, text: textComponents },
617
730
  mode: ConversationOptionConstants.edit,
618
731
  });
619
732
 
620
- setInputMessage(message.text ?? '');
733
+ inputValueRef.current = textComponents ?? '';
734
+ setInputMessage(textComponents ?? '');
621
735
  messageInputRef.current.focus();
622
736
  }
623
737
  };
624
738
 
739
+ const cameraCallback = async (cameraImage: any) => {
740
+ if (CheckPropertyExists(cameraImage, 'error')) {
741
+ return;
742
+ }
743
+ const { name, uri, type } = cameraImage;
744
+ let file = {
745
+ name,
746
+ type,
747
+ uri,
748
+ };
749
+ sendMediaMessage(
750
+ chatWithId.current,
751
+ file,
752
+ MessageTypeConstants.image,
753
+ chatWith.current
754
+ );
755
+ }
756
+
625
757
  const fileInputHandler = async (fileType: string) => {
626
758
  if (fileType === MessageTypeConstants.takePhoto) {
627
- if (!(await permissionUtilIOS.startResourceBasedTask(["camera"]))) {
759
+ if (!(await permissionUtil.startResourceBasedTask(["camera"]))) {
628
760
  return;
629
761
  }
630
- FileManager.openCamera(fileType, async (cameraImage: any) => {
631
- if (CheckPropertyExists(cameraImage, 'error')) {
632
- return;
633
- }
634
- const { name, uri, type } = cameraImage;
635
- let file = {
636
- name,
637
- type,
638
- uri,
639
- };
640
- sendMediaMessage(
641
- chatWithId.current,
642
- file,
643
- MessageTypeConstants.image,
644
- chatWith.current
762
+ let quality = imageQuality
763
+ if (isNaN(imageQuality) || imageQuality < 1 || imageQuality > 100) {
764
+ quality = 20
765
+ }
766
+ if (Platform.OS === "android") {
767
+ FileManager.openCamera(
768
+ fileType,
769
+ Math.round(quality),
770
+ cameraCallback
771
+ );
772
+ } else {
773
+ FileManager.openCamera(
774
+ fileType,
775
+ cameraCallback
645
776
  );
646
- });
647
- }
648
- else if (Platform.OS === 'ios' && fileType === MessageTypeConstants.video) {
649
- NativeModules.VideoPickerModule.pickVideo(((file) => {
650
- if(file.uri)
651
- sendMediaMessage(
652
- chatWithId.current,
653
- file,
654
- MessageTypeConstants.video,
655
- chatWith.current
656
- );
657
- }))
658
777
  }
778
+ }
779
+ else if (Platform.OS === 'ios' && fileType === MessageTypeConstants.video) {
780
+ NativeModules.VideoPickerModule.pickVideo(((file) => {
781
+ if (file.uri)
782
+ sendMediaMessage(
783
+ chatWithId.current,
784
+ file,
785
+ MessageTypeConstants.video,
786
+ chatWith.current
787
+ );
788
+ }))
789
+ }
659
790
  else
660
791
  FileManager.openFileChooser(fileType, async (fileInfo: any) => {
661
792
  if (CheckPropertyExists(fileInfo, 'error')) {
@@ -689,12 +820,6 @@ export const CometChatMessageComposer = React.forwardRef(
689
820
  }
690
821
  };
691
822
 
692
- const textChangeHandler = (txt: string) => {
693
- onChangeText && onChangeText(txt);
694
- startTyping();
695
- setInputMessage(txt);
696
- };
697
-
698
823
  const liveReactionHandler = () => {
699
824
  if (hideLiveReaction) return;
700
825
  if (!showReaction) {
@@ -726,6 +851,7 @@ export const CometChatMessageComposer = React.forwardRef(
726
851
  };
727
852
 
728
853
  const clearInputBox = () => {
854
+ inputValueRef.current = '';
729
855
  setInputMessage('');
730
856
  };
731
857
 
@@ -737,20 +863,29 @@ export const CometChatMessageComposer = React.forwardRef(
737
863
  return;
738
864
  }
739
865
 
866
+ let finalTextInput = getRegexString(plainTextInput.current);
867
+
740
868
  let textMessage = new CometChat.TextMessage(
741
869
  chatWithId.current,
742
- inputMessage,
870
+ finalTextInput,
743
871
  chatWith.current
744
872
  );
745
873
 
746
874
  textMessage.setSender(loggedInUser.current);
747
875
  textMessage.setReceiver(chatWith.current);
748
- textMessage.setText(inputMessage);
876
+ textMessage.setText(finalTextInput);
749
877
  textMessage.setMuid(String(getUnixTimestamp()));
750
878
  parentMessageId && textMessage.setParentMessageId(parentMessageId as number);
751
879
 
880
+ allFormatters.current.forEach(item => {
881
+ textMessage = item.handlePreMessageSend(textMessage);
882
+ })
883
+
884
+ setMentionsSearchData([]);
885
+ plainTextInput.current = ""
886
+
752
887
  onSendButtonPress && onSendButtonPress(textMessage);
753
- if (inputMessage.trim().length == 0) {
888
+ if (finalTextInput.trim().length == 0) {
754
889
  return;
755
890
  }
756
891
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
@@ -772,7 +907,7 @@ export const CometChatMessageComposer = React.forwardRef(
772
907
  })
773
908
  .catch((error: any) => {
774
909
  onError && onError(error);
775
- textMessage.data.metaData = {error: true}
910
+ textMessage.data.metaData = { error: true }
776
911
  CometChatUIEventHandler.emitMessageEvent(
777
912
  MessageEvents.ccMessageSent,
778
913
  {
@@ -788,7 +923,9 @@ export const CometChatMessageComposer = React.forwardRef(
788
923
  const editMessage = (message: any) => {
789
924
  endTyping(null, null);
790
925
 
791
- let messageText = inputMessage.trim();
926
+ let finalTextInput = getRegexString(plainTextInput.current);
927
+
928
+ let messageText = finalTextInput.trim();
792
929
  let textMessage = new CometChat.TextMessage(
793
930
  chatWithId.current,
794
931
  messageText,
@@ -797,6 +934,7 @@ export const CometChatMessageComposer = React.forwardRef(
797
934
  textMessage.setId(message.id);
798
935
  parentMessageId && textMessage.setParentMessageId(parentMessageId as number);
799
936
 
937
+ inputValueRef.current = '';
800
938
  setInputMessage('');
801
939
  messageInputRef.current.textContent = '';
802
940
 
@@ -806,6 +944,7 @@ export const CometChatMessageComposer = React.forwardRef(
806
944
 
807
945
  CometChat.editMessage(textMessage)
808
946
  .then((editedMessage: any) => {
947
+ inputValueRef.current = '';
809
948
  setInputMessage('');
810
949
  CometChatUIEventHandler.emitMessageEvent(
811
950
  MessageEvents.ccMessageEdited,
@@ -907,7 +1046,7 @@ export const CometChatMessageComposer = React.forwardRef(
907
1046
  .catch((error: any) => {
908
1047
  setShowRecordAudio(false);
909
1048
  onError && onError(error);
910
- localMessage.data.metaData = {error: true}
1049
+ localMessage.data.metaData = { error: true }
911
1050
  CometChatUIEventHandler.emitMessageEvent(
912
1051
  MessageEvents.ccMessageSent,
913
1052
  {
@@ -1020,12 +1159,12 @@ export const CometChatMessageComposer = React.forwardRef(
1020
1159
  imageStyle={[
1021
1160
  Style.imageStyle,
1022
1161
  {
1023
- tintColor: !inputMessage.length ? theme.palette.getAccent400() :
1162
+ tintColor: ((inputMessage as String).length === 0) ? theme.palette.getAccent400() :
1024
1163
  messageComposerStyle.sendIconTint ||
1025
1164
  theme.palette.getPrimary(),
1026
1165
  },
1027
1166
  ]}
1028
- disable={!inputMessage.length}
1167
+ disable={((inputMessage as String).length === 0)}
1029
1168
  onClick={sendTextMessage}
1030
1169
  />
1031
1170
  );
@@ -1045,15 +1184,15 @@ export const CometChatMessageComposer = React.forwardRef(
1045
1184
  height: 23,
1046
1185
  width: 23,
1047
1186
  resizeMode: 'contain',
1048
- tintColor: messageComposerStyle.attachIcontint
1049
- ? messageComposerStyle.attachIcontint
1187
+ tintColor: messageComposerStyle.attachIconTint
1188
+ ? messageComposerStyle.attachIconTint
1050
1189
  : theme.palette.getAccent(),
1051
1190
  }}
1052
1191
  />
1053
1192
  );
1054
1193
  };
1055
1194
  const PrimaryButtonView = () => {
1056
- return inputMessage.length || hideLiveReaction ? (
1195
+ return ((inputMessage as String).length !== 0) || hideLiveReaction ? (
1057
1196
  <SendButtonViewElem />
1058
1197
  ) : (
1059
1198
  <View>
@@ -1090,6 +1229,37 @@ export const CometChatMessageComposer = React.forwardRef(
1090
1229
  //fetch logged in user
1091
1230
  useEffect(() => {
1092
1231
  CometChat.getLoggedinUser().then((user) => (loggedInUser.current = user));
1232
+ let _formatter = [...(textFormatters || [])] || [];
1233
+
1234
+ if (!disableMentions) {
1235
+ let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
1236
+ mentionsFormatter.setLoggedInUser(CometChatUIKit.loggedInUser);
1237
+ mentionsFormatter.setMentionsStyle(new MentionTextStyle({
1238
+ loggedInUserTextStyle: {
1239
+ color: theme.palette.getPrimary(),
1240
+ ...theme.typography.title2,
1241
+ fontSize: 17
1242
+ },
1243
+ textStyle: {
1244
+ color: theme.palette.getPrimary(),
1245
+ ...theme.typography.subtitle1,
1246
+ fontSize: 17
1247
+ }
1248
+ }));
1249
+ mentionsFormatter.setUser(user);
1250
+ mentionsFormatter.setGroup(group);
1251
+
1252
+ _formatter.push(mentionsFormatter)
1253
+ }
1254
+
1255
+ _formatter.forEach((formatter) => {
1256
+ formatter.setComposerId(id);
1257
+ let trackingCharacter = formatter.getTrackingCharacter();
1258
+ trackingCharacters.current.push(trackingCharacter);
1259
+
1260
+ let newFormatter = CommonUtils.clone(formatter);
1261
+ allFormatters.current.set(trackingCharacter, newFormatter);
1262
+ })
1093
1263
  }, []);
1094
1264
 
1095
1265
  useEffect(() => {
@@ -1218,9 +1388,16 @@ export const CometChatMessageComposer = React.forwardRef(
1218
1388
  setIsVisible(false);
1219
1389
  bottomSheetRef.current?.togglePanel();
1220
1390
 
1391
+ inputValueRef.current = text?.text;
1221
1392
  setInputMessage(text?.text)
1222
1393
 
1223
- }
1394
+ },
1395
+ ccSuggestionData(item: { id: string | number, data: Array<SuggestionItem> }) {
1396
+ if (activeCharacter.current && id === item?.id) {
1397
+ setMentionsSearchData(item?.data);
1398
+ setSuggestionListLoader(false);
1399
+ }
1400
+ },
1224
1401
  })
1225
1402
  return () => {
1226
1403
  CometChatUIEventHandler.removeMessageListener(editMessageListenerID);
@@ -1271,6 +1448,330 @@ export const CometChatMessageComposer = React.forwardRef(
1271
1448
  console.log("Send Audio");
1272
1449
  }
1273
1450
 
1451
+ function isCursorWithinMentionRange(mentionRanges, cursorPosition) {
1452
+ for (let [range, mention] of mentionRanges) {
1453
+ const [start, end] = range.split('_').map(Number);
1454
+ if (cursorPosition >= start && cursorPosition <= end) {
1455
+ return true; // Cursor is within the range of a mention
1456
+ }
1457
+ }
1458
+ return false; // No mention found at the cursor position
1459
+ }
1460
+
1461
+ function shouldOpenList(selection: {
1462
+ start: number;
1463
+ end: number;
1464
+ }, searchString: string, tracker: string) {
1465
+ return (selection.start === selection.end
1466
+ && !isCursorWithinMentionRange(mentionMap.current, selection.start - searchString.length)
1467
+ && trackingCharacters.current.includes(tracker)
1468
+ && (searchString === "" ? ((plainTextInput.current[selection.start - 2]?.length === 1 && plainTextInput.current[selection.start - 2]?.trim()?.length === 0) || plainTextInput.current[selection.start - 2] === undefined) : true)
1469
+ && ((plainTextInput.current[selection.start - 1]?.length === 1 && plainTextInput.current[selection.start - 1]?.trim()?.length === 0) ? searchString.length > 0 : true)
1470
+ )
1471
+ }
1472
+
1473
+ let timeoutId;
1474
+ const openList = (selection: {
1475
+ start: number;
1476
+ end: number;
1477
+ }) => {
1478
+ clearTimeout(timeoutId);
1479
+ timeoutId = setTimeout(() => {
1480
+ let searchString = extractTextFromCursor(plainTextInput.current, selection.start);
1481
+ let tracker = searchString ? plainTextInput.current[selection.start - (searchString.length + 1)] : plainTextInput.current[selection.start - 1];
1482
+
1483
+ if (shouldOpenList(selection, searchString, tracker)) {
1484
+ activeCharacter.current = tracker;
1485
+ searchStringRef.current = searchString;
1486
+ setShowMentionList(true);
1487
+
1488
+ let formatter = allFormatters.current.get(tracker);
1489
+ formatter.search(searchString);
1490
+
1491
+ } else {
1492
+ activeCharacter.current = "";
1493
+ searchStringRef.current = "";
1494
+ setShowMentionList(false);
1495
+ setMentionsSearchData([]);
1496
+ }
1497
+ }, 100);
1498
+ }
1499
+
1500
+ const getRegexString = (str: string) => {
1501
+ // Get an array of the entries in the map using the spread operator
1502
+ const entries = [...mentionMap.current.entries()].reverse();
1503
+
1504
+ let uidInput = str;
1505
+
1506
+ // Iterate over the array in reverse order
1507
+ entries.forEach(([key, value]) => {
1508
+
1509
+ let [start, end] = key.split("_").map(Number);
1510
+
1511
+ let pre = uidInput.substring(0, start);
1512
+ let post = uidInput.substring(end);
1513
+
1514
+ uidInput = pre + value.underlyingText + post;
1515
+
1516
+ });
1517
+
1518
+ return uidInput;
1519
+
1520
+ }
1521
+
1522
+ const getPlainString = (str: string, edits: Array<{
1523
+ "endIndex": number,
1524
+ "replacement": string,
1525
+ "startIndex": number,
1526
+ "user": SuggestionItem
1527
+ }>) => {
1528
+ // Get an array of the entries in the map using the spread operator
1529
+ const entries = [...edits].reverse();
1530
+
1531
+ let _plainString = str;
1532
+
1533
+ // Iterate over the array in reverse order
1534
+ entries.forEach(({ endIndex, replacement, startIndex, user }) => {
1535
+
1536
+ let pre = _plainString.substring(0, startIndex);
1537
+ let post = _plainString.substring(endIndex);
1538
+
1539
+ _plainString = pre + replacement + post;
1540
+
1541
+ });
1542
+
1543
+ return _plainString;
1544
+
1545
+ }
1546
+
1547
+ const textChangeHandler = (txt: string) => {
1548
+ let removing = plainTextInput.current.length > txt.length;
1549
+ let adding = plainTextInput.current.length < txt.length;
1550
+ let textDiff = txt.length - plainTextInput.current.length;
1551
+ let notAtLast = (selectionPosition.start + textDiff) < txt.length;
1552
+
1553
+ plainTextInput.current = txt;
1554
+ onChangeText && onChangeText(txt);
1555
+ startTyping();
1556
+
1557
+ let decr = 0;
1558
+
1559
+ let newMentionMap = new Map(mentionMap.current);
1560
+
1561
+ mentionMap.current.forEach((value, key) => {
1562
+ let position = { start: parseInt(key.split("_")[0]), end: parseInt(key.split("_")[1]) };
1563
+
1564
+ //Runs when cursor before the mention and before the last position
1565
+
1566
+ if (notAtLast && (((selectionPosition.start - 1) <= position.start)
1567
+ || ((selectionPosition.start - textDiff) <= position.start)
1568
+ )) {
1569
+ if (removing) {
1570
+ decr = ((selectionPosition.end) - selectionPosition.start) - (textDiff);
1571
+ position = { start: position.start - decr, end: position.end - decr };
1572
+ } else if (adding) {
1573
+ decr = ((selectionPosition.end) - selectionPosition.start) + (textDiff);
1574
+ position = { start: position.start + decr, end: position.end + decr };
1575
+ }
1576
+ if (removing || adding) {
1577
+ let newKey = `${position.start}_${position.end}`;
1578
+ position.start >= 0 && newMentionMap.set(newKey, value);
1579
+ newMentionMap.delete(key);
1580
+ }
1581
+ }
1582
+
1583
+ // Code to delete mention from hashmap 👇
1584
+ let expctedMentionPos = plainTextInput.current.substring(position.start, position.end);
1585
+
1586
+ if (expctedMentionPos !== `${value.promptText}`) {
1587
+ let newKey = `${position.start}_${position.end}`;
1588
+ newMentionMap.delete(newKey);
1589
+
1590
+ if (!ifIdExists(value.id, newMentionMap)) {
1591
+ let targetedFormatter = allFormatters.current.get(value.trackingCharacter);
1592
+ let existingCCUsers = [...targetedFormatter.getSuggestionItems()];
1593
+ let userPosition = existingCCUsers.findIndex((item: SuggestionItem) => item.id === value.id);
1594
+ if (userPosition !== -1) {
1595
+ existingCCUsers.splice(userPosition, 1);
1596
+ (targetedFormatter as CometChatMentionsFormatter).setSuggestionItems(existingCCUsers)
1597
+ }
1598
+ }
1599
+
1600
+ }
1601
+
1602
+ });
1603
+
1604
+ mentionMap.current = newMentionMap;
1605
+
1606
+ setFormattedInputMessage();
1607
+
1608
+ };
1609
+
1610
+ const onMentionPress = (item: SuggestionItem) => {
1611
+ setShowMentionList(false);
1612
+ setMentionsSearchData([]);
1613
+
1614
+ let notAtLast = selectionPosition.start < plainTextInput.current.length;
1615
+
1616
+ let textDiff = (plainTextInput.current.length + item.promptText.length - searchStringRef.current.length) - plainTextInput.current.length;
1617
+
1618
+ let incr = 0;
1619
+ let mentionPos = 0;
1620
+
1621
+ let newMentionMap = new Map(mentionMap.current);
1622
+
1623
+ let targetedFormatter = allFormatters.current.get(activeCharacter.current);
1624
+
1625
+ let existingCCUsers = [...targetedFormatter.getSuggestionItems()];
1626
+ let userAlreadyExists = existingCCUsers.find((existingUser: SuggestionItem) => existingUser.id === item.id);
1627
+ if (!userAlreadyExists) {
1628
+ let cometchatUIUserArray: Array<SuggestionItem> = [...existingCCUsers];
1629
+ cometchatUIUserArray.push(item);
1630
+ (targetedFormatter as CometChatMentionsFormatter).setSuggestionItems(cometchatUIUserArray)
1631
+ }
1632
+ mentionMap.current.forEach((value, key) => {
1633
+ let position = { start: parseInt(key.split("_")[0]), end: parseInt(key.split("_")[1]) };
1634
+
1635
+ if (!(selectionPosition.start <= position.start)) {
1636
+ mentionPos += 1;
1637
+ }
1638
+
1639
+ // Code to delete mention from hashmap 👇
1640
+ if (position.end === selectionPosition.end || (selectionPosition.start > position.start && selectionPosition.end <= position.end)) {
1641
+ let newKey = `${position.start}_${position.end}`;
1642
+ newMentionMap.delete(newKey);
1643
+ mentionPos -= 1
1644
+ }
1645
+
1646
+ if (notAtLast && ((selectionPosition.start - 1) <= position.start)) {
1647
+ incr = (selectionPosition.end - selectionPosition.start) + (textDiff);
1648
+ let newKey = `${(position.start + incr)}_${(position.end + incr)}`;
1649
+ newMentionMap.set(newKey, value);
1650
+ newMentionMap.delete(key);
1651
+ }
1652
+
1653
+ });
1654
+ mentionMap.current = newMentionMap;
1655
+
1656
+ // When updating the input text, just get the latest plain text input and replace the selected text with the new mention
1657
+ const updatedPlainTextInput = `${plainTextInput.current.substring(0, (selectionPosition.start - (1 + searchStringRef.current.length)))}${item.promptText + " "}${plainTextInput.current.substring(
1658
+ (selectionPosition.end),
1659
+ plainTextInput.current.length
1660
+ )}`;
1661
+ plainTextInput.current = updatedPlainTextInput;
1662
+
1663
+ let key = (selectionPosition.start - (1 + searchStringRef.current.length)) + "_" + ((selectionPosition.start - (searchStringRef.current.length + 1)) + item.promptText.length);
1664
+
1665
+ let updatedMap = insertMentionAt(mentionMap.current, mentionPos, key, { ...item, trackingCharacter: activeCharacter.current });
1666
+ mentionMap.current = updatedMap;
1667
+
1668
+ setFormattedInputMessage()
1669
+
1670
+ }
1671
+
1672
+ const setFormattedInputMessage = () => {
1673
+ let textComponents = getRegexString(plainTextInput.current);
1674
+
1675
+ allFormatters.current.forEach((formatter: CometChatMentionsFormatter, key) => {
1676
+ let resp = formatter.getFormattedText(textComponents);
1677
+ textComponents = resp;
1678
+ })
1679
+
1680
+ inputValueRef.current = textComponents;
1681
+ setInputMessage(textComponents);
1682
+ }
1683
+
1684
+ function escapeRegExp(string: string) {
1685
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1686
+ }
1687
+
1688
+ function extractTextFromCursor(inputText: string, cursorPosition: number) {
1689
+ const leftText = inputText.substring(0, cursorPosition);
1690
+
1691
+ // Escape the mentionPrefixes to safely use them in a regex pattern
1692
+ const escapedPrefixes = trackingCharacters.current.map(escapeRegExp).join('|');
1693
+
1694
+ // Build a dynamic regex pattern that matches any of the mention prefixes.
1695
+ // This pattern will match a prefix followed by any combination of word characters
1696
+ // and spaces, including a trailing space.
1697
+ const mentionRegex = new RegExp(`(?:^|\\s)(${escapedPrefixes})([^${escapedPrefixes}\\s][^${escapedPrefixes}]*)$`);
1698
+ const match = leftText.match(mentionRegex);
1699
+
1700
+ // If a match is found, return the first capturing group, which is the username
1701
+ return match && substringUpToNthSpace(match[2], 4) || "";
1702
+ }
1703
+
1704
+ function substringUpToNthSpace(str: string, n: number) {
1705
+ // Split the string by spaces, slice to the (n-1) elements, and then rejoin with spaces
1706
+ return str.split(' ', n).join(' ');
1707
+ }
1708
+
1709
+ const insertMentionAt = (mentionMap: Map<string, SuggestionItem>, insertAt: number, key: string, value: SuggestionItem): Map<string, SuggestionItem> => {
1710
+ // Convert the hashmap to an array of [key, value] pairs
1711
+ let mentionsArray = Array.from(mentionMap);
1712
+
1713
+ // Insert the new mention into the array at the calculated index
1714
+ mentionsArray.splice(insertAt, 0, [key, value]);
1715
+
1716
+ return new Map(mentionsArray);
1717
+
1718
+ }
1719
+
1720
+ /**
1721
+ * Function to check if the id exists in the mentionMap
1722
+ */
1723
+ const ifIdExists = (id: string, hashmap: Map<string, SuggestionItem>) => {
1724
+ let exists = false;
1725
+ hashmap.forEach((value, key) => {
1726
+ if (value.id === id) {
1727
+ exists = true;
1728
+ }
1729
+ });
1730
+ return exists;
1731
+ }
1732
+
1733
+ const onSuggestionListEndReached = () => {
1734
+ let targetedFormatter = allFormatters.current.get(activeCharacter.current);
1735
+ if (!targetedFormatter) return;
1736
+ let fetchingNext = targetedFormatter.fetchNext();
1737
+ fetchingNext !== null && setSuggestionListLoader(true);
1738
+ }
1739
+
1740
+ const getMentionLimitView = () => {
1741
+ let targetedFormatter = allFormatters.current.get(activeCharacter.current);
1742
+ let shouldWarn;
1743
+ let limit;
1744
+ if (targetedFormatter?.getLimit && targetedFormatter?.getLimit()) {
1745
+ limit = targetedFormatter?.getLimit();
1746
+ if (targetedFormatter.getUniqueUsersList && targetedFormatter.getUniqueUsersList()?.size >= limit) {
1747
+ shouldWarn = true;
1748
+ }
1749
+ }
1750
+ if (!shouldWarn) return null;
1751
+ let errorString = targetedFormatter?.getErrorString ? targetedFormatter?.getErrorString() : `${localize("MENTION_UPTO")} ${limit} ${limit === 1 ? localize("TIME") : localize("TIMES")} ${localize("AT_A_TIME")}.`;
1752
+ return (
1753
+ <View style={{
1754
+ flexDirection: "row",
1755
+ alignItems: "center",
1756
+ paddingTop: 5,
1757
+ paddingLeft: 5,
1758
+ borderTopWidth: 1,
1759
+ borderTopColor: theme.palette.getAccent300()
1760
+ }}>
1761
+ <Image style={{
1762
+ tintColor: theme.palette.getAccent500(),
1763
+ height: 20,
1764
+ width: 20
1765
+ }} source={ICONS.INFO} />
1766
+ <Text style={{
1767
+ marginLeft: 5,
1768
+ color: theme.palette.getAccent500(),
1769
+ ...theme.typography.text1
1770
+ }}>{errorString}</Text>
1771
+ </View>
1772
+ )
1773
+ }
1774
+
1274
1775
  return (
1275
1776
  <>
1276
1777
  {!isVisible && typeof CustomView === "function" && <CustomView />}
@@ -1287,7 +1788,7 @@ export const CometChatMessageComposer = React.forwardRef(
1287
1788
  <KeyboardAvoidingView
1288
1789
  key={id}
1289
1790
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
1290
- keyboardVerticalOffset={Platform.select({ios: 60})}
1791
+ keyboardVerticalOffset={Platform.select({ios: kbOffset})}
1291
1792
  {...keyboardAvoidingViewProps}
1292
1793
  >
1293
1794
  <View
@@ -1304,11 +1805,12 @@ export const CometChatMessageComposer = React.forwardRef(
1304
1805
  shouldShow={showEmojiboard}
1305
1806
  onClose={() => setShowEmojiboard(false)}
1306
1807
  emojiSelection={(emoji: any) => {
1307
- let pre = inputMessage.substring(0, selectionPosition.start);
1308
- let post = inputMessage.substring(
1808
+ let pre = plainTextInput.current.substring(0, selectionPosition.start);
1809
+ let post = plainTextInput.current.substring(
1309
1810
  selectionPosition.end,
1310
- inputMessage.length
1811
+ plainTextInput.current.length
1311
1812
  );
1813
+ inputValueRef.current = selectionPosition.start && selectionPosition.end ? `${pre}${emoji}${post}` : `${inputValueRef.current}${emoji}`;
1312
1814
  setInputMessage((prev) =>
1313
1815
  selectionPosition.start && selectionPosition.end
1314
1816
  ? `${pre}${emoji}${post}`
@@ -1330,6 +1832,10 @@ export const CometChatMessageComposer = React.forwardRef(
1330
1832
  messageComposerStyle.actionSheetSeparatorTint,
1331
1833
  }
1332
1834
  : {}),
1835
+ layoutModeIconTint: messageComposerStyle.actionSheetLayoutModeIconTint,
1836
+ titleColor: messageComposerStyle.actionSheetTitleColor,
1837
+ listItemIconTint: messageComposerStyle.attachIconTint,
1838
+ listItemTitleFont: messageComposerStyle.actionSheetTitleFont
1333
1839
  }}
1334
1840
  cometChatBottomSheetStyle={
1335
1841
  messageComposerStyle.actionSheetCancelButtonIconTint
@@ -1373,6 +1879,33 @@ export const CometChatMessageComposer = React.forwardRef(
1373
1879
  aiOptions={AIOptionItems}
1374
1880
  aiStyle={AIStyles}
1375
1881
  />
1882
+
1883
+ {
1884
+ (mentionsSearchData.length > 0 && plainTextInput.current.length > 0)
1885
+ && <View style={{
1886
+ borderTopWidth: 1, borderColor: theme.palette.getAccent300(),
1887
+ paddingVertical: 5, paddingHorizontal: 0,
1888
+ maxHeight: Dimensions.get("window").height * .22, justifyContent: "flex-end",
1889
+ paddingBottom: messagePreview !== null ? 60 : undefined,
1890
+ zIndex: 1
1891
+ }}>
1892
+ <CometChatSuggestionList
1893
+ data={mentionsSearchData}
1894
+ avatarStyle={{
1895
+ height: 33, width: 33,
1896
+ }}
1897
+ listItemStyle={{
1898
+ height: 50,
1899
+ }}
1900
+ separatorColor={theme.palette.getAccent100()}
1901
+ onPress={onMentionPress}
1902
+ onEndReached={onSuggestionListEndReached}
1903
+ loading={suggestionListLoader}
1904
+ />
1905
+ {getMentionLimitView()}
1906
+ </View>
1907
+ }
1908
+
1376
1909
  {HeaderView ? (
1377
1910
  <HeaderView />
1378
1911
  ) : (
@@ -1387,11 +1920,13 @@ export const CometChatMessageComposer = React.forwardRef(
1387
1920
  </View >
1388
1921
  <CometChatMessageInput
1389
1922
  messageInputRef={messageInputRef}
1390
- text={inputMessage}
1923
+ text={inputMessage as string}
1391
1924
  placeHolderText={placeHolderText}
1392
1925
  style={messageComposerStyle}
1393
- onSelectionChange={({ nativeEvent: { selection } }) =>
1926
+ onSelectionChange={({ nativeEvent: { selection } }) => {
1394
1927
  setSelectionPosition(selection)
1928
+ openList(selection)
1929
+ }
1395
1930
  }
1396
1931
  maxHeight={maxHeight ?? null}
1397
1932
  onChangeText={textChangeHandler}