@cometchat/chat-uikit-react-native 4.3.3 → 4.3.5

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 (92) hide show
  1. package/README.md +11 -21
  2. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +6 -6
  3. package/ios/CommonUtil.h +4 -0
  4. package/ios/CommonUtil.m +27 -0
  5. package/package.json +10 -5
  6. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
  7. package/src/CometChatConversations/CometChatConversations.tsx +143 -72
  8. package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
  9. package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
  10. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +11 -1
  11. package/src/CometChatGroups/CometChatGroups.tsx +10 -0
  12. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +554 -52
  13. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
  14. package/src/CometChatMessageComposer/resources/Info.png +0 -0
  15. package/src/CometChatMessageComposer/resources/index.ts +3 -1
  16. package/src/CometChatMessageHeader/listners.ts +0 -2
  17. package/src/CometChatMessageList/CometChatMessageList.tsx +124 -15
  18. package/src/CometChatMessageList/MessageListConfiguration.ts +14 -1
  19. package/src/CometChatMessages/CometChatMessages.tsx +16 -16
  20. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +6 -1
  21. package/src/calls/CallingExtentionDecorator.tsx +11 -9
  22. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
  23. package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +10 -0
  24. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +10 -0
  25. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
  26. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
  27. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
  28. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
  29. package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
  30. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
  31. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
  32. package/src/extensions/Polls/Polls.tsx +106 -70
  33. package/src/extensions/Polls/PollsDecorator.tsx +3 -2
  34. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
  35. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
  36. package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
  37. package/src/index.ts +21 -0
  38. package/src/shared/CometChatUiKit/CometChatUIKit.ts +150 -25
  39. package/src/shared/CometChatUiKit/index.ts +1 -1
  40. package/src/shared/base/vars.ts +13 -0
  41. package/src/shared/constants/UIKitConstants.ts +6 -0
  42. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
  43. package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
  44. package/src/shared/events/CometChatUIEvents.ts +3 -1
  45. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
  46. package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
  48. package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
  50. package/src/shared/formatters/index.ts +11 -0
  51. package/src/shared/framework/DataSource.ts +21 -16
  52. package/src/shared/framework/DataSourceDecorator.tsx +29 -13
  53. package/src/shared/framework/MessageDataSource.tsx +215 -49
  54. package/src/shared/helper/useKeyboard.tsx +20 -2
  55. package/src/shared/index.ts +23 -3
  56. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
  57. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
  58. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
  59. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
  60. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
  61. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
  62. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
  63. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
  64. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
  65. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
  66. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
  67. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
  68. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
  69. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
  70. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
  71. package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
  72. package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
  73. package/src/shared/utils/PermissionUtil.ts +142 -0
  74. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
  75. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
  76. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
  77. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +7 -5
  78. package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
  79. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +11 -2
  80. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
  82. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
  83. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
  84. package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
  85. package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
  86. package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
  87. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
  88. package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
  89. package/src/shared/views/CometChatTextBubble/index.ts +2 -3
  90. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +5 -3
  91. package/src/shared/views/index.ts +9 -3
  92. package/src/shared/utils/PermissionUtilIOS.ts +0 -104
@@ -0,0 +1,380 @@
1
+ import React from 'react';
2
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
3
+ import { CometChatTextFormatter } from "../CometChatTextFormatter";
4
+ import { MentionTextStyle } from "./MentionTextStyle";
5
+ import { Text } from "react-native";
6
+ import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
7
+ import { localize } from '../../resources';
8
+ import { SuggestionItem } from '../../views/CometChatSuggestionList';
9
+
10
+ /**
11
+ * Represents the CometChatMentionsFormatter class.
12
+ * This class extends the CometChatTextFormatter class and provides methods for handling mentions in text.
13
+ * @extends CometChatTextFormatter
14
+ */
15
+ export class CometChatMentionsFormatter extends CometChatTextFormatter {
16
+
17
+ /**
18
+ * List of users for mentions.
19
+ */
20
+ protected SuggestionItems: Array<SuggestionItem> = [];
21
+
22
+ /**
23
+ * List of searched data.
24
+ */
25
+ protected searchData: Array<SuggestionItem> = [];
26
+
27
+ /**
28
+ * Stores the formatting style for mentions.
29
+ */
30
+ private mentionsStyle: MentionTextStyle = {};
31
+
32
+ /**
33
+ * The message object in context.
34
+ */
35
+ protected messageObject: CometChat.BaseMessage = undefined;
36
+
37
+ /**
38
+ * Default search request object to fetch users or group members.
39
+ */
40
+ private searchRequest: CometChat.UsersRequest | CometChat.GroupMembersRequest;
41
+
42
+ /**
43
+ * Custom request object to fetch users or group members.
44
+ */
45
+ private customRequest: CometChat.UsersRequestBuilder | CometChat.GroupMembersRequestBuilder;
46
+
47
+ /**
48
+ * Limit of unique users to be added in the composer.
49
+ */
50
+ protected limit: number = 10;
51
+
52
+ /**
53
+ * Initializes a new CometChatMentionsFormatter.
54
+ * @param {CometChat.User} loggedInUser - The user who is currently logged in.
55
+ */
56
+ constructor(loggedInUser?: CometChat.User) {
57
+ super();
58
+ this.regexPattern = /<@uid:(.*?)>/g;
59
+ this.trackCharacter = '@';
60
+ this.loggedInUser = loggedInUser;
61
+ }
62
+
63
+
64
+ /**
65
+ * Sets the message object.
66
+ *
67
+ * @param {CometChat.BaseMessage} messageObject - The message object to be set.
68
+ */
69
+ setMessage(messageObject: CometChat.BaseMessage) {
70
+ this.messageObject = messageObject;
71
+
72
+ let mentionedUsers = (messageObject?.getMentionedUsers && messageObject?.getMentionedUsers()) || [];
73
+ let cometchatUIUserArray: Array<SuggestionItem> = this.convertCCUsersToSuggestionsItem(mentionedUsers);;
74
+
75
+ this.setSuggestionItems(cometchatUIUserArray);
76
+
77
+ }
78
+
79
+ handlePreMessageSend(message: CometChat.TextMessage): CometChat.TextMessage {
80
+ let CCUsers = this.getSuggestionItems().map(item => {
81
+ let user = new CometChat.User(item.id);
82
+ user.setAvatar(item?.leadingIconUrl);
83
+ user.setName(item?.name);
84
+ return user;
85
+ });
86
+ message.setMentionedUsers(CCUsers);
87
+ return message;
88
+ }
89
+
90
+ handleComposerPreview(message: CometChat.TextMessage): void {
91
+ let users = this.convertCCUsersToSuggestionsItem(message.getMentionedUsers());
92
+ this.setSuggestionItems(users);
93
+ }
94
+
95
+ private convertCCUsersToSuggestionsItem(users: CometChat.User[]) {
96
+ return users.map((item: CometChat.User) => {
97
+ return new SuggestionItem({
98
+ id: item?.getUid(),
99
+ name: item?.getName(),
100
+ promptText: "@" + item?.getName(),
101
+ trackingCharacter: "@",
102
+ underlyingText: `<@uid:${item?.getUid()}>`,
103
+ leadingIconUrl: item?.getAvatar(),
104
+ hideLeadingIcon: false
105
+ })
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Sets the search request builder.
111
+ * @param requestBuilder - The request builder to set.
112
+ */
113
+ setSearchRequestBuilder(requestBuilder: CometChat.UsersRequestBuilder | CometChat.GroupMembersRequestBuilder) {
114
+ this.customRequest = requestBuilder;
115
+ }
116
+
117
+ private shouldLoadLocalData(searchKey?: string) {
118
+ if (this.getUniqueUsersList().size >= this.limit) {
119
+ let data = searchKey ? [...this.SuggestionItems].filter(item => ((item.name.toLowerCase()).includes(searchKey.trim().toLowerCase()) || (item.id.toLowerCase()).includes(searchKey.trim().toLowerCase()))) : [...this.SuggestionItems];
120
+ this.searchData = [...data];
121
+ this.setSearchData(this.searchData);
122
+ return true
123
+ }
124
+ return false
125
+ }
126
+
127
+ search(searchKey: string): void {
128
+ if (this.shouldLoadLocalData(searchKey)) return;
129
+ let requestBuilder = this.customRequest || (this.group ? new CometChat.GroupMembersRequestBuilder(this.group.getGuid()) : new CometChat.UsersRequestBuilder());
130
+
131
+ this.searchRequest = requestBuilder.setLimit(10)
132
+ .setSearchKeyword(searchKey)
133
+ .build();
134
+
135
+ this.searchData = [];
136
+ this.fetchNext(true);
137
+ }
138
+
139
+ fetchNext(freshCall?: boolean): void | null {
140
+ if (this.getUniqueUsersList().size >= this.limit) return;
141
+ this.searchRequest?.fetchNext && this.searchRequest?.fetchNext()
142
+ .then((users: CometChat.User[]) => {
143
+ let structuredData = this.convertCCUsersToSuggestionsItem(users);
144
+ this.searchData = freshCall ? [...structuredData] : [...this.searchData, ...structuredData];
145
+ this.setSearchData(this.searchData);
146
+ })
147
+ .catch(err => {
148
+ console.log("searchRequest fetchNext failed:", err);
149
+ this.setSearchData(this.searchData);
150
+ })
151
+ }
152
+
153
+ setSearchData(data: Array<SuggestionItem>) {
154
+ this.searchData = [...data];
155
+ CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccSuggestionData, { id: this.composerId, data: [...this.searchData] });
156
+ }
157
+
158
+ /**
159
+ * Sets the limit of unique users to be added in the composer.
160
+ */
161
+ setLimit(limit: number) {
162
+ this.limit = limit;
163
+ }
164
+
165
+ /**
166
+ * Retrieves the limit of unique users to be added in the composer.
167
+ */
168
+ getLimit() {
169
+ return this.limit;
170
+ }
171
+
172
+ /**
173
+ * Retrieves the unique users list.
174
+ */
175
+ getUniqueUsersList(): Set<number | string> {
176
+ // A Set to store unique user IDs
177
+ const uniqueUserIds: Set<number | string> = new Set();
178
+
179
+ // Populate the Set with user IDs from the existing user list
180
+ this.SuggestionItems.forEach(user => uniqueUserIds.add(user.id));
181
+
182
+ return uniqueUserIds;
183
+ }
184
+
185
+ /**
186
+ * Retrieves the message object.
187
+ *
188
+ * @returns {CometChat.BaseMessage} - The current message object.
189
+ */
190
+ getMessage(): CometChat.BaseMessage {
191
+ return this.messageObject;
192
+ }
193
+
194
+ /**
195
+ * Sets the regex pattern for matching text.
196
+ *
197
+ * @param {<RegExp>} regexPattern - Regex patterns.
198
+ */
199
+ setRegexPattern = (regexPattern: RegExp) => {
200
+ this.regexPattern = regexPattern;
201
+ }
202
+
203
+ /**
204
+ * Gets the regex pattern for matching text.
205
+ */
206
+ getRegexPattern = () => {
207
+ return this.regexPattern;
208
+ }
209
+
210
+ /**
211
+ * Retrieves the SuggestionItems.
212
+ *
213
+ * @returns {Array<SuggestionItem>} - The current SuggestionItems.
214
+ */
215
+ getSuggestionItems(): Array<SuggestionItem> {
216
+ return this.SuggestionItems;
217
+ }
218
+
219
+ /**
220
+ * Sets the SuggestionItems.
221
+ *
222
+ * @param {Array<SuggestionItem>} SuggestionItems - The SuggestionItems to be set.
223
+ */
224
+ setSuggestionItems(SuggestionItems: Array<SuggestionItem>) {
225
+ this.SuggestionItems = [...SuggestionItems];
226
+ }
227
+
228
+ /**
229
+ * Retrieves the mentions style.
230
+ *
231
+ * @returns {MentionTextStyle} - The current mentions style.
232
+ */
233
+ getMentionsStyle(): MentionTextStyle {
234
+ return this.mentionsStyle;
235
+ }
236
+
237
+ /**
238
+ * Sets the mentions style.
239
+ *
240
+ * @param {MentionTextStyle} mentionsStyle - The mentions style to be set.
241
+ */
242
+ setMentionsStyle(mentionsStyle: MentionTextStyle) {
243
+ this.mentionsStyle = { ...mentionsStyle };
244
+ }
245
+
246
+ getFormattedText(inputText: string | null | JSX.Element): string | JSX.Element {
247
+ if (!inputText) {
248
+ return "";
249
+ }
250
+ let formattedText = this.addMentionsView(inputText);
251
+ return formattedText;
252
+ }
253
+
254
+ temp: Function;
255
+
256
+ setOnMentionClick(callBack: (message: CometChat.BaseMessage, uid: string) => void) {
257
+ // callBack(this.messageObject, "uid");
258
+ this.temp = callBack;
259
+ }
260
+
261
+ /**
262
+ * Emits the event for mention click.
263
+ * @param {any} event - The event object.
264
+ * @param {string} uid - The user id.
265
+ */
266
+ private onMentionClick = (event: any, uid: string) => {
267
+ if (this.temp) {
268
+ this.temp(this.messageObject, uid);
269
+ return;
270
+ }
271
+
272
+ // let obj = { uid, trackCharacter: this.trackCharacter };
273
+ // CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccMentionClick, {
274
+ // item: {
275
+ // body: {
276
+ // CometChatUserGroupMembersObject: obj,
277
+ // message: this.messageObject ?? null,
278
+ // id: uid,
279
+ // },
280
+ // // event,
281
+ // source: "mentions", //add through enum
282
+ // }
283
+ // });
284
+ }
285
+
286
+ /**
287
+ * This function adds the mention view to the input text.
288
+ *
289
+ * @param {string} inputText - The input text where the view needs to be added.
290
+ * @returns {string} - The modified input text.
291
+ */
292
+ protected addMentionsView(inputText: string | JSX.Element) {
293
+ if (typeof inputText === 'string') {
294
+ let mentions: JSX.Element[] = [];
295
+
296
+ if (this.SuggestionItems) {
297
+
298
+ const userRegistry: { [key: string]: string } = {};
299
+ for (let i = 0; i < this.SuggestionItems?.length; i++) {
300
+ const userUid = this.SuggestionItems[i].id;
301
+ const userName = this.SuggestionItems[i].promptText;
302
+ userRegistry[userUid] = userName;
303
+ }
304
+
305
+ // Define the regex pattern
306
+ const regex = this.getRegexPattern();
307
+
308
+ // Break the string into segments split by the regex
309
+ let match;
310
+ let lastIndex = 0;
311
+ let segments = [];
312
+
313
+ while ((match = regex.exec(inputText)) !== null) {
314
+
315
+ // Add preceding non-UID segment, if any
316
+ if (match.index > lastIndex) {
317
+ segments.push(inputText.slice(lastIndex, match.index));
318
+ }
319
+
320
+ // Add UID segment
321
+ segments.push(match[1]);
322
+
323
+ // Update lastIndex
324
+ lastIndex = match.index + match[0].length;
325
+ }
326
+
327
+ // Append trailing non-UID segment, if any
328
+ if (lastIndex < inputText.length) {
329
+ segments.push(inputText.slice(lastIndex));
330
+ }
331
+
332
+ // Now create an array of JSX elements from the segments
333
+ const elements = segments.map((segment, index) => {
334
+ // Check if segment is a UID
335
+ if (userRegistry.hasOwnProperty(segment)) {
336
+
337
+ let textStyle = (this.loggedInUser?.getUid() == segment) ? this.mentionsStyle.loggedInUserTextStyle : this.mentionsStyle.textStyle;
338
+ let onPressProp = this.temp ? { onPress: (event: any) => this.onMentionClick(event, segment) } : {};
339
+
340
+ return (
341
+ <Text
342
+ suppressHighlighting={true}
343
+ key={index}
344
+ {...onPressProp}
345
+ style={{ ...textStyle }}>{userRegistry[segment]}</Text>
346
+ );
347
+ } else {
348
+ return <Text key={index}>{segment}</Text>;
349
+ }
350
+ });
351
+
352
+ if (elements.length > 0)
353
+ return <Text>{elements.map(item => item)}</Text>
354
+ }
355
+ return inputText;
356
+
357
+ } else if (React.isValidElement(inputText)) {
358
+ // inputText is a React element
359
+ if (inputText.props.children) {
360
+ // If the React element have children, we map over these children
361
+ // and call addMentionsView recursively for each child.
362
+ return React.cloneElement(inputText, {
363
+ children: React.Children.map(inputText.props.children, child => {
364
+ return this.addMentionsView(child);
365
+ }),
366
+ });
367
+ } else {
368
+ // If the React element does not have children, return it as is
369
+ return inputText;
370
+ }
371
+ } else {
372
+ throw new Error(`Unsupported inputText type: ${typeof inputText}`);
373
+ }
374
+ }
375
+
376
+ getErrorString() {
377
+ return (`${localize("MENTION_UPTO")} ${this.limit} ${this.limit === 1 ? localize("TIME") : localize("TIMES")} ${localize("AT_A_TIME")}.`);
378
+ }
379
+
380
+ }
@@ -0,0 +1,14 @@
1
+ import { TextStyle } from 'react-native';
2
+ /**
3
+ * MentionTextStyle
4
+ * Stores the styles for user mention.
5
+ * @param textStyle: TextStyle
6
+ * @param loggedInUserTextStyle: TextStyle
7
+ */
8
+ export class MentionTextStyle {
9
+ textStyle?: TextStyle;
10
+ loggedInUserTextStyle?: TextStyle;
11
+ constructor(props: MentionTextStyle) {
12
+ Object.assign(this, props);
13
+ }
14
+ }
@@ -0,0 +1,7 @@
1
+ import { CometChatMentionsFormatter } from './CometChatMentionsFormatter';
2
+ import { MentionTextStyle } from './MentionTextStyle';
3
+
4
+ export {
5
+ CometChatMentionsFormatter,
6
+ MentionTextStyle
7
+ }
@@ -0,0 +1,253 @@
1
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
2
+ import { CometChatUIEventHandler, CometChatUIEvents } from "../events";
3
+ import { SuggestionItem } from "../views/CometChatSuggestionList";
4
+
5
+ /**
6
+ * CometChatTextFormatter
7
+ * Abstract class for text formatter.
8
+ */
9
+ export abstract class CometChatTextFormatter {
10
+ /**
11
+ * The regex patterns to find specific text pattern in the user input text.
12
+ */
13
+ protected regexPattern = /(@w+)/g;
14
+
15
+ /**
16
+ * List of users for suggestion item.
17
+ */
18
+ protected SuggestionItems: Array<SuggestionItem> = [];
19
+
20
+ /**
21
+ * The message object in context.
22
+ */
23
+ protected messageObject: CometChat.BaseMessage;
24
+
25
+ /**
26
+ * List of searched data.
27
+ */
28
+ protected searchData = [];
29
+
30
+ /**
31
+ * The user in context.
32
+ */
33
+ protected user: CometChat.User;
34
+
35
+ /**
36
+ * The group in context.
37
+ */
38
+ protected group: CometChat.Group;
39
+
40
+ /**
41
+ * The composer ID.
42
+ */
43
+ protected composerId: string | number;
44
+
45
+ /**
46
+ * The formatter id.
47
+ */
48
+ protected id: string | number;
49
+
50
+ /**
51
+ * The character to track once typed in the text input field.
52
+ */
53
+ protected trackCharacter: string = '#';
54
+
55
+ /**
56
+ * The user who is currently logged in.
57
+ */
58
+ protected loggedInUser?: CometChat.User;
59
+
60
+ /**
61
+ * Sets the regex patterns to match.
62
+ * @param regexPattern - The regex patterns.
63
+ */
64
+ setRegexPatterns(regexPattern: RegExp) {
65
+ this.regexPattern = regexPattern;
66
+ }
67
+
68
+ /**
69
+ * Gets the regex pattern for matching text.
70
+ * @returns The regex pattern.
71
+ */
72
+ getRegexPattern = (): RegExp => {
73
+ return this.regexPattern;
74
+ }
75
+
76
+ /**
77
+ * Gets the composer ID.
78
+ * @returns The composer ID.
79
+ */
80
+ getComposerId = (): string | number => {
81
+ return this.composerId;
82
+ }
83
+
84
+ /**
85
+ * Gets the formatter ID.
86
+ * @returns The formatter ID.
87
+ */
88
+ getId = (): string | number => {
89
+ return this.id;
90
+ }
91
+
92
+ /**
93
+ * Sets the tracking character.
94
+ * @param trackCharacter - The character to track.
95
+ */
96
+ setTrackingCharacter(trackCharacter: string) {
97
+ this.trackCharacter = trackCharacter;
98
+ }
99
+
100
+ /**
101
+ * Sets the composer ID.
102
+ * @param composerId - The composer ID.
103
+ */
104
+ setComposerId(composerId: string | number) {
105
+ this.composerId = composerId;
106
+ }
107
+
108
+ /**
109
+ * Sets the formatter ID.
110
+ * @param id - The formatter ID.
111
+ */
112
+ setId(id: string | number) {
113
+ this.id = id;
114
+ }
115
+
116
+ /**
117
+ * Search function used to call an API with searched text.
118
+ * @param searchKey - The search key.
119
+ */
120
+ search(searchKey: string) { }
121
+
122
+ /**
123
+ * Sets the search data.
124
+ * @param data - The search data.
125
+ */
126
+ setSearchData(data: Array<SuggestionItem>) {
127
+ this.searchData = [...data];
128
+ CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccSuggestionData, { id: this.composerId, data: [...this.searchData] });
129
+ }
130
+
131
+ /**
132
+ * Sets the message object.
133
+ * @param messageObject - The message object to be set.
134
+ */
135
+ setMessage(messageObject: CometChat.BaseMessage) {
136
+ this.messageObject = messageObject;
137
+ }
138
+
139
+ /**
140
+ * Retrieves the message object.
141
+ * @returns The current message object.
142
+ */
143
+ getMessage() {
144
+ return this.messageObject;
145
+ }
146
+
147
+ /**
148
+ * Fetches the next set of data.
149
+ */
150
+ fetchNext() { }
151
+
152
+ /**
153
+ * Sets the user.
154
+ * @param user - The user to set.
155
+ */
156
+ setUser(user: CometChat.User) {
157
+ this.user = user;
158
+ }
159
+
160
+ /**
161
+ * Retrieves the user.
162
+ * @returns The current user.
163
+ */
164
+ getUser(): CometChat.User {
165
+ return this.user;
166
+ }
167
+
168
+ /**
169
+ * Sets the group.
170
+ * @param group - The group to set.
171
+ */
172
+ setGroup(group: CometChat.Group) {
173
+ this.group = group;
174
+ }
175
+
176
+ /**
177
+ * Retrieves the group.
178
+ * @returns The current group.
179
+ */
180
+ getGroup(): CometChat.Group {
181
+ return this.group;
182
+ }
183
+
184
+ /**
185
+ * Retrieves the currently logged in user.
186
+ * @returns The currently logged in user.
187
+ */
188
+ getLoggedInUser() {
189
+ return this.loggedInUser;
190
+ }
191
+
192
+ /**
193
+ * Sets the currently logged in user.
194
+ * @param loggedInUser - The user to set as currently logged in.
195
+ */
196
+ setLoggedInUser(loggedInUser: CometChat.User) {
197
+ this.loggedInUser = loggedInUser;
198
+ }
199
+
200
+ /**
201
+ * If the input text is provided, it returns the formatted text. Otherwise, it edits the text using the current cursor position.
202
+ * @param inputText - The text to format.
203
+ * @returns The formatted text.
204
+ */
205
+ getFormattedText(inputText: string | null | JSX.Element): string | null | JSX.Element {
206
+ if (!inputText) {
207
+ return "";
208
+ }
209
+
210
+ return inputText;
211
+ };
212
+
213
+ /**
214
+ * Handles the message before sending it.
215
+ * @param message - The message to handle.
216
+ * @returns The message after handling.
217
+ */
218
+ handlePreMessageSend(message: CometChat.TextMessage): CometChat.TextMessage {
219
+ return message;
220
+ };
221
+
222
+ /**
223
+ * Handles the message before editing it.
224
+ * @param message - The message to handle.
225
+ * @returns The message after handling.
226
+ */
227
+ handleComposerPreview(message: CometChat.TextMessage) { }
228
+
229
+ /**
230
+ * Gets the tracking character.
231
+ * @returns The tracking character.
232
+ */
233
+ getTrackingCharacter() {
234
+ return this.trackCharacter;
235
+ }
236
+
237
+ /**
238
+ * Retrieves the suggestion items.
239
+ * @returns The current suggestion items.
240
+ */
241
+ getSuggestionItems(): Array<SuggestionItem> {
242
+ return this.SuggestionItems;
243
+ }
244
+
245
+ /**
246
+ * Sets the suggestion items.
247
+ * @param SuggestionItems - The suggestion items to be set.
248
+ */
249
+ setSuggestionItems(SuggestionItems: Array<SuggestionItem>) {
250
+ this.SuggestionItems = SuggestionItems;
251
+ }
252
+
253
+ }