@cometchat/chat-uikit-react-native 5.2.11 → 5.3.0

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 (82) 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 +4557 -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 +139 -10
  21. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +1 -20
  22. package/src/CometChatMessageComposer/styles.tsx +0 -1
  23. package/src/CometChatMessageList/CometChatMessageList.tsx +6 -1
  24. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
  25. package/src/CometChatRichTextEditor/index.tsx +385 -0
  26. package/src/CometChatRichTextEditor/types.ts +162 -0
  27. package/src/CometChatSearch/CometChatSearch.tsx +8 -3
  28. package/src/index.ts +48 -1
  29. package/src/shared/constants/UIKitConstants.ts +12 -1
  30. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
  31. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
  32. package/src/shared/formatters/index.ts +3 -0
  33. package/src/shared/framework/MessageDataSource.tsx +93 -2
  34. package/src/shared/helper/composerHelpers.ts +553 -0
  35. package/src/shared/helper/useKeyboard.tsx +7 -17
  36. package/src/shared/icons/components/code-blocks.tsx +13 -0
  37. package/src/shared/icons/components/code.tsx +11 -0
  38. package/src/shared/icons/components/format-bold.tsx +11 -0
  39. package/src/shared/icons/components/format-italic.tsx +11 -0
  40. package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
  41. package/src/shared/icons/components/format-list-numbered.tsx +11 -0
  42. package/src/shared/icons/components/format-quote.tsx +13 -0
  43. package/src/shared/icons/components/format-strikethrough.tsx +13 -0
  44. package/src/shared/icons/components/format-underlined.tsx +11 -0
  45. package/src/shared/icons/components/smileys-&-people.tsx +1 -1
  46. package/src/shared/icons/icon-mapping.tsx +18 -0
  47. package/src/shared/index.ts +54 -2
  48. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +37 -32
  49. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +5 -0
  50. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +17 -12
  51. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -500
  52. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +18 -13
  53. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +17 -12
  54. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -499
  55. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -499
  56. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -499
  57. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +18 -13
  58. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +17 -12
  59. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -500
  60. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +17 -12
  61. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +17 -12
  62. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +18 -13
  63. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -500
  64. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +17 -12
  65. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +18 -13
  66. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
  67. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
  68. package/src/shared/utils/MarkdownUtils.ts +143 -0
  69. package/src/shared/utils/MentionUtils.ts +37 -0
  70. package/src/shared/utils/index.ts +5 -0
  71. package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
  72. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
  73. package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
  74. package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
  75. package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
  76. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
  77. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
  78. package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
  79. package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
  80. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
  81. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +64 -16
  82. 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
 
@@ -535,7 +536,9 @@ const ConversationItem = React.memo<ConversationItemProps>((
535
536
  const formatMentionsInText = (rawText: any, message?: CometChat.BaseMessage) => {
536
537
  if (typeof rawText !== 'string') return rawText;
537
538
 
538
- let text = rawText.replace(/<@all:(.*?)>/g, '@$1');
539
+ // Strip markdown syntax for clean search result preview while
540
+ // preserving mention tokens for processing below.
541
+ let text = stripMarkdown(rawText).replace(/<@all:(.*?)>/g, '@$1');
539
542
 
540
543
  try {
541
544
  const mentionedUsers: CometChat.User[] = (message && (message).getMentionedUsers && (message).getMentionedUsers()) || [];
@@ -1390,11 +1393,13 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
1390
1393
  };
1391
1394
 
1392
1395
  // Format mentions in raw message text: convert <@all:alias> to @alias
1393
- // and <@uid:UID> to @Name when message provides mentioned users
1396
+ // and <@uid:UID> to @Name when message provides mentioned users.
1397
+ // Also strips markdown syntax for clean search result previews.
1394
1398
  const formatMentionsInText = (rawText: any, message?: CometChat.BaseMessage) => {
1395
1399
  if (typeof rawText !== 'string') return rawText;
1396
1400
 
1397
- let text = rawText.replace(/<@all:(.*?)>/g, '@$1');
1401
+ // Strip markdown syntax while preserving mention tokens for processing below.
1402
+ let text = stripMarkdown(rawText).replace(/<@all:(.*?)>/g, '@$1');
1398
1403
 
1399
1404
  try {
1400
1405
  const mentionedUsers: CometChat.User[] = (message && (message).getMentionedUsers && (message).getMentionedUsers()) || [];
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import {
4
4
  ActionItemInterface,
5
5
  AdditionalParams,
6
+ AudioWaveformVisualizerProps,
6
7
  //Add Call events here already exposed in Calls
7
8
  //Framework
8
9
  ChatConfigurator,
@@ -27,6 +28,9 @@ import {
27
28
  CometChatGroupsEvents,
28
29
  CometChatImageBubble,
29
30
  CometChatImageBubbleInterface,
31
+ CometChatInlineAudioRecorder,
32
+ CometChatInlineAudioRecorderProps,
33
+ CometChatInlineAudioRecorderStyle,
30
34
  CometChatListActionsInterface,
31
35
  //View
32
36
  CometChatListItem,
@@ -62,6 +66,8 @@ import {
62
66
  CometChatUIKitHelper,
63
67
  CometChatUiKitConstants,
64
68
  CometChatUrlsFormatter,
69
+ CometChatRichTextFormatter,
70
+ RichTextStyle,
65
71
  CometChatVideoBubble,
66
72
  CometChatVideoBubbleInterface,
67
73
  ConversationType,
@@ -74,9 +80,12 @@ import {
74
80
  MessageEvents,
75
81
  MessageListAlignmentType,
76
82
  MessageTimeAlignmentType,
83
+ RecorderState,
77
84
  SelectionMode,
78
85
  SuggestionItem,
79
86
  UIKitSettings,
87
+ UseAudioRecorderReturn,
88
+ WaveformStyle,
80
89
  messageStatus,
81
90
  Icon,
82
91
  MenuItemInterface,
@@ -120,6 +129,12 @@ import {
120
129
  CometChatMessageComposerInterface,
121
130
  } from "./CometChatMessageComposer";
122
131
 
132
+ import {
133
+ CometChatCompactMessageComposer,
134
+ CometChatCompactMessageComposerInterface,
135
+ SingleLineMessageComposerStyleInterface,
136
+ } from "./CometChatCompactMessageComposer";
137
+
123
138
  import { CometChatAIAssistantChatHistory } from "./CometChatAIAssistantChatHistory";
124
139
 
125
140
  import { CometChatThreadHeader, CometChatThreadHeaderInterface } from "./CometChatThreadHeader";
@@ -210,6 +225,7 @@ export {
210
225
  CometChatAIAssistantChatHistory,
211
226
  CometChatImageBubble,
212
227
  CometChatIncomingCall,
228
+ CometChatInlineAudioRecorder,
213
229
  //
214
230
  //
215
231
  CometChatListItem,
@@ -219,6 +235,7 @@ export {
219
235
  /* Text Formatters */
220
236
  CometChatMentionsFormatter,
221
237
  CometChatMessageComposer,
238
+ CometChatCompactMessageComposer,
222
239
  CometChatMessageInformation,
223
240
  CometChatMessageList,
224
241
  CometChatMessagePreview,
@@ -245,6 +262,8 @@ export {
245
262
  CometChatUIKitHelper,
246
263
  CometChatUiKitConstants,
247
264
  CometChatUrlsFormatter,
265
+ CometChatRichTextFormatter,
266
+ RichTextStyle,
248
267
  CometChatUsers,
249
268
  CometChatVideoBubble,
250
269
  DataSourceDecorator,
@@ -305,6 +324,8 @@ export type {
305
324
  CometChatGroupMembersInterface,
306
325
  CometChatFileBubbleInterface,
307
326
  CometChatImageBubbleInterface,
327
+ CometChatInlineAudioRecorderProps,
328
+ CometChatInlineAudioRecorderStyle,
308
329
  CometChatListActionsInterface,
309
330
  CometChatListItemInterface,
310
331
  CometChatListStylesInterface,
@@ -313,10 +334,12 @@ export type {
313
334
  CometChatMessageListActionsInterface,
314
335
  CometChatMessageListInterface,
315
336
  CometChatMessageComposerInterface,
316
- CometChatMessageListProps,
337
+ CometChatCompactMessageComposerInterface,
338
+ SingleLineMessageComposerStyleInterface,
317
339
  CometChatMessageOption,
318
340
  ActionItemInterface,
319
341
  AdditionalParams,
342
+ AudioWaveformVisualizerProps,
320
343
  SelectionMode,
321
344
  CometChatReactionsInterface,
322
345
  CometChatReactionListInterface,
@@ -340,12 +363,36 @@ export type {
340
363
  ConversationInterface,
341
364
  LinkPreviewBubbleInterface,
342
365
  PollsConfigurationInterface,
366
+ RecorderState,
343
367
  StickerConfigurationInterface,
344
368
  ConversationType,
345
369
  DataSource,
346
370
  MessageListAlignmentType,
347
371
  MessageTimeAlignmentType,
348
372
  MessageBubbleAlignmentType,
373
+ UseAudioRecorderReturn,
374
+ WaveformStyle,
349
375
  CometChatTheme,
350
376
  MenuItemInterface
351
377
  };
378
+
379
+ // Rich Text Editor
380
+ export { default as RichTextEditor } from './CometChatRichTextEditor';
381
+ export type {
382
+ RichTextEditorRef,
383
+ ContentChangeEvent,
384
+ ActiveStylesState,
385
+ RichTextEditorProps,
386
+ RichTextEditorPropsExtended,
387
+ } from './CometChatRichTextEditor';
388
+ export type {
389
+ Selection,
390
+ StyleRange,
391
+ Block,
392
+ BlockType,
393
+ TextAlignment,
394
+ EditorVariant,
395
+ ToolbarOption,
396
+ SelectionChangeEvent,
397
+ RichTextEditorRef as RichTextEditorRefType,
398
+ } from './CometChatRichTextEditor/types';