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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +20 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +9 -1
  3. package/ios/RichTextEditorView.swift +43 -0
  4. package/ios/RichTextEditorViewManager.m +1 -0
  5. package/ios/RichTextEditorViewManager.swift +8 -0
  6. package/package.json +5 -2
  7. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +38 -9
  8. package/src/CometChatConversations/CometChatConversations.tsx +8 -1
  9. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +2 -2
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +15 -3
  11. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +10 -1
  12. package/src/CometChatMessageList/CometChatMessageList.tsx +5 -2
  13. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +478 -0
  14. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +613 -0
  15. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +313 -0
  16. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +7 -8
  17. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +43 -19
  18. package/src/CometChatRichTextEditor/index.tsx +4 -0
  19. package/src/CometChatRichTextEditor/types.ts +2 -0
  20. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +251 -14
  21. package/src/CometChatSearch/CometChatSearch.tsx +29 -6
  22. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +76 -0
  23. package/src/shared/CometChatUiKit/CometChatUIKit.ts +2 -1
  24. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +211 -0
  25. package/src/shared/constants/UIKitConstants.ts +3 -17
  26. package/src/shared/constants/textPatterns.ts +27 -0
  27. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +25 -259
  28. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +31 -19
  29. package/src/shared/formatters/CometChatTextFormatter.ts +22 -0
  30. package/src/shared/formatters/applyRawFormatters.ts +31 -0
  31. package/src/shared/framework/MessageDataSource.tsx +14 -8
  32. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +15 -30
  33. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +138 -19
  34. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -1
  35. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +0 -1
  36. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +54 -1
  37. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +54 -1
  38. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +54 -1
  39. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +54 -1
  40. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +54 -1
  41. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +54 -1
  42. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +54 -1
  43. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +54 -1
  44. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +54 -1
  45. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +54 -1
  46. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +54 -1
  47. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +54 -1
  48. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +54 -1
  49. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +54 -1
  50. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +54 -1
  51. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +54 -1
  52. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +11 -0
  53. package/src/shared/utils/MarkdownUtils.ts +34 -4
  54. package/src/shared/utils/PinnedMessagesHelper.ts +65 -0
  55. package/src/shared/utils/SavedMessagesHelper.ts +42 -6
  56. package/src/shared/utils/__testUtils__/messagesRequestBuilderMock.ts +37 -0
  57. package/src/shared/utils/cloneRequestBuilder.ts +25 -0
  58. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +15 -4
  59. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +5 -0
  60. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -1
  61. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +8 -1
  62. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -0
  63. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +5 -0
  64. package/src/shared/views/CometChatList/Header.tsx +8 -2
  65. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +5 -0
  66. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +5 -0
  67. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  68. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  69. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  70. package/android/.gradle/7.4/gc.properties +0 -0
  71. package/android/.gradle/vcs-1/gc.properties +0 -0
  72. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +0 -154
@@ -5514,6 +5514,26 @@ class RichTextEditorView(context: Context) : androidx.appcompat.widget.AppCompat
5514
5514
  sendContentChange()
5515
5515
  }
5516
5516
 
5517
+ /**
5518
+ * Replaces the current selection with plain text, or inserts at the caret when nothing is
5519
+ * selected — the editor-side half of a consumer's toolbar button.
5520
+ *
5521
+ * The run is inserted without carrying the spans of whatever it replaced, so a consumer's own
5522
+ * wire token lands as plain characters rather than inheriting the styling around it.
5523
+ */
5524
+ fun replaceSelection(replacement: String) {
5525
+ val editable = text ?: return
5526
+ val start = selectionStart.coerceAtMost(selectionEnd).coerceIn(0, editable.length)
5527
+ val end = selectionStart.coerceAtLeast(selectionEnd).coerceIn(0, editable.length)
5528
+
5529
+ isInternalChange = true
5530
+ editable.replace(start, end, replacement)
5531
+ isInternalChange = false
5532
+
5533
+ setSelection((start + replacement.length).coerceAtMost(text?.length ?: 0))
5534
+ sendContentChange()
5535
+ }
5536
+
5517
5537
  fun removeLink(location: Int, length: Int) {
5518
5538
  val editable = text ?: return
5519
5539
  val end = location + length
@@ -33,6 +33,7 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
33
33
  const val COMMAND_SET_CHECKLIST = "setChecklist"
34
34
  const val COMMAND_SET_PARAGRAPH = "setParagraph"
35
35
  const val COMMAND_INSERT_LINK = "insertLink"
36
+ const val COMMAND_REPLACE_SELECTION = "replaceSelection"
36
37
  const val COMMAND_UNDO = "undo"
37
38
  const val COMMAND_REDO = "redo"
38
39
  const val COMMAND_CLEAR_FORMATTING = "clearFormatting"
@@ -127,7 +128,8 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
127
128
  COMMAND_REMOVE_LINK to 31,
128
129
  COMMAND_UPDATE_LINK to 32,
129
130
  COMMAND_APPLY_INLINE_STYLE to 33,
130
- COMMAND_REMOVE_INLINE_STYLE to 34
131
+ COMMAND_REMOVE_INLINE_STYLE to 34,
132
+ COMMAND_REPLACE_SELECTION to 35
131
133
  )
132
134
  }
133
135
 
@@ -162,6 +164,12 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
162
164
  view.insertLink(url, linkText)
163
165
  }
164
166
  }
167
+ COMMAND_REPLACE_SELECTION -> {
168
+ val replacement = args?.getString(0) ?: ""
169
+ if (replacement.isNotEmpty()) {
170
+ view.replaceSelection(replacement)
171
+ }
172
+ }
165
173
  COMMAND_UNDO -> view.onUndoClick()
166
174
  COMMAND_REDO -> view.onRedoClick()
167
175
  COMMAND_CLEAR_FORMATTING -> view.onClearFormattingClick()
@@ -3141,6 +3141,11 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
3141
3141
 
3142
3142
  /// Returns true when a UTI represents pasteable media (image/video/audio/file),
3143
3143
  /// and false for plain text / URLs which should paste as text.
3144
+ ///
3145
+ /// Rich-text containers are excluded too. Copying TEXT puts one on the pasteboard next to
3146
+ /// the plain string — Safari adds a web archive, Notes / Mail / Pages / TextEdit add RTFD.
3147
+ /// Both conform to public.data, so without this a text copy from those apps was uploaded
3148
+ /// as a WEBARCHIVE / RTFD attachment and the text itself was never pasted.
3144
3149
  private static func isMediaTypeIdentifier(_ typeId: String) -> Bool {
3145
3150
  if #available(iOS 14.0, *) {
3146
3151
  guard let type = UTType(typeId) else { return false }
@@ -3148,6 +3153,9 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
3148
3153
  if type.conforms(to: .plainText) || type.conforms(to: .url) || type.conforms(to: .text) {
3149
3154
  return false
3150
3155
  }
3156
+ if type.conforms(to: .webArchive) || type.conforms(to: .rtfd) || type.conforms(to: .flatRTFD) {
3157
+ return false
3158
+ }
3151
3159
  return type.conforms(to: .image)
3152
3160
  || type.conforms(to: .movie)
3153
3161
  || type.conforms(to: .audio)
@@ -3160,6 +3168,9 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
3160
3168
  if UTTypeConformsTo(cf, kUTTypePlainText) || UTTypeConformsTo(cf, kUTTypeText) || UTTypeConformsTo(cf, kUTTypeURL) {
3161
3169
  return false
3162
3170
  }
3171
+ if UTTypeConformsTo(cf, kUTTypeWebArchive) || UTTypeConformsTo(cf, kUTTypeRTFD) || UTTypeConformsTo(cf, kUTTypeFlatRTFD) {
3172
+ return false
3173
+ }
3163
3174
  return UTTypeConformsTo(cf, kUTTypeImage)
3164
3175
  || UTTypeConformsTo(cf, kUTTypeMovie)
3165
3176
  || UTTypeConformsTo(cf, kUTTypeAudio)
@@ -5292,6 +5303,38 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5292
5303
  emitActiveStyles()
5293
5304
  }
5294
5305
 
5306
+ /// Replaces the current selection with plain text, or inserts at the caret when nothing is
5307
+ /// selected — the editor-side half of a consumer's toolbar button.
5308
+ ///
5309
+ /// The run goes in with the editor's current typing attributes rather than the attributes of
5310
+ /// whatever it replaced, so a consumer's own wire token lands as plain characters instead of
5311
+ /// inheriting, say, the bold of the word it wrapped.
5312
+ func replaceSelection(with text: String) {
5313
+ let range = textView.selectedRange
5314
+ let mutableAttrString = NSMutableAttributedString(attributedString: textView.attributedText)
5315
+ let insertion = NSAttributedString(string: text, attributes: textView.typingAttributes)
5316
+
5317
+ isInternalChange = true
5318
+ if range.length > 0 {
5319
+ mutableAttrString.replaceCharacters(in: range, with: insertion)
5320
+ } else {
5321
+ mutableAttrString.insert(insertion, at: range.location)
5322
+ }
5323
+ textView.attributedText = mutableAttrString
5324
+
5325
+ // Caret after the inserted run. NSString length, not `text.count`: an emoji is one
5326
+ // Character but two UTF-16 units, and the text view counts in UTF-16.
5327
+ let caret = range.location + (text as NSString).length
5328
+ textView.selectedRange = NSRange(location: caret, length: 0)
5329
+
5330
+ placeholderLabel.isHidden = !textView.text.isEmpty
5331
+ isInternalChange = false
5332
+ saveToUndoStack()
5333
+ sendContentChange()
5334
+ updateToolbarButtonStates()
5335
+ emitActiveStyles()
5336
+ }
5337
+
5295
5338
  func undo() {
5296
5339
  guard undoStack.count > 1 else { return }
5297
5340
 
@@ -38,6 +38,7 @@ RCT_EXTERN_METHOD(clear:(nonnull NSNumber *)node)
38
38
  RCT_EXTERN_METHOD(focus:(nonnull NSNumber *)node)
39
39
  RCT_EXTERN_METHOD(blur:(nonnull NSNumber *)node)
40
40
  RCT_EXTERN_METHOD(insertLink:(nonnull NSNumber *)node url:(nonnull NSString *)url text:(nonnull NSString *)text)
41
+ RCT_EXTERN_METHOD(replaceSelection:(nonnull NSNumber *)node text:(nonnull NSString *)text)
41
42
  RCT_EXTERN_METHOD(undo:(nonnull NSNumber *)node)
42
43
  RCT_EXTERN_METHOD(redo:(nonnull NSNumber *)node)
43
44
  RCT_EXTERN_METHOD(toggleBold:(nonnull NSNumber *)node)
@@ -72,6 +72,14 @@ class RichTextEditorViewManager: RCTViewManager {
72
72
  }
73
73
  }
74
74
 
75
+ @objc func replaceSelection(_ node: NSNumber, text: NSString) {
76
+ DispatchQueue.main.async {
77
+ if let view = self.bridge?.uiManager.view(forReactTag: node) as? RichTextEditorView {
78
+ view.replaceSelection(with: text as String)
79
+ }
80
+ }
81
+ }
82
+
75
83
  @objc func undo(_ node: NSNumber) {
76
84
  DispatchQueue.main.async {
77
85
  if let view = self.bridge?.uiManager.view(forReactTag: node) as? RichTextEditorView {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -90,7 +90,10 @@
90
90
  "preset": "react-native",
91
91
  "modulePathIgnorePatterns": [
92
92
  "<rootDir>/lib/"
93
- ]
93
+ ],
94
+ "moduleNameMapper": {
95
+ "\\.(wav|mp3|m4a|aac|ogg)$": "<rootDir>/jest/assetMock.js"
96
+ }
94
97
  },
95
98
  "commitlint": {
96
99
  "extends": [
@@ -40,6 +40,7 @@ import {
40
40
  matchColorTagAt,
41
41
  stripColorTags,
42
42
  } from '../shared/formatters/richTextWireFormat';
43
+ import { applyRawFormatters } from '../shared/formatters/applyRawFormatters';
43
44
 
44
45
  /**
45
46
  * Stack-key prefix for the value-carrying text-colour style during send serialization.
@@ -282,7 +283,7 @@ const RecordAudio = (props: any) => {
282
283
  * MessagePreviewTray component for displaying edit/reply message preview (v5 pattern)
283
284
  */
284
285
  const MessagePreviewTray = (props: any) => {
285
- const { shouldShow = false, message = null, onClose = () => {}, title = '' } = props;
286
+ const { shouldShow = false, message = null, onClose = () => {}, title = '', textFormatters } = props;
286
287
  const { t } = useCometChatTranslation();
287
288
  if (!shouldShow) return null;
288
289
  // Editing a media caption: caption text is the editable subtitle; a muted overline (media-type icon +
@@ -292,9 +293,12 @@ const MessagePreviewTray = (props: any) => {
292
293
  <CometChatMessagePreview
293
294
  messagePreviewTitle={title}
294
295
  message={message}
296
+ textFormatters={textFormatters}
295
297
  {...(isMediaCaptionEdit
296
298
  ? {
297
- messagePreviewSubtitle: message.getCaption() ?? '',
299
+ // The caption goes in as a plain string, so a consumer's token is rewritten here —
300
+ // `textFormatters` above only reaches the message-text path.
301
+ messagePreviewSubtitle: applyRawFormatters(message.getCaption() ?? '', textFormatters),
298
302
  hideSubtitleIcon: true,
299
303
  overlineText: attachmentCountLabel(message.getType?.(), message.getAttachments?.()?.length ?? 1),
300
304
  }
@@ -552,6 +556,14 @@ export interface ComposerInputHandle {
552
556
  setSelection: (start: number, end?: number) => void;
553
557
  /** Inserts a hyperlink, wrapping the current selection when there is one. */
554
558
  insertLink: (url: string, text: string) => void;
559
+ /**
560
+ * Replaces the selected text, or inserts at the caret when nothing is selected — how a trailing
561
+ * button writes its own wire token into the composer.
562
+ *
563
+ * Prefer this over `getText` + `setText`: rewriting the whole input re-seeds the editor, while
564
+ * this touches only the selected run and leaves the formatting around it alone.
565
+ */
566
+ replaceSelection: (text: string) => void;
555
567
  toggleBold: () => void;
556
568
  toggleItalic: () => void;
557
569
  toggleUnderline: () => void;
@@ -2022,13 +2034,15 @@ export const CometChatCompactMessageComposer = React.forwardRef(
2022
2034
 
2023
2035
  // Clone and store formatter using tracking character as key (matching MessageComposer pattern)
2024
2036
  const newFormatter = CommonUtils.clone(formatter);
2025
- if (trackingChar) {
2026
- allFormatters.current.set(trackingChar, newFormatter);
2027
-
2028
- // Set up tracking characters for mention detection
2029
- if (!trackingCharacters.current.includes(trackingChar)) {
2030
- trackingCharacters.current.push(trackingChar);
2031
- }
2037
+ // A formatter with no tracking character has no suggestion list, but it still takes part in
2038
+ // the send and edit-preview lifecycle — so key it by id instead of dropping it. The prefix
2039
+ // keeps it out of reach of the single-character lookup that opens the suggestion list.
2040
+ const formatterKey = trackingChar || `formatter:${formatter.getId?.() ?? allFormatters.current.size}`;
2041
+ allFormatters.current.set(formatterKey, newFormatter);
2042
+
2043
+ // Set up tracking characters for mention detection
2044
+ if (trackingChar && !trackingCharacters.current.includes(trackingChar)) {
2045
+ trackingCharacters.current.push(trackingChar);
2032
2046
  }
2033
2047
  });
2034
2048
  }, []);
@@ -3547,6 +3561,11 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3547
3561
  mode: ConversationOptionConstants.edit,
3548
3562
  });
3549
3563
 
3564
+ // A consumer's own wire token becomes UI Kit markup before the editor parses it, so an edit
3565
+ // opens showing the styling rather than the raw token. `handlePreMessageSend` below turns it
3566
+ // back into the consumer's format when the edit is saved.
3567
+ resolvedText = applyRawFormatters(resolvedText, textFormatters);
3568
+
3550
3569
  // Parse markdown into structured blocks and load into the native editor
3551
3570
  const blocks = markdownToBlocks(resolvedText);
3552
3571
  inputTextRef.current = resolvedText;
@@ -3630,6 +3649,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3630
3649
  setText: (text: string) => setInputTextProgrammatic(text),
3631
3650
  setSelection: (start: number, end?: number) => inputRef.current?.setSelection(start, end),
3632
3651
  insertLink: (url: string, text: string) => inputRef.current?.insertLink(url, text),
3652
+ replaceSelection: (text: string) => inputRef.current?.replaceSelection(text),
3633
3653
  toggleBold: () => inputRef.current?.toggleBold(),
3634
3654
  toggleItalic: () => inputRef.current?.toggleItalic(),
3635
3655
  toggleUnderline: () => inputRef.current?.toggleUnderline(),
@@ -4523,6 +4543,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
4523
4543
  textMessage.setParentMessageId(parentMessageId as number);
4524
4544
  }
4525
4545
  outgoing = textMessage;
4546
+
4547
+ // An edit IS a send: without this a consumer's formatter never converts the text back to
4548
+ // its own wire format, and the mentions formatter never re-attaches the mentioned users.
4549
+ // Captions are left alone — the media send path does not run this hook either.
4550
+ allFormatters.current.forEach((formatter) => {
4551
+ outgoing = formatter.handlePreMessageSend(outgoing);
4552
+ });
4526
4553
  }
4527
4554
 
4528
4555
  // Clear input and preview
@@ -5048,6 +5075,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5048
5075
  <MessagePreviewTray
5049
5076
  shouldShow={messagePreview !== null}
5050
5077
  message={messagePreview?.message}
5078
+ textFormatters={textFormatters}
5051
5079
  title={t('EDIT_MESSAGE')}
5052
5080
  onClose={() => {
5053
5081
  setMessagePreview(null);
@@ -5058,6 +5086,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5058
5086
  {replyMessage && replyMessage.message && (
5059
5087
  <CometChatMessagePreview
5060
5088
  message={replyMessage.message}
5089
+ textFormatters={textFormatters}
5061
5090
  showCloseIcon={true}
5062
5091
  closeIconURL={ICONS.CLOSE}
5063
5092
  onCloseClick={closeReplyPreview}
@@ -42,6 +42,7 @@ import { Icon } from "../shared/icons/Icon";
42
42
  import { CommonUtils } from "../shared/utils/CommonUtils";
43
43
  import { stripMarkdown, preparePreviewText } from "../shared/utils/MarkdownUtils";
44
44
  import { CometChatRichTextFormatter } from "../shared/formatters/CometChatRichTextFormatter";
45
+ import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
45
46
  import { getMessagePreviewInternal, applyMentionsFormatting } from "../shared/utils/MessageUtils";
46
47
  import { CometChatBadge } from "../shared/views/CometChatBadge";
47
48
  import { useToast } from "../shared/helper/useToast";
@@ -1104,7 +1105,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
1104
1105
  if (!lastMessage) return null;
1105
1106
  let messageText: string | JSX.Element = "";
1106
1107
  messageText = ChatConfigurator.getDataSource().getLastConversationMessage(conversations, theme);
1107
-
1108
+
1109
+ // Rewrite a consumer's own wire token first: block detection and markdown stripping below
1110
+ // would otherwise flatten it away before the formatter ever sees the message.
1111
+ if (typeof messageText === "string") {
1112
+ messageText = applyRawFormatters(messageText, textFormatters);
1113
+ }
1114
+
1108
1115
  // Detect block-level elements in text messages before stripMarkdown flattens them
1109
1116
  let blockType: 'blockquote' | 'codeBlock' | 'list' | null = null;
1110
1117
  let codeBlockLine = '';
@@ -185,9 +185,9 @@ export interface CometChatGroupMembersInterface
185
185
  */
186
186
  hideHeader?: boolean;
187
187
  /**
188
- * Hide the Submit Button.
188
+ * Callback when an error occurs.
189
189
  */
190
- onError?: () => void;
190
+ onError?: (e: CometChat.CometChatException) => void;
191
191
  /**
192
192
  * search Keyword
193
193
  */
@@ -57,6 +57,7 @@ import {
57
57
  messageStatus,
58
58
  } from "../shared/utils/CometChatMessageHelper";
59
59
  import { CommonUtils } from "../shared/utils/CommonUtils";
60
+ import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
60
61
  import { isCursorWithinMentionRange, getMentionRangeAtCursor } from "../shared/utils/MentionUtils";
61
62
  import { permissionUtil } from "../shared/utils/PermissionUtil";
62
63
  import { CometChatMediaRecorder } from "../shared/views/CometChatMediaRecorder";
@@ -1921,10 +1922,15 @@ export const CometChatMessageComposer = React.forwardRef(
1921
1922
  if (user) formatter.setUser(user);
1922
1923
  if (group) formatter.setGroup(group);
1923
1924
  let trackingCharacter = formatter.getTrackingCharacter();
1924
- trackingCharacters.current.push(trackingCharacter);
1925
+ if (trackingCharacter) trackingCharacters.current.push(trackingCharacter);
1925
1926
 
1926
1927
  let newFormatter = CommonUtils.clone(formatter);
1927
- allFormatters.current.set(trackingCharacter, newFormatter);
1928
+ // A formatter with no tracking character has no suggestion list, but it still takes part in
1929
+ // the send and edit-preview lifecycle — so key it by id instead of letting an empty key
1930
+ // collapse them all into one entry. The prefix keeps it clear of tracking-character lookups.
1931
+ const formatterKey =
1932
+ trackingCharacter || `formatter:${formatter.getId?.() ?? allFormatters.current.size}`;
1933
+ allFormatters.current.set(formatterKey, newFormatter);
1928
1934
  });
1929
1935
  }, []);
1930
1936
 
@@ -2857,12 +2863,17 @@ export const CometChatMessageComposer = React.forwardRef(
2857
2863
  <CometChatMessagePreview
2858
2864
  messagePreviewTitle={t("EDIT_MESSAGE")}
2859
2865
  message={messagePreview?.message}
2866
+ textFormatters={textFormatters}
2860
2867
  // Editing a media caption: caption text is the editable subtitle; a muted overline
2861
2868
  // (media-type icon + attachment count) restores the context the hidden thumbnail gave.
2862
2869
  {...(typeof messagePreview?.message?.getCaption === "function"
2863
2870
  ? {
2864
- messagePreviewSubtitle:
2871
+ // A caption arrives as a plain string, so a consumer's token is rewritten
2872
+ // here — `textFormatters` above only covers the message-text path.
2873
+ messagePreviewSubtitle: applyRawFormatters(
2865
2874
  messagePreview.message.getCaption() ?? "",
2875
+ textFormatters
2876
+ ),
2866
2877
  hideSubtitleIcon: true,
2867
2878
  overlineText: attachmentCountLabel(messagePreview.message.getType?.(), messagePreview.message.getAttachments?.()?.length ?? 1),
2868
2879
  }
@@ -2888,6 +2899,7 @@ export const CometChatMessageComposer = React.forwardRef(
2888
2899
  {replyMessage && replyMessage.message && (
2889
2900
  <CometChatMessagePreview
2890
2901
  message={replyMessage.message}
2902
+ textFormatters={textFormatters}
2891
2903
  showCloseIcon={true}
2892
2904
  closeIconURL={ICONS.CLOSE}
2893
2905
  onCloseClick={() => {
@@ -9,6 +9,7 @@ import {
9
9
  CometChatUIEventHandler,
10
10
  CometChatUiKitConstants,
11
11
  } from "../shared";
12
+ import { CometChatTextFormatter } from "../shared/formatters/CometChatTextFormatter";
12
13
  import { MessageUtils } from "../shared/utils/MessageUtils";
13
14
  import { Style } from "./styles";
14
15
  import { useTheme } from "../theme";
@@ -33,6 +34,11 @@ type Recipient = {
33
34
 
34
35
  export interface CometChatMessageInformationInterface {
35
36
  title?: string;
37
+ /**
38
+ * Text formatters, only needed when this screen is used on its own — opened from the message
39
+ * list, the template it receives already carries them.
40
+ */
41
+ textFormatters?: Array<CometChatTextFormatter>;
36
42
  message: CometChat.BaseMessage;
37
43
  template?: CometChatMessageTemplate;
38
44
  BubbleView?: (message: CometChat.BaseMessage) => JSX.Element;
@@ -60,6 +66,7 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
60
66
  title = t("MESSAGE_INFORMATION"),
61
67
  message,
62
68
  template,
69
+ textFormatters,
63
70
  BubbleView,
64
71
  ListItemView,
65
72
  receiptDatePattern,
@@ -354,7 +361,9 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
354
361
  message,
355
362
  templates: template
356
363
  ? [template]
357
- : ChatConfigurator.dataSource.getAllMessageTemplates(theme),
364
+ // Opened straight from the message list, the template above already carries the
365
+ // consumer's formatters. Standalone, they have to come in through the prop.
366
+ : ChatConfigurator.dataSource.getAllMessageTemplates(theme, { textFormatters }),
358
367
  alignment: "right",
359
368
  theme: theme,
360
369
  })}
@@ -1,6 +1,7 @@
1
1
  let __listenerIdCounter = 0;
2
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
3
3
  import { ClipboardPasteHandler } from "../shared/views/ClipboardPasteHandler/ClipboardPasteHandler";
4
+ import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
4
5
  import React, {
5
6
  forwardRef,
6
7
  JSX,
@@ -4492,7 +4493,7 @@ export const CometChatMessageList = memo(
4492
4493
  // getPlainString resolves mention tokens but leaves the rich-text wire format alone.
4493
4494
  // copyMessageText puts clean plain text on the clipboard for every other app and keeps
4494
4495
  // the colour in a private representation our own composer restores on paste.
4495
- ClipboardPasteHandler.copyMessageText(getPlainString(item["text"], item));
4496
+ ClipboardPasteHandler.copyMessageText(getPlainString(item["text"], item), textFormatters);
4496
4497
  // Defer modal dismiss to next frame to avoid Fabric race condition
4497
4498
  // where unmounting the Modal while Clipboard is still accessing views
4498
4499
  // causes EXC_BAD_ACCESS (SIGSEGV) at null pointer in mount phase.
@@ -4554,7 +4555,9 @@ export const CometChatMessageList = memo(
4554
4555
  // Strip markdown/HTML from raw text BEFORE mention replacement,
4555
4556
  // because getPlainString can break HTML tags (e.g., </u> becomes /u>)
4556
4557
  let rawText = messageObject?.getData()["text"] || "";
4557
- let strippedText = stripMarkdown(rawText);
4558
+ // The app's own token becomes UI Kit markup BEFORE stripping, the same order the pinned
4559
+ // panel uses. Without it a consumer's `(#e11d48)text()` reaches the share sheet verbatim.
4560
+ let strippedText = stripMarkdown(applyRawFormatters(rawText, textFormatters));
4558
4561
  let textMessage = getPlainString(strippedText, messageObject);
4559
4562
  let fileUrl = messageObject.getData()["url"];
4560
4563