@cometchat/chat-uikit-react-native 5.4.1 → 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 (105) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +34 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +562 -5
  3. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +28 -1
  4. package/ios/CometChatClipboardModule.m +5 -0
  5. package/ios/CometChatClipboardModule.swift +22 -0
  6. package/ios/RichTextEditorView.swift +636 -31
  7. package/ios/RichTextEditorViewManager.m +3 -0
  8. package/ios/RichTextEditorViewManager.swift +24 -0
  9. package/package.json +5 -2
  10. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +283 -64
  11. package/src/CometChatCompactMessageComposer/index.ts +2 -0
  12. package/src/CometChatConversations/CometChatConversations.tsx +299 -15
  13. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +2 -2
  14. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +15 -3
  15. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +181 -12
  16. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +10 -1
  17. package/src/CometChatMessageList/CometChatMessageList.tsx +572 -16
  18. package/src/CometChatMessageList/components/MessageModals.tsx +30 -0
  19. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +21 -9
  20. package/src/CometChatMessageList/components/MessageQuickActions.tsx +162 -0
  21. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +964 -0
  22. package/src/CometChatPinnedMessages/index.ts +5 -0
  23. package/src/CometChatPinnedMessages/style.ts +216 -0
  24. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +5 -0
  25. package/src/CometChatRichTextEditor/index.tsx +31 -1
  26. package/src/CometChatRichTextEditor/types.ts +21 -1
  27. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +871 -0
  28. package/src/CometChatSavedMessages/index.ts +5 -0
  29. package/src/CometChatSavedMessages/style.ts +159 -0
  30. package/src/CometChatSearch/CometChatSearch.tsx +71 -341
  31. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +22 -2
  32. package/src/index.ts +60 -0
  33. package/src/shared/CometChatUiKit/CometChatUIKit.ts +18 -1
  34. package/src/shared/base/Types.ts +5 -0
  35. package/src/shared/constants/UIKitConstants.ts +16 -17
  36. package/src/shared/constants/textPatterns.ts +27 -0
  37. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +25 -225
  38. package/src/shared/events/CometChatUIEventHandler/Listener.ts +37 -0
  39. package/src/shared/events/ListenerInitializer.ts +20 -1
  40. package/src/shared/events/messages.ts +18 -0
  41. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +123 -25
  42. package/src/shared/formatters/CometChatTextFormatter.ts +22 -0
  43. package/src/shared/formatters/applyRawFormatters.ts +31 -0
  44. package/src/shared/formatters/index.ts +14 -0
  45. package/src/shared/formatters/richTextWireFormat.ts +165 -0
  46. package/src/shared/framework/MessageDataSource.tsx +309 -10
  47. package/src/shared/icons/components/thread-follow.tsx +13 -0
  48. package/src/shared/icons/components/thread-unfollow.tsx +13 -0
  49. package/src/shared/icons/components/unsave.tsx +13 -0
  50. package/src/shared/icons/icon-mapping.tsx +6 -0
  51. package/src/shared/index.ts +37 -0
  52. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +15 -30
  53. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +138 -19
  54. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -1
  55. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +54 -1
  56. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +54 -1
  57. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +54 -1
  58. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +54 -1
  59. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +54 -1
  60. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +54 -1
  61. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +54 -1
  62. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +54 -1
  63. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +54 -1
  64. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +54 -1
  65. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +54 -1
  66. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +54 -1
  67. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +54 -1
  68. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +54 -1
  69. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +54 -1
  70. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +54 -1
  71. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +54 -1
  72. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +11 -0
  73. package/src/shared/utils/MarkdownUtils.ts +57 -6
  74. package/src/shared/utils/MessageUtils.tsx +80 -5
  75. package/src/shared/utils/PinConversationHelper.ts +245 -0
  76. package/src/shared/utils/PinSaveFeatureGates.ts +178 -0
  77. package/src/shared/utils/PinSaveHelper.ts +549 -0
  78. package/src/shared/utils/PinnedMessagesHelper.ts +65 -0
  79. package/src/shared/utils/SavedMessagesHelper.ts +267 -0
  80. package/src/shared/utils/ThreadSubscriptionHelper.ts +427 -0
  81. package/src/shared/utils/__testUtils__/messagesRequestBuilderMock.ts +37 -0
  82. package/src/shared/utils/cloneRequestBuilder.ts +25 -0
  83. package/src/shared/utils/conversationUtils.ts +8 -1
  84. package/src/shared/utils/stripRichText.ts +7 -0
  85. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +32 -0
  86. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +6 -0
  87. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +4 -0
  88. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +5 -0
  89. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +17 -5
  90. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -1
  91. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +8 -1
  92. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -0
  93. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +91 -20
  94. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -0
  95. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +5 -0
  96. package/src/shared/views/CometChatList/CometChatList.tsx +6 -1
  97. package/src/shared/views/CometChatList/Header.tsx +8 -2
  98. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +4 -0
  99. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +1 -0
  100. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +4 -0
  101. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +5 -0
  102. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +5 -0
  103. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +4 -1
  104. package/src/theme/default/default.ts +6 -0
  105. package/src/theme/type.ts +4 -0
@@ -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"
@@ -48,6 +49,8 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
48
49
  const val COMMAND_SET_MENTION_RANGES = "setMentionRanges"
49
50
  const val COMMAND_REMOVE_LINK = "removeLink"
50
51
  const val COMMAND_UPDATE_LINK = "updateLink"
52
+ const val COMMAND_APPLY_INLINE_STYLE = "applyInlineStyle"
53
+ const val COMMAND_REMOVE_INLINE_STYLE = "removeInlineStyle"
51
54
 
52
55
  private const val TAG_EDITOR = "editor"
53
56
  }
@@ -123,7 +126,10 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
123
126
  COMMAND_SET_CONTENT to 29,
124
127
  COMMAND_SET_MENTION_RANGES to 30,
125
128
  COMMAND_REMOVE_LINK to 31,
126
- COMMAND_UPDATE_LINK to 32
129
+ COMMAND_UPDATE_LINK to 32,
130
+ COMMAND_APPLY_INLINE_STYLE to 33,
131
+ COMMAND_REMOVE_INLINE_STYLE to 34,
132
+ COMMAND_REPLACE_SELECTION to 35
127
133
  )
128
134
  }
129
135
 
@@ -158,6 +164,12 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
158
164
  view.insertLink(url, linkText)
159
165
  }
160
166
  }
167
+ COMMAND_REPLACE_SELECTION -> {
168
+ val replacement = args?.getString(0) ?: ""
169
+ if (replacement.isNotEmpty()) {
170
+ view.replaceSelection(replacement)
171
+ }
172
+ }
161
173
  COMMAND_UNDO -> view.onUndoClick()
162
174
  COMMAND_REDO -> view.onRedoClick()
163
175
  COMMAND_CLEAR_FORMATTING -> view.onClearFormattingClick()
@@ -199,6 +211,11 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
199
211
  if (styleName == "link" && style.hasKey("url")) {
200
212
  styleMap["url"] = style.getString("url") ?: ""
201
213
  }
214
+ // Preserve colour for textColor styles — without this the
215
+ // edit round-trip loses the colour and renders plain.
216
+ if (styleName == "textColor" && style.hasKey("color")) {
217
+ styleMap["color"] = style.getString("color") ?: ""
218
+ }
202
219
  stylesList.add(styleMap)
203
220
  }
204
221
  }
@@ -221,6 +238,16 @@ class RichTextEditorViewManager : SimpleViewManager<LinearLayout>() {
221
238
  view.setMentionRanges(ranges)
222
239
  }
223
240
  }
241
+ COMMAND_APPLY_INLINE_STYLE -> {
242
+ val key = args?.getString(0) ?: return
243
+ // ARGB int from RN's processColor()
244
+ val color = args?.getInt(1) ?: return
245
+ view.applyInlineStyle(key, color)
246
+ }
247
+ COMMAND_REMOVE_INLINE_STYLE -> {
248
+ val key = args?.getString(0) ?: return
249
+ view.removeInlineStyle(key)
250
+ }
224
251
  COMMAND_REMOVE_LINK -> {
225
252
  val location = args?.getInt(0) ?: return
226
253
  val length = args?.getInt(1) ?: return
@@ -2,6 +2,11 @@
2
2
 
3
3
  @interface RCT_EXTERN_MODULE(CometChatClipboardModule, NSObject)
4
4
 
5
+ RCT_EXTERN_METHOD(setRichText:(nonnull NSString *)plain
6
+ wire:(nonnull NSString *)wire
7
+ resolve:(RCTPromiseResolveBlock)resolve
8
+ reject:(RCTPromiseRejectBlock)reject)
9
+
5
10
  RCT_EXTERN_METHOD(hasImageInClipboard:(RCTPromiseResolveBlock)resolve
6
11
  reject:(RCTPromiseRejectBlock)reject)
7
12
 
@@ -1,9 +1,31 @@
1
1
  import Foundation
2
2
  import UIKit
3
3
 
4
+ /// Private pasteboard type carrying the rich-text wire format alongside the plain text.
5
+ /// Other apps only ever see `public.utf8-plain-text`, so `<color=…>` markup can never leak
6
+ /// out of CometChat — only our own editor reads this type back.
7
+ let CometChatRichTextPasteboardType = "com.cometchat.uikit.richtext"
8
+
4
9
  @objc(CometChatClipboardModule)
5
10
  class CometChatClipboardModule: NSObject {
6
11
 
12
+ /// Copies `plain` to the system pasteboard for everyone, and `wire` under a private type
13
+ /// so our composer can restore inline colour when the paste lands back in CometChat.
14
+ @objc func setRichText(
15
+ _ plain: NSString,
16
+ wire: NSString,
17
+ resolve: @escaping RCTPromiseResolveBlock,
18
+ reject: @escaping RCTPromiseRejectBlock
19
+ ) {
20
+ var item: [String: Any] = ["public.utf8-plain-text": plain as String]
21
+ // Only carry the private type when it actually differs — nothing to restore otherwise.
22
+ if (wire as String) != (plain as String) {
23
+ item[CometChatRichTextPasteboardType] = wire as String
24
+ }
25
+ UIPasteboard.general.items = [item]
26
+ resolve(true)
27
+ }
28
+
7
29
  @objc func hasImageInClipboard(
8
30
  _ resolve: @escaping RCTPromiseResolveBlock,
9
31
  reject: @escaping RCTPromiseRejectBlock