@cometchat/chat-uikit-react-native 5.2.11 → 5.3.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 (93) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +4 -1
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +909 -10
  4. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorPackage.kt +24 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +5382 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +452 -0
  7. package/ios/FileManager.m +430 -3
  8. package/ios/RichTextEditorView.swift +5504 -0
  9. package/ios/RichTextEditorViewManager.m +66 -0
  10. package/ios/RichTextEditorViewManager.swift +291 -0
  11. package/ios/ToolbarIcons.swift +736 -0
  12. package/package.json +1 -1
  13. package/react-native-cometchat-ui-kit.podspec +1 -1
  14. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +4602 -0
  15. package/src/CometChatCompactMessageComposer/SingleLineTextComposerConfiguration.tsx +568 -0
  16. package/src/CometChatCompactMessageComposer/heightUtils.ts +204 -0
  17. package/src/CometChatCompactMessageComposer/index.ts +56 -0
  18. package/src/CometChatCompactMessageComposer/resources/index.ts +5 -0
  19. package/src/CometChatCompactMessageComposer/styles.ts +291 -0
  20. package/src/CometChatConversations/CometChatConversations.tsx +141 -14
  21. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +6 -0
  22. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +1 -20
  23. package/src/CometChatMessageComposer/styles.tsx +0 -1
  24. package/src/CometChatMessageList/CometChatMessageList.tsx +76 -30
  25. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
  26. package/src/CometChatRichTextEditor/index.tsx +385 -0
  27. package/src/CometChatRichTextEditor/types.ts +162 -0
  28. package/src/CometChatSearch/CometChatSearch.tsx +35 -29
  29. package/src/calls/CallUtils.ts +4 -4
  30. package/src/index.ts +48 -1
  31. package/src/shared/CometChatUiKit/CometChatUIKit.ts +2 -0
  32. package/src/shared/constants/UIKitConstants.ts +12 -1
  33. package/src/shared/events/ListenerInitializer.ts +6 -0
  34. package/src/shared/events/messages.ts +2 -0
  35. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
  36. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
  37. package/src/shared/formatters/index.ts +3 -0
  38. package/src/shared/framework/MessageDataSource.tsx +93 -2
  39. package/src/shared/helper/composerHelpers.ts +553 -0
  40. package/src/shared/helper/useKeyboard.tsx +7 -17
  41. package/src/shared/icons/components/code-blocks.tsx +13 -0
  42. package/src/shared/icons/components/code.tsx +11 -0
  43. package/src/shared/icons/components/format-bold.tsx +11 -0
  44. package/src/shared/icons/components/format-italic.tsx +11 -0
  45. package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
  46. package/src/shared/icons/components/format-list-numbered.tsx +11 -0
  47. package/src/shared/icons/components/format-quote.tsx +13 -0
  48. package/src/shared/icons/components/format-strikethrough.tsx +13 -0
  49. package/src/shared/icons/components/format-underlined.tsx +11 -0
  50. package/src/shared/icons/components/smileys-&-people.tsx +1 -1
  51. package/src/shared/icons/icon-mapping.tsx +18 -0
  52. package/src/shared/index.ts +54 -2
  53. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +37 -32
  54. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +5 -0
  55. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +17 -12
  56. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -500
  57. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +18 -13
  58. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +17 -12
  59. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -499
  60. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -499
  61. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -499
  62. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +18 -13
  63. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +17 -12
  64. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -500
  65. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +17 -12
  66. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +17 -12
  67. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +18 -13
  68. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -500
  69. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +17 -12
  70. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +18 -13
  71. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
  72. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
  73. package/src/shared/utils/CommonUtils.ts +18 -1
  74. package/src/shared/utils/MarkdownUtils.ts +143 -0
  75. package/src/shared/utils/MentionUtils.ts +37 -0
  76. package/src/shared/utils/MessageReceiptUtils.ts +5 -4
  77. package/src/shared/utils/MessageUtils.tsx +5 -3
  78. package/src/shared/utils/index.ts +5 -0
  79. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +1 -1
  80. package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
  81. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
  82. package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
  83. package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
  84. package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
  85. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
  86. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
  87. package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
  88. package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
  89. package/src/shared/views/CometChatList/Header.tsx +2 -1
  90. package/src/shared/views/CometChatListItem/style.ts +1 -0
  91. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
  92. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +64 -16
  93. package/src/shared/views/index.ts +39 -0
@@ -0,0 +1,385 @@
1
+ import React, { forwardRef, useImperativeHandle, useRef, useCallback, useState } from 'react';
2
+ import { StyleSheet, UIManager, findNodeHandle } from 'react-native';
3
+ import type {
4
+ Block,
5
+ TextAlignment,
6
+ ContentChangeEvent,
7
+ SelectionChangeEvent,
8
+ RichTextEditorProps,
9
+ RichTextEditorRef,
10
+ } from './types';
11
+ import RichTextEditorViewNative from './RichTextEditorViewNativeComponent';
12
+
13
+ // Command constants
14
+ const COMMANDS = {
15
+ focus: 'focus',
16
+ blur: 'blur',
17
+ clear: 'clear',
18
+ toggleBold: 'toggleBold',
19
+ toggleItalic: 'toggleItalic',
20
+ toggleUnderline: 'toggleUnderline',
21
+ toggleStrikethrough: 'toggleStrikethrough',
22
+ toggleCode: 'toggleCode',
23
+ toggleCodeBlock: 'toggleCodeBlock',
24
+ toggleHighlight: 'toggleHighlight',
25
+ setHeading: 'setHeading',
26
+ setBulletList: 'setBulletList',
27
+ setNumberedList: 'setNumberedList',
28
+ setQuote: 'setQuote',
29
+ setChecklist: 'setChecklist',
30
+ setParagraph: 'setParagraph',
31
+ insertLink: 'insertLink',
32
+ undo: 'undo',
33
+ redo: 'redo',
34
+ clearFormatting: 'clearFormatting',
35
+ indent: 'indent',
36
+ outdent: 'outdent',
37
+ alignLeft: 'alignLeft',
38
+ alignCenter: 'alignCenter',
39
+ alignRight: 'alignRight',
40
+ toggleChecklistItem: 'toggleChecklistItem',
41
+ setText: 'setText',
42
+ setSelection: 'setSelection',
43
+ setContent: 'setContent',
44
+ setMentionRanges: 'setMentionRanges',
45
+ removeLink: 'removeLink',
46
+ updateLink: 'updateLink',
47
+ } as const;
48
+
49
+ // Helper to dispatch commands to native view
50
+ const dispatchCommand = (
51
+ ref: React.RefObject<any>,
52
+ command: string,
53
+ args: any[] = []
54
+ ) => {
55
+ const viewTag = findNodeHandle(ref.current);
56
+ if (viewTag != null) {
57
+ UIManager.dispatchViewManagerCommand(viewTag, command, args);
58
+ }
59
+ };
60
+
61
+ interface SizeChangeEvent {
62
+ nativeEvent: {
63
+ height: number;
64
+ };
65
+ }
66
+
67
+ export interface ActiveStylesState {
68
+ bold: boolean;
69
+ italic: boolean;
70
+ underline: boolean;
71
+ strikethrough: boolean;
72
+ code: boolean;
73
+ codeBlock: boolean;
74
+ highlight: boolean;
75
+ blockType: string;
76
+ alignment: string;
77
+ }
78
+
79
+ interface ActiveStylesChangeEvent {
80
+ nativeEvent: {
81
+ bold: boolean;
82
+ italic: boolean;
83
+ underline: boolean;
84
+ strikethrough: boolean;
85
+ code: boolean;
86
+ codeBlock: boolean;
87
+ highlight: boolean;
88
+ blockType: string;
89
+ alignment: string;
90
+ };
91
+ }
92
+
93
+ export interface LinkTapEventData {
94
+ url: string;
95
+ text: string;
96
+ location: number;
97
+ length: number;
98
+ }
99
+
100
+ interface LinkTapEvent {
101
+ nativeEvent: LinkTapEventData;
102
+ }
103
+
104
+ export interface RichTextEditorPropsExtended extends RichTextEditorProps {
105
+ /** Test ID for testing frameworks (e.g. Detox, React Native Testing Library) */
106
+ testID?: string;
107
+ /** Accessibility label for screen readers */
108
+ accessibilityLabel?: string;
109
+ onActiveStylesChange?: (styles: ActiveStylesState) => void;
110
+ onSizeChange?: (height: number) => void;
111
+ onLinkTap?: (data: LinkTapEventData) => void;
112
+ /** Callback when Enter is pressed in "sendMessage" mode (Android only) */
113
+ onSendRequest?: () => void;
114
+ /** Enter key behavior: "newLine" (default) or "sendMessage" (Android only) */
115
+ enterKeyBehavior?: string;
116
+ /** Show Bold/Italic/Underline/Strikethrough in text selection context menu */
117
+ showTextSelectionMenuItems?: boolean;
118
+ /** Code block background color */
119
+ codeBackgroundColor?: string;
120
+ /** Code block border color */
121
+ codeBorderColor?: string;
122
+ /** Code block text color */
123
+ codeTextColor?: string;
124
+ /** Code block font size */
125
+ codeFontSize?: number;
126
+ }
127
+
128
+ const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorPropsExtended>((props, ref) => {
129
+ const nativeRef = useRef<React.ElementRef<typeof RichTextEditorViewNative>>(null);
130
+ const [height, setHeight] = useState<number | undefined>(undefined);
131
+
132
+ const handleSizeChange = useCallback((event: SizeChangeEvent) => {
133
+ const newHeight = event.nativeEvent?.height;
134
+ if (newHeight && newHeight > 0) {
135
+ setHeight(newHeight);
136
+ props.onSizeChange?.(newHeight);
137
+ }
138
+ }, [props.onSizeChange]);
139
+
140
+ useImperativeHandle(ref, () => ({
141
+ setContent: (blocks: Block[]) => {
142
+ dispatchCommand(nativeRef, COMMANDS.setContent, [blocks]);
143
+ },
144
+ getText: async (): Promise<string> => '',
145
+ getBlocks: async (): Promise<Block[]> => [],
146
+ clear: () => {
147
+ dispatchCommand(nativeRef, COMMANDS.clear);
148
+ },
149
+ focus: () => {
150
+ dispatchCommand(nativeRef, COMMANDS.focus);
151
+ },
152
+ blur: () => {
153
+ dispatchCommand(nativeRef, COMMANDS.blur);
154
+ },
155
+ toggleBold: () => {
156
+ dispatchCommand(nativeRef, COMMANDS.toggleBold);
157
+ },
158
+ toggleItalic: () => {
159
+ dispatchCommand(nativeRef, COMMANDS.toggleItalic);
160
+ },
161
+ toggleUnderline: () => {
162
+ dispatchCommand(nativeRef, COMMANDS.toggleUnderline);
163
+ },
164
+ toggleStrikethrough: () => {
165
+ dispatchCommand(nativeRef, COMMANDS.toggleStrikethrough);
166
+ },
167
+ toggleCode: () => {
168
+ dispatchCommand(nativeRef, COMMANDS.toggleCode);
169
+ },
170
+ toggleCodeBlock: () => {
171
+ dispatchCommand(nativeRef, COMMANDS.toggleCodeBlock);
172
+ },
173
+ toggleHighlight: (_color?: string) => {
174
+ dispatchCommand(nativeRef, COMMANDS.toggleHighlight);
175
+ },
176
+ setHeading: () => {
177
+ dispatchCommand(nativeRef, COMMANDS.setHeading);
178
+ },
179
+ setBulletList: () => {
180
+ dispatchCommand(nativeRef, COMMANDS.setBulletList);
181
+ },
182
+ setNumberedList: () => {
183
+ dispatchCommand(nativeRef, COMMANDS.setNumberedList);
184
+ },
185
+ setQuote: () => {
186
+ dispatchCommand(nativeRef, COMMANDS.setQuote);
187
+ },
188
+ setChecklist: () => {
189
+ dispatchCommand(nativeRef, COMMANDS.setChecklist);
190
+ },
191
+ setParagraph: () => {
192
+ dispatchCommand(nativeRef, COMMANDS.setParagraph);
193
+ },
194
+ insertLink: (url: string, text: string) => {
195
+ dispatchCommand(nativeRef, COMMANDS.insertLink, [url, text]);
196
+ },
197
+ undo: () => {
198
+ dispatchCommand(nativeRef, COMMANDS.undo);
199
+ },
200
+ redo: () => {
201
+ dispatchCommand(nativeRef, COMMANDS.redo);
202
+ },
203
+ clearFormatting: () => {
204
+ dispatchCommand(nativeRef, COMMANDS.clearFormatting);
205
+ },
206
+ indent: () => {
207
+ dispatchCommand(nativeRef, COMMANDS.indent);
208
+ },
209
+ outdent: () => {
210
+ dispatchCommand(nativeRef, COMMANDS.outdent);
211
+ },
212
+ setAlignment: (alignment: TextAlignment) => {
213
+ switch (alignment) {
214
+ case 'left':
215
+ dispatchCommand(nativeRef, COMMANDS.alignLeft);
216
+ break;
217
+ case 'center':
218
+ dispatchCommand(nativeRef, COMMANDS.alignCenter);
219
+ break;
220
+ case 'right':
221
+ dispatchCommand(nativeRef, COMMANDS.alignRight);
222
+ break;
223
+ }
224
+ },
225
+ toggleChecklistItem: () => {
226
+ dispatchCommand(nativeRef, COMMANDS.toggleChecklistItem);
227
+ },
228
+ setText: (text: string) => {
229
+ dispatchCommand(nativeRef, COMMANDS.setText, [text]);
230
+ },
231
+ setSelection: (start: number, end?: number) => {
232
+ dispatchCommand(nativeRef, COMMANDS.setSelection, [start, end ?? start]);
233
+ },
234
+ setMentionRanges: (ranges: Array<{ start: number; end: number }>) => {
235
+ dispatchCommand(nativeRef, COMMANDS.setMentionRanges, [ranges]);
236
+ },
237
+ removeLink: (location: number, length: number) => {
238
+ dispatchCommand(nativeRef, COMMANDS.removeLink, [location, length]);
239
+ },
240
+ updateLink: (location: number, length: number, newUrl: string, newText: string) => {
241
+ dispatchCommand(nativeRef, COMMANDS.updateLink, [location, length, newUrl, newText]);
242
+ },
243
+ }));
244
+
245
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
246
+ const handleContentChange = useCallback(
247
+ (event: any) => {
248
+ // Parse blocksJson string (codegen doesn't support nested ReadonlyArray<Object>)
249
+ let blocks: Block[] = [];
250
+ try {
251
+ if (event.nativeEvent.blocksJson) {
252
+ blocks = JSON.parse(event.nativeEvent.blocksJson);
253
+ } else if (event.nativeEvent.blocks) {
254
+ // Fallback for backward compatibility
255
+ blocks = [...event.nativeEvent.blocks];
256
+ }
257
+ } catch {
258
+ blocks = [];
259
+ }
260
+
261
+ // Convert native event to our API format
262
+ const contentEvent: ContentChangeEvent = {
263
+ nativeEvent: {
264
+ text: event.nativeEvent.text,
265
+ blocks,
266
+ delta: event.nativeEvent.delta,
267
+ },
268
+ };
269
+ props.onContentChange?.(contentEvent);
270
+ },
271
+ [props.onContentChange],
272
+ );
273
+
274
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
+ const handleSelectionChange = useCallback(
276
+ (event: any) => {
277
+ const selectionEvent: SelectionChangeEvent = {
278
+ nativeEvent: {
279
+ start: event.nativeEvent.start,
280
+ end: event.nativeEvent.end,
281
+ },
282
+ };
283
+ props.onSelectionChange?.(selectionEvent);
284
+ },
285
+ [props.onSelectionChange],
286
+ );
287
+
288
+ const handleFocus = useCallback(() => {
289
+ props.onFocus?.();
290
+ }, [props.onFocus]);
291
+
292
+ const handleBlur = useCallback(() => {
293
+ props.onBlur?.();
294
+ }, [props.onBlur]);
295
+
296
+ const handleActiveStylesChange = useCallback(
297
+ (event: ActiveStylesChangeEvent) => {
298
+ const native = event.nativeEvent;
299
+ const styles: ActiveStylesState = {
300
+ bold: native.bold,
301
+ italic: native.italic,
302
+ underline: native.underline,
303
+ strikethrough: native.strikethrough,
304
+ code: native.codeBlock ? false : native.code,
305
+ codeBlock: native.codeBlock,
306
+ highlight: native.highlight,
307
+ blockType: native.blockType,
308
+ alignment: native.alignment,
309
+ };
310
+ props.onActiveStylesChange?.(styles);
311
+ },
312
+ [props.onActiveStylesChange],
313
+ );
314
+
315
+ const handleLinkTap = useCallback(
316
+ (event: LinkTapEvent) => {
317
+ props.onLinkTap?.(event.nativeEvent);
318
+ },
319
+ [props.onLinkTap],
320
+ );
321
+
322
+ const handleSendRequest = useCallback(() => {
323
+ props.onSendRequest?.();
324
+ }, [props.onSendRequest]);
325
+
326
+ const combinedStyle = StyleSheet.flatten([props.style, height != null ? { height } : undefined]);
327
+
328
+ return (
329
+ <RichTextEditorViewNative
330
+ ref={nativeRef}
331
+ testID={props.testID}
332
+ accessibilityLabel={props.accessibilityLabel}
333
+ style={combinedStyle}
334
+ placeholder={props.placeholder}
335
+ initialContentJson={props.initialContent ? JSON.stringify(props.initialContent) : undefined}
336
+ editable={props.readOnly !== undefined ? !props.readOnly : true}
337
+ maxHeight={props.maxHeight}
338
+ numberOfLines={props.numberOfLines}
339
+ showToolbar={props.readOnly ? false : props.showToolbar ?? true}
340
+ toolbarOptions={props.toolbarOptions}
341
+ variant={props.variant ?? 'outlined'}
342
+ toolbarMode={props.toolbarMode}
343
+ selection={props.selection}
344
+ textStyle={props.textStyle}
345
+ placeholderTextColor={props.placeholderTextColor}
346
+ text={props.text}
347
+ codeBackgroundColor={props.codeBackgroundColor}
348
+ codeBorderColor={props.codeBorderColor}
349
+ codeTextColor={props.codeTextColor}
350
+ codeFontSize={props.codeFontSize}
351
+ onContentChange={handleContentChange}
352
+ onSelectionChange={handleSelectionChange}
353
+ onEditorFocus={handleFocus}
354
+ onEditorBlur={handleBlur}
355
+ onSizeChange={handleSizeChange}
356
+ onActiveStylesChange={handleActiveStylesChange}
357
+ onLinkTap={handleLinkTap}
358
+ onSendRequest={handleSendRequest}
359
+ enterKeyBehavior={props.enterKeyBehavior}
360
+ showTextSelectionMenuItems={props.showTextSelectionMenuItems ?? true}
361
+ />
362
+ );
363
+ });
364
+
365
+ RichTextEditor.displayName = 'RichTextEditor';
366
+
367
+ export default RichTextEditor;
368
+ export { DEFAULT_TOOLBAR_OPTIONS } from './types';
369
+ export type {
370
+ Block,
371
+ BlockType,
372
+ StyleRange,
373
+ TextAlignment,
374
+ EditorVariant,
375
+ ContentChangeEvent,
376
+ SelectionChangeEvent,
377
+ RichTextEditorRef,
378
+ RichTextEditorProps,
379
+ ToolbarOption,
380
+ ContentDelta,
381
+ DeltaType,
382
+ Selection,
383
+ TextStyle,
384
+ } from './types';
385
+ export { dispatchCommand };
@@ -0,0 +1,162 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native';
2
+
3
+ // New interfaces for CometChat integration
4
+ export interface Selection {
5
+ start: number;
6
+ end: number;
7
+ }
8
+
9
+ export interface TextStyle {
10
+ fontSize?: number;
11
+ color?: string;
12
+ fontFamily?: string;
13
+ }
14
+
15
+ export interface StyleRange {
16
+ style: 'bold' | 'italic' | 'underline' | 'strikethrough' | 'link' | 'code' | 'highlight';
17
+ start: number;
18
+ end: number;
19
+ url?: string;
20
+ highlightColor?: string;
21
+ }
22
+
23
+ export type BlockType = 'paragraph' | 'bullet' | 'numbered' | 'heading' | 'quote' | 'checklist';
24
+ export type TextAlignment = 'left' | 'center' | 'right';
25
+ export type EditorVariant = 'outlined' | 'flat' | 'plain';
26
+
27
+ export interface Block {
28
+ type: BlockType;
29
+ text: string;
30
+ styles: StyleRange[];
31
+ alignment?: TextAlignment;
32
+ checked?: boolean;
33
+ indentLevel?: number;
34
+ }
35
+
36
+ export interface ContentChangeEvent {
37
+ nativeEvent: {
38
+ text: string;
39
+ blocks: Block[];
40
+ delta?: ContentDelta;
41
+ };
42
+ }
43
+
44
+ export type DeltaType = 'insert' | 'delete' | 'format' | 'replace';
45
+
46
+ export interface ContentDelta {
47
+ type: DeltaType;
48
+ position: number;
49
+ length?: number;
50
+ text?: string;
51
+ blockIndex?: number;
52
+ style?: string;
53
+ }
54
+
55
+ export interface SelectionChangeEvent {
56
+ nativeEvent: {
57
+ start: number;
58
+ end: number;
59
+ };
60
+ }
61
+
62
+ export type ToolbarOption =
63
+ | 'bold'
64
+ | 'italic'
65
+ | 'strikethrough'
66
+ | 'underline'
67
+ | 'code'
68
+ | 'highlight'
69
+ | 'heading'
70
+ | 'bullet'
71
+ | 'numbered'
72
+ | 'quote'
73
+ | 'checklist'
74
+ | 'link'
75
+ | 'undo'
76
+ | 'redo'
77
+ | 'clearFormatting'
78
+ | 'indent'
79
+ | 'outdent'
80
+ | 'alignLeft'
81
+ | 'alignCenter'
82
+ | 'alignRight';
83
+
84
+ export const DEFAULT_TOOLBAR_OPTIONS: ToolbarOption[] = [
85
+ 'bold',
86
+ 'italic',
87
+ 'underline',
88
+ 'strikethrough',
89
+ 'code',
90
+ 'highlight',
91
+ 'heading',
92
+ 'bullet',
93
+ 'numbered',
94
+ 'quote',
95
+ 'checklist',
96
+ 'link',
97
+ 'undo',
98
+ 'redo',
99
+ 'clearFormatting',
100
+ 'indent',
101
+ 'outdent',
102
+ 'alignLeft',
103
+ 'alignCenter',
104
+ 'alignRight',
105
+ ];
106
+
107
+ export interface RichTextEditorProps {
108
+ style?: StyleProp<ViewStyle>;
109
+ placeholder?: string;
110
+ initialContent?: Block[];
111
+ readOnly?: boolean;
112
+ maxHeight?: number;
113
+ numberOfLines?: number;
114
+ showToolbar?: boolean;
115
+ toolbarOptions?: ToolbarOption[];
116
+ variant?: EditorVariant;
117
+ toolbarMode?: 'floating' | 'inline';
118
+ // New props for CometChat integration
119
+ selection?: Selection;
120
+ textStyle?: TextStyle;
121
+ placeholderTextColor?: string;
122
+ text?: string;
123
+ onContentChange?: (event: ContentChangeEvent) => void;
124
+ onSelectionChange?: (event: SelectionChangeEvent) => void;
125
+ onFocus?: () => void;
126
+ onBlur?: () => void;
127
+ }
128
+
129
+ export interface RichTextEditorRef {
130
+ setContent: (blocks: Block[]) => void;
131
+ getText: () => Promise<string>;
132
+ getBlocks: () => Promise<Block[]>;
133
+ clear: () => void;
134
+ focus: () => void;
135
+ blur: () => void;
136
+ toggleBold: () => void;
137
+ toggleItalic: () => void;
138
+ toggleUnderline: () => void;
139
+ toggleStrikethrough: () => void;
140
+ toggleCode: () => void;
141
+ toggleCodeBlock: () => void;
142
+ toggleHighlight: (color?: string) => void;
143
+ setHeading: () => void;
144
+ setBulletList: () => void;
145
+ setNumberedList: () => void;
146
+ setQuote: () => void;
147
+ setChecklist: () => void;
148
+ setParagraph: () => void;
149
+ insertLink: (url: string, text: string) => void;
150
+ undo: () => void;
151
+ redo: () => void;
152
+ clearFormatting: () => void;
153
+ indent: () => void;
154
+ outdent: () => void;
155
+ setAlignment: (alignment: TextAlignment) => void;
156
+ toggleChecklistItem: () => void;
157
+ setText: (text: string) => void;
158
+ setSelection: (start: number, end?: number) => void;
159
+ setMentionRanges: (ranges: Array<{ start: number; end: number }>) => void;
160
+ removeLink: (location: number, length: number) => void;
161
+ updateLink: (location: number, length: number, newUrl: string, newText: string) => void;
162
+ }
@@ -17,6 +17,7 @@ import { deepMerge } from '../shared/helper/helperFunctions';
17
17
  import { DeepPartial } from '../shared/helper/types';
18
18
  import { getCometChatTranslation } from '../shared/resources/CometChatLocalizeNew/LocalizationManager';
19
19
  import { CommonUtils } from '../shared/utils/CommonUtils';
20
+ import { stripMarkdown } from '../shared/utils/MarkdownUtils';
20
21
  import { ExtensionConstants } from '../extensions/ExtensionConstants';
21
22
  import { getExtensionData } from '../extensions/ExtensionModerator';
22
23
 
@@ -338,34 +339,38 @@ const t = getCometChatTranslation();
338
339
 
339
340
  interface LinkPreviewImageProps {
340
341
  uri: string;
342
+ fallbackUri?: string;
341
343
  mergedStyles: any;
342
344
  theme: any;
343
345
  }
344
346
 
345
- const LinkPreviewImage: React.FC<LinkPreviewImageProps> = ({ uri, mergedStyles, theme }) => {
347
+ const LinkFallbackIcon = ({ mergedStyles, theme }: { mergedStyles: any; theme: any }) => (
348
+ <View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
349
+ <Icon
350
+ name='link-fill'
351
+ size={48}
352
+ height={48}
353
+ width={48}
354
+ color={theme.color.iconSecondary}
355
+ />
356
+ </View>
357
+ );
358
+
359
+ const LinkPreviewImage: React.FC<LinkPreviewImageProps> = ({ uri, fallbackUri, mergedStyles, theme }) => {
346
360
  const [imageError, setImageError] = useState(false);
361
+ const [fallbackError, setFallbackError] = useState(false);
347
362
 
348
- if (imageError) {
349
- return (
350
- <View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
351
- <Icon
352
- name='link-fill'
353
- size={48}
354
- height={48}
355
- width={48}
356
- color={theme.color.iconSecondary}
357
- />
358
- </View>
359
- );
363
+ if (imageError && (!fallbackUri || fallbackError)) {
364
+ return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
360
365
  }
361
366
 
362
367
  return (
363
368
  <View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
364
369
  <Image
365
- source={{ uri }}
370
+ source={{ uri: imageError ? fallbackUri! : uri }}
366
371
  style={mergedStyles.messageItemStyle?.linkPreviewImageStyle}
367
372
  resizeMode="cover"
368
- onError={() => setImageError(true)}
373
+ onError={() => imageError ? setFallbackError(true) : setImageError(true)}
369
374
  />
370
375
  </View>
371
376
  );
@@ -535,7 +540,9 @@ const ConversationItem = React.memo<ConversationItemProps>((
535
540
  const formatMentionsInText = (rawText: any, message?: CometChat.BaseMessage) => {
536
541
  if (typeof rawText !== 'string') return rawText;
537
542
 
538
- let text = rawText.replace(/<@all:(.*?)>/g, '@$1');
543
+ // Strip markdown syntax for clean search result preview while
544
+ // preserving mention tokens for processing below.
545
+ let text = stripMarkdown(rawText).replace(/<@all:(.*?)>/g, '@$1');
539
546
 
540
547
  try {
541
548
  const mentionedUsers: CometChat.User[] = (message && (message).getMentionedUsers && (message).getMentionedUsers()) || [];
@@ -1390,11 +1397,13 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
1390
1397
  };
1391
1398
 
1392
1399
  // Format mentions in raw message text: convert <@all:alias> to @alias
1393
- // and <@uid:UID> to @Name when message provides mentioned users
1400
+ // and <@uid:UID> to @Name when message provides mentioned users.
1401
+ // Also strips markdown syntax for clean search result previews.
1394
1402
  const formatMentionsInText = (rawText: any, message?: CometChat.BaseMessage) => {
1395
1403
  if (typeof rawText !== 'string') return rawText;
1396
1404
 
1397
- let text = rawText.replace(/<@all:(.*?)>/g, '@$1');
1405
+ // Strip markdown syntax while preserving mention tokens for processing below.
1406
+ let text = stripMarkdown(rawText).replace(/<@all:(.*?)>/g, '@$1');
1398
1407
 
1399
1408
  try {
1400
1409
  const mentionedUsers: CometChat.User[] = (message && (message).getMentionedUsers && (message).getMentionedUsers()) || [];
@@ -1476,25 +1485,22 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
1476
1485
  return (
1477
1486
  <LinkPreviewImage
1478
1487
  uri={thumbnailUrl}
1488
+ fallbackUri={firstLink.favicon !== thumbnailUrl ? firstLink.favicon : undefined}
1479
1489
  mergedStyles={mergedStyles}
1480
1490
  theme={theme}
1481
1491
  />
1482
1492
  );
1483
1493
  } else {
1484
1494
  // Fallback to link icon if no thumbnail
1485
- return (
1486
- <View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
1487
- <Icon
1488
- name='link-fill'
1489
- size={48}
1490
- height={48}
1491
- width={48}
1492
- color={theme.color.iconSecondary}
1493
- />
1494
- </View>
1495
- );
1495
+ return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
1496
1496
  }
1497
1497
  }
1498
+
1499
+ // Show link icon for text messages in Links filter that lack preview metadata
1500
+ if (searchState.activeFilters.includes(CometChatSearchFilter.Links)) {
1501
+ return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
1502
+ }
1503
+
1498
1504
  return null;
1499
1505
  }
1500
1506
 
@@ -85,8 +85,8 @@ export class CallUtils {
85
85
  callMessageText = `${t("CALL_REJECTED")}`;
86
86
  selectedIcon = call["type"] === "audio" ? "call" : "video-call";
87
87
  } else {
88
- callMessageText = `${t("INCOMING_CALL")}`;
89
- selectedIcon = call["type"] === "audio" ? "incoming-audio" : "incoming-video";
88
+ callMessageText = `${t("CALL_REJECTED")}`;
89
+             selectedIcon = call["type"] === "audio" ? "call" : "video-call";
90
90
  }
91
91
  break;
92
92
  case CALL_BUSY:
@@ -124,8 +124,8 @@ export class CallUtils {
124
124
  return callStatus === CALL_UNANSWERED;
125
125
  }
126
126
 
127
- // Incoming calls: treat BUSY as missed as well
128
- return [CALL_UNANSWERED, CALL_CANCELLED, CALL_BUSY].includes(callStatus);
127
+ // Incoming calls: treat BUSY and REJECTED as missed as well
128
+ return [CALL_UNANSWERED, CALL_CANCELLED, CALL_BUSY, CALL_REJECTED].includes(callStatus);
129
129
  }
130
130
 
131
131
  /**