@cometchat/chat-uikit-react-native 5.2.10 → 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.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +4 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +909 -10
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorPackage.kt +24 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +5382 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +452 -0
- package/ios/FileManager.m +430 -3
- package/ios/RichTextEditorView.swift +5504 -0
- package/ios/RichTextEditorViewManager.m +66 -0
- package/ios/RichTextEditorViewManager.swift +291 -0
- package/ios/ToolbarIcons.swift +736 -0
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +4557 -0
- package/src/CometChatCompactMessageComposer/SingleLineTextComposerConfiguration.tsx +568 -0
- package/src/CometChatCompactMessageComposer/heightUtils.ts +204 -0
- package/src/CometChatCompactMessageComposer/index.ts +56 -0
- package/src/CometChatCompactMessageComposer/resources/index.ts +5 -0
- package/src/CometChatCompactMessageComposer/styles.ts +291 -0
- package/src/CometChatConversations/CometChatConversations.tsx +139 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +25 -21
- package/src/CometChatMessageComposer/styles.tsx +0 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +39 -6
- package/src/CometChatMessageList/components/MessageListItem.tsx +11 -8
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
- package/src/CometChatRichTextEditor/index.tsx +385 -0
- package/src/CometChatRichTextEditor/types.ts +162 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -3
- package/src/CometChatSearch/style.ts +3 -3
- package/src/index.ts +48 -1
- package/src/shared/constants/UIKitConstants.ts +12 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
- package/src/shared/formatters/index.ts +3 -0
- package/src/shared/framework/MessageDataSource.tsx +93 -2
- package/src/shared/helper/composerHelpers.ts +553 -0
- package/src/shared/helper/useKeyboard.tsx +7 -17
- package/src/shared/icons/components/code-blocks.tsx +13 -0
- package/src/shared/icons/components/code.tsx +11 -0
- package/src/shared/icons/components/format-bold.tsx +11 -0
- package/src/shared/icons/components/format-italic.tsx +11 -0
- package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
- package/src/shared/icons/components/format-list-numbered.tsx +11 -0
- package/src/shared/icons/components/format-quote.tsx +13 -0
- package/src/shared/icons/components/format-strikethrough.tsx +13 -0
- package/src/shared/icons/components/format-underlined.tsx +11 -0
- package/src/shared/icons/components/smileys-&-people.tsx +1 -1
- package/src/shared/icons/icon-mapping.tsx +18 -0
- package/src/shared/index.ts +54 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +38 -32
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +6 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +19 -13
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
- package/src/shared/utils/MarkdownUtils.ts +143 -0
- package/src/shared/utils/MentionUtils.ts +37 -0
- package/src/shared/utils/MessageUtils.tsx +55 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
- package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
- package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
- package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
- package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
- package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
- package/src/shared/views/CometChatList/Header.tsx +57 -49
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +0 -1
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +3 -2
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +11 -5
- package/src/shared/views/CometChatReactions/style.ts +35 -8
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +108 -75
- package/src/shared/views/index.ts +39 -0
- package/src/theme/index.ts +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
13
13
|
import React, { useCallback, useMemo } from "react";
|
|
14
|
-
import { Text, View, GestureResponderEvent } from "react-native";
|
|
14
|
+
import { Text, View, GestureResponderEvent, Platform, StyleSheet } from "react-native";
|
|
15
15
|
import {
|
|
16
16
|
ChatConfigurator,
|
|
17
17
|
CometChatAvatar,
|
|
@@ -41,6 +41,8 @@ import {
|
|
|
41
41
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
42
42
|
import { Icon } from "../shared/icons/Icon";
|
|
43
43
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
44
|
+
import { stripMarkdown, preparePreviewText } from "../shared/utils/MarkdownUtils";
|
|
45
|
+
import { CometChatRichTextFormatter } from "../shared/formatters/CometChatRichTextFormatter";
|
|
44
46
|
import { getMessagePreviewInternal } from "../shared/utils/MessageUtils";
|
|
45
47
|
import { CometChatBadge } from "../shared/views/CometChatBadge";
|
|
46
48
|
import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
|
|
@@ -68,6 +70,9 @@ const groupListenerId = "chatlist_group_" + new Date().getTime();
|
|
|
68
70
|
const messageListenerId = "chatlist_message_" + new Date().getTime();
|
|
69
71
|
const callListenerId = "call_" + new Date().getTime();
|
|
70
72
|
|
|
73
|
+
/** Module-level rich text formatter — reused across renders (no GC churn) */
|
|
74
|
+
const conversationRichTextFormatter = new CometChatRichTextFormatter();
|
|
75
|
+
|
|
71
76
|
/**
|
|
72
77
|
* Interface defining props for the CometChatConversations component.
|
|
73
78
|
*/
|
|
@@ -322,6 +327,22 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
322
327
|
// Merge theme styles with provided style overrides.
|
|
323
328
|
const theme = useTheme();
|
|
324
329
|
const { t } = useCometChatTranslation()
|
|
330
|
+
|
|
331
|
+
// Configure conversation subtitle formatter with theme-aware inline code colors
|
|
332
|
+
useMemo(() => {
|
|
333
|
+
conversationRichTextFormatter.setStyle({
|
|
334
|
+
inlineCodeStyle: {
|
|
335
|
+
color: theme.color.primary as string,
|
|
336
|
+
},
|
|
337
|
+
inlineCodeContainerStyle: {
|
|
338
|
+
backgroundColor: theme.color.background3 as string,
|
|
339
|
+
borderRadius: 2,
|
|
340
|
+
paddingHorizontal: 2,
|
|
341
|
+
paddingVertical: 0,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
}, [theme]);
|
|
345
|
+
|
|
325
346
|
const mergedStyles = useMemo(() => {
|
|
326
347
|
const baseStyles = deepMerge(theme.conversationStyles, style ?? {});
|
|
327
348
|
// Add search styling for CometChatList component
|
|
@@ -815,19 +836,73 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
815
836
|
let messageText: string | JSX.Element = "";
|
|
816
837
|
messageText = ChatConfigurator.getDataSource().getLastConversationMessage(conversations, theme);
|
|
817
838
|
|
|
818
|
-
|
|
839
|
+
// Detect block-level elements in text messages before stripMarkdown flattens them
|
|
840
|
+
let blockType: 'blockquote' | 'codeBlock' | 'list' | null = null;
|
|
841
|
+
let codeBlockLine = '';
|
|
842
|
+
let listPrefix = '';
|
|
843
|
+
if (
|
|
844
|
+
lastMessage instanceof CometChat.TextMessage &&
|
|
845
|
+
lastMessage.getCategory() === MessageCategoryConstants.message &&
|
|
846
|
+
typeof messageText === "string"
|
|
847
|
+
) {
|
|
848
|
+
const rawText = messageText;
|
|
849
|
+
const preview = preparePreviewText(rawText);
|
|
850
|
+
if (preview.isBlockquote) {
|
|
851
|
+
blockType = 'blockquote';
|
|
852
|
+
// Run formatter on content only (no `> ` prefix) so it won't re-parse as block
|
|
853
|
+
messageText = getFormattedText(lastMessage, preview.text.trim());
|
|
854
|
+
} else if (preview.codeBlockFirstLine !== null) {
|
|
855
|
+
blockType = 'codeBlock';
|
|
856
|
+
codeBlockLine = preview.codeBlockFirstLine;
|
|
857
|
+
} else if (preview.listPrefix) {
|
|
858
|
+
blockType = 'list';
|
|
859
|
+
listPrefix = preview.listPrefix;
|
|
860
|
+
messageText = getFormattedText(lastMessage, preview.text.trim());
|
|
861
|
+
} else {
|
|
862
|
+
messageText = getFormattedText(lastMessage, preview.text.trim());
|
|
863
|
+
}
|
|
864
|
+
} else if (lastMessage && typeof messageText === "string") {
|
|
819
865
|
messageText = getFormattedText(lastMessage, messageText?.trim());
|
|
820
866
|
}
|
|
867
|
+
|
|
821
868
|
if (
|
|
822
869
|
lastMessage instanceof CometChat.TextMessage &&
|
|
823
|
-
lastMessage.getCategory() ===
|
|
870
|
+
lastMessage.getCategory() === MessageCategoryConstants.message &&
|
|
824
871
|
(() => {
|
|
825
|
-
// Guard against undefined text or non-string values.
|
|
826
872
|
const text = typeof lastMessage.getText === "function" ? lastMessage.getText() : undefined;
|
|
827
873
|
return typeof text === "string" && text.slice(0, 50).match(/https?:\/\//);
|
|
828
874
|
})()
|
|
829
875
|
) {
|
|
830
876
|
messageText = getMessagePreviewInternal("link-fill", t("LINK"), { theme });
|
|
877
|
+
} else if (blockType === 'codeBlock') {
|
|
878
|
+
messageText = (
|
|
879
|
+
<View style={conversationPreviewStyles.codeBlockRow}>
|
|
880
|
+
<View style={[conversationPreviewStyles.codeBlockBadge, { backgroundColor: theme?.color?.background2 as string || '#FAFAFA', borderColor: theme?.color?.borderDefault as string || '#E8E8E8' }]}>
|
|
881
|
+
<Text numberOfLines={1} ellipsizeMode='tail' style={[conversationPreviewStyles.codeBlockText, { color: theme?.color?.textPrimary as string || '#141414' }]}>
|
|
882
|
+
{codeBlockLine + '..'}
|
|
883
|
+
</Text>
|
|
884
|
+
</View>
|
|
885
|
+
</View>
|
|
886
|
+
);
|
|
887
|
+
} else if (blockType === 'blockquote') {
|
|
888
|
+
messageText = (
|
|
889
|
+
<View style={conversationPreviewStyles.blockquoteRow}>
|
|
890
|
+
<View style={[conversationPreviewStyles.blockquoteBar, { backgroundColor: theme?.color?.primary as string }]} />
|
|
891
|
+
<Text numberOfLines={1} ellipsizeMode='tail' style={[mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.blockquoteText]}>
|
|
892
|
+
{messageText}
|
|
893
|
+
</Text>
|
|
894
|
+
</View>
|
|
895
|
+
);
|
|
896
|
+
} else if (blockType === 'list') {
|
|
897
|
+
messageText = (
|
|
898
|
+
<Text
|
|
899
|
+
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
900
|
+
numberOfLines={1}
|
|
901
|
+
ellipsizeMode='tail'
|
|
902
|
+
>
|
|
903
|
+
{listPrefix}{messageText}{'...'}
|
|
904
|
+
</Text>
|
|
905
|
+
);
|
|
831
906
|
} else if (messageText) {
|
|
832
907
|
messageText = (
|
|
833
908
|
<Text
|
|
@@ -874,11 +949,24 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
874
949
|
* @returns The formatted text.
|
|
875
950
|
*/
|
|
876
951
|
function getFormattedText(message: CometChat.BaseMessage, subtitle: string) {
|
|
877
|
-
|
|
952
|
+
// For text messages, use the rich text formatter to preserve inline styles
|
|
953
|
+
// (bold, italic, underline, strikethrough, inline code). The subtitle has
|
|
954
|
+
// already been processed by preparePreviewText which strips block-level
|
|
955
|
+
// markers, so the formatter will only encounter inline formatting.
|
|
956
|
+
let messageTextTmp: string | JSX.Element;
|
|
957
|
+
if (
|
|
958
|
+
message instanceof CometChat.TextMessage &&
|
|
959
|
+
message.getCategory() === MessageCategoryConstants.message
|
|
960
|
+
) {
|
|
961
|
+
const formatted = conversationRichTextFormatter.getFormattedText(subtitle);
|
|
962
|
+
messageTextTmp = formatted ?? subtitle;
|
|
963
|
+
} else {
|
|
964
|
+
// Non-text messages: strip markdown as before
|
|
965
|
+
messageTextTmp = stripMarkdown(subtitle);
|
|
966
|
+
}
|
|
878
967
|
let allFormatters = [...(textFormatters || [])];
|
|
879
|
-
// Detect presence of @all alias token in raw string
|
|
880
|
-
const containsAllAlias =
|
|
881
|
-
typeof messageTextTmp === "string" && /<@all:(.*?)>/.test(messageTextTmp);
|
|
968
|
+
// Detect presence of @all alias token in raw subtitle string (before formatting)
|
|
969
|
+
const containsAllAlias = /<@all:(.*?)>/.test(subtitle);
|
|
882
970
|
|
|
883
971
|
if (message.getMentionedUsers().length || containsAllAlias) {
|
|
884
972
|
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
|
|
@@ -890,7 +978,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
890
978
|
|
|
891
979
|
// Inject alias suggestion item if needed so formatter can render styled @All
|
|
892
980
|
if (containsAllAlias) {
|
|
893
|
-
const match =
|
|
981
|
+
const match = subtitle.match(/<@all:(.*?)>/);
|
|
894
982
|
const aliasLabel = match && match[1] ? match[1] : "all";
|
|
895
983
|
let existing = mentionsFormatter.getSuggestionItems();
|
|
896
984
|
const underlyingText = `<@all:${aliasLabel}>`;
|
|
@@ -913,7 +1001,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
913
1001
|
|
|
914
1002
|
if (
|
|
915
1003
|
message instanceof CometChat.TextMessage &&
|
|
916
|
-
message.getCategory() ===
|
|
1004
|
+
message.getCategory() === MessageCategoryConstants.message &&
|
|
917
1005
|
(() => {
|
|
918
1006
|
const text = typeof message.getText === "function" ? message.getText() : undefined;
|
|
919
1007
|
return typeof text === "string" && text.slice(0, 50).match(/https?:\/\//);
|
|
@@ -1765,3 +1853,44 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1765
1853
|
</View>
|
|
1766
1854
|
);
|
|
1767
1855
|
};
|
|
1856
|
+
|
|
1857
|
+
// Static styles for conversation preview block-level elements (code block, blockquote, list).
|
|
1858
|
+
// Theme-dependent values (colors) are applied inline via style array merging.
|
|
1859
|
+
const conversationPreviewStyles = StyleSheet.create({
|
|
1860
|
+
codeBlockRow: {
|
|
1861
|
+
flexDirection: 'row',
|
|
1862
|
+
alignItems: 'center',
|
|
1863
|
+
flexShrink: 2,
|
|
1864
|
+
},
|
|
1865
|
+
codeBlockBadge: {
|
|
1866
|
+
borderRadius: 4,
|
|
1867
|
+
borderWidth: 1,
|
|
1868
|
+
paddingHorizontal: 6,
|
|
1869
|
+
paddingVertical: 2,
|
|
1870
|
+
flexShrink: 1,
|
|
1871
|
+
},
|
|
1872
|
+
codeBlockText: {
|
|
1873
|
+
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
|
1874
|
+
fontSize: 11,
|
|
1875
|
+
},
|
|
1876
|
+
blockquoteRow: {
|
|
1877
|
+
flexDirection: 'row',
|
|
1878
|
+
alignItems: 'stretch',
|
|
1879
|
+
backgroundColor: 'rgba(104, 81, 214, 0.08)',
|
|
1880
|
+
borderRadius: 6,
|
|
1881
|
+
flexShrink: 2,
|
|
1882
|
+
minHeight: 22,
|
|
1883
|
+
paddingVertical: 1,
|
|
1884
|
+
},
|
|
1885
|
+
blockquoteBar: {
|
|
1886
|
+
width: 3,
|
|
1887
|
+
borderRadius: 1.5,
|
|
1888
|
+
marginVertical: 3,
|
|
1889
|
+
marginLeft: 4,
|
|
1890
|
+
},
|
|
1891
|
+
blockquoteText: {
|
|
1892
|
+
flex: 1,
|
|
1893
|
+
paddingHorizontal: 5,
|
|
1894
|
+
lineHeight: 18,
|
|
1895
|
+
},
|
|
1896
|
+
});
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
messageStatus,
|
|
56
56
|
} from "../shared/utils/CometChatMessageHelper";
|
|
57
57
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
58
|
+
import { isCursorWithinMentionRange, getMentionRangeAtCursor } from "../shared/utils/MentionUtils";
|
|
58
59
|
import { permissionUtil } from "../shared/utils/PermissionUtil";
|
|
59
60
|
import { CometChatMediaRecorder } from "../shared/views/CometChatMediaRecorder";
|
|
60
61
|
import { useTheme } from "../theme";
|
|
@@ -105,6 +106,7 @@ const ActionSheetBoard = (props: any) => {
|
|
|
105
106
|
ref={sheetRef}
|
|
106
107
|
onClose={onClose}
|
|
107
108
|
isOpen={shouldShow}
|
|
109
|
+
doNotOccupyEntireHeight
|
|
108
110
|
>
|
|
109
111
|
<CometChatActionSheet actions={options} style={style} />
|
|
110
112
|
</CometChatBottomSheet>
|
|
@@ -132,6 +134,7 @@ const RecordAudio = (props: any) => {
|
|
|
132
134
|
onClose={onClose}
|
|
133
135
|
style={cometChatBottomSheetStyle}
|
|
134
136
|
isOpen={shouldShow}
|
|
137
|
+
doNotOccupyEntireHeight
|
|
135
138
|
>
|
|
136
139
|
<CometChatMediaRecorder
|
|
137
140
|
onClose={onClose}
|
|
@@ -1151,6 +1154,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1151
1154
|
url: messageInput["uri"],
|
|
1152
1155
|
sender: loggedInUser.current,
|
|
1153
1156
|
attachments: [messageInput],
|
|
1157
|
+
entities: {
|
|
1158
|
+
sender: {
|
|
1159
|
+
entity: loggedInUser.current,
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1154
1162
|
});
|
|
1155
1163
|
|
|
1156
1164
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
@@ -1172,18 +1180,34 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1172
1180
|
});
|
|
1173
1181
|
}
|
|
1174
1182
|
setReplyMessage(null);
|
|
1183
|
+
setWarningMessage("");
|
|
1175
1184
|
setShowRecordAudio(false);
|
|
1176
1185
|
})
|
|
1177
1186
|
.catch((error: any) => {
|
|
1178
1187
|
setShowRecordAudio(false);
|
|
1188
|
+
if (error?.code === "ERR_PERMISSION_DENIED") {
|
|
1189
|
+
onError && onError(error);
|
|
1190
|
+
// Set error in data.metaData where the message list receipt logic checks
|
|
1191
|
+
const currentData = localMessage.getData() || {};
|
|
1192
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1193
|
+
localMessage.setMetadata({ error: true });
|
|
1194
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1195
|
+
message: localMessage,
|
|
1196
|
+
status: messageStatus.error,
|
|
1197
|
+
});
|
|
1198
|
+
setReplyMessage(null);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1179
1201
|
onError && onError(error);
|
|
1202
|
+
// Set error in data.metaData where the message list receipt logic checks
|
|
1203
|
+
const currentData = localMessage.getData() || {};
|
|
1204
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1180
1205
|
localMessage.setMetadata({ error: true });
|
|
1181
1206
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1182
1207
|
message: localMessage,
|
|
1183
1208
|
status: messageStatus.error,
|
|
1184
1209
|
});
|
|
1185
1210
|
setReplyMessage(null);
|
|
1186
|
-
// console.log("media message sent error", error); // Removed debug log
|
|
1187
1211
|
});
|
|
1188
1212
|
};
|
|
1189
1213
|
|
|
@@ -1650,26 +1674,6 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1650
1674
|
// console.log("Send Audio"); // Removed debug log
|
|
1651
1675
|
};
|
|
1652
1676
|
|
|
1653
|
-
function isCursorWithinMentionRange(mentionRanges: any, cursorPosition: number) {
|
|
1654
|
-
for (let [range, mention] of mentionRanges) {
|
|
1655
|
-
const [start, end] = range.split("_").map(Number);
|
|
1656
|
-
if (cursorPosition >= start && cursorPosition <= end) {
|
|
1657
|
-
return true; // Cursor is within the range of a mention
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
return false; // No mention found at the cursor position
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
function getMentionRangeAtCursor(mentionRanges: any, cursorPosition: number): { start: number; end: number } | null {
|
|
1664
|
-
for (let [range] of mentionRanges) {
|
|
1665
|
-
const [start, end] = range.split("_").map(Number);
|
|
1666
|
-
if (cursorPosition >= start && cursorPosition <= end) {
|
|
1667
|
-
return { start, end }; // Return the boundary positions
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
return null; // No mention found at the cursor position
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
1677
|
function shouldOpenList(
|
|
1674
1678
|
selection: {
|
|
1675
1679
|
start: number;
|
|
@@ -75,9 +75,9 @@ import { CometChatAvatar } from "../shared/views/CometChatAvatar";
|
|
|
75
75
|
import { CometChatBadge } from "../shared/views/CometChatBadge";
|
|
76
76
|
import { CometChatDate } from "../shared/views/CometChatDate";
|
|
77
77
|
import { CometChatMessageBubble } from "../shared/views/CometChatMessageBubble";
|
|
78
|
-
import { getModerationStatus, ModerationBottomView } from "../shared/utils/MessageUtils";
|
|
78
|
+
import { getModerationStatus, ModerationBottomView, MimeErrorBottomView } from "../shared/utils/MessageUtils";
|
|
79
79
|
import { CometChatReactions } from "../shared/views/CometChatReactions";
|
|
80
|
-
import { useTheme } from "../theme";
|
|
80
|
+
import { useTheme, useThemeInternal } from "../theme";
|
|
81
81
|
import { MessageSkeleton } from "./Skeleton";
|
|
82
82
|
import { ErrorEmptyView } from "../shared/views/ErrorEmptyView/ErrorEmptyView";
|
|
83
83
|
import { BubbleStyles, CometChatTheme } from "../theme/type";
|
|
@@ -715,6 +715,8 @@ export const CometChatMessageList = memo(
|
|
|
715
715
|
}, [hideGroupActionMessages, isAgenticUser, parentMessageId]);
|
|
716
716
|
|
|
717
717
|
const theme = useTheme();
|
|
718
|
+
const themeInternal = useThemeInternal();
|
|
719
|
+
const themeMode = themeInternal.mode; // 'light' or 'dark' - used for FlatList extraData
|
|
718
720
|
const { t } = useCometChatTranslation();
|
|
719
721
|
|
|
720
722
|
const mergedTheme: CometChatTheme = useMemo(() => {
|
|
@@ -3043,11 +3045,17 @@ export const CometChatMessageList = memo(
|
|
|
3043
3045
|
messagesContentListRef.current[currentIndex! - 1].getDeliveredAt();
|
|
3044
3046
|
// Moderation status should override other receipt states for immediate error display
|
|
3045
3047
|
const moderationStatus = getModerationStatus(item);
|
|
3046
|
-
|
|
3048
|
+
|
|
3049
|
+
// Check error metadata FIRST before sentAt/deliveredAt/readAt
|
|
3050
|
+
const hasErrorMetadata = item?.getData?.()?.metaData?.error;
|
|
3051
|
+
const hasErrorInMetadata = item?.getMetadata?.()?.error;
|
|
3052
|
+
const hasErrorProp = (item as any)?.error;
|
|
3053
|
+
if (hasErrorMetadata || hasErrorInMetadata || hasErrorProp) {
|
|
3054
|
+
messageState = MessageReceipt.ERROR;
|
|
3055
|
+
} else if (item.getReadAt() || nextItemIsRead) messageState = MessageReceipt.READ;
|
|
3047
3056
|
else if (item.getDeliveredAt() || nextItemIsDelivered)
|
|
3048
3057
|
messageState = MessageReceipt.DELIVERED;
|
|
3049
3058
|
else if (item.getSentAt()) messageState = MessageReceipt.SENT;
|
|
3050
|
-
else if (item?.getData()?.metaData?.error) messageState = MessageReceipt.ERROR;
|
|
3051
3059
|
else if (isOutgoingMessage) messageState = MessageReceipt.WAIT;
|
|
3052
3060
|
else messageState = MessageReceipt.ERROR;
|
|
3053
3061
|
|
|
@@ -3321,7 +3329,12 @@ export const CometChatMessageList = memo(
|
|
|
3321
3329
|
const copyMessage = (item: any) => {
|
|
3322
3330
|
let copyMessage = getPlainString(item["text"], item);
|
|
3323
3331
|
Clipboard.setString(copyMessage);
|
|
3324
|
-
|
|
3332
|
+
// Defer modal dismiss to next frame to avoid Fabric race condition
|
|
3333
|
+
// where unmounting the Modal while Clipboard is still accessing views
|
|
3334
|
+
// causes EXC_BAD_ACCESS (SIGSEGV) at null pointer in mount phase.
|
|
3335
|
+
requestAnimationFrame(() => {
|
|
3336
|
+
setShowMessageOptions([]);
|
|
3337
|
+
});
|
|
3325
3338
|
};
|
|
3326
3339
|
|
|
3327
3340
|
const getThreadView = useCallback(
|
|
@@ -3409,6 +3422,9 @@ export const CometChatMessageList = memo(
|
|
|
3409
3422
|
if (hideFlagMessageOption) {
|
|
3410
3423
|
options = options.filter((opt: any) => opt.id !== MessageOptionConstants.reportMessage);
|
|
3411
3424
|
}
|
|
3425
|
+
if (hideMarkAsUnreadOption) {
|
|
3426
|
+
options = options.filter((opt: any) => opt.id !== MessageOptionConstants.markAsUnread);
|
|
3427
|
+
}
|
|
3412
3428
|
let optionsWithPressHandling = options.map((option) => {
|
|
3413
3429
|
if (!option.onPress)
|
|
3414
3430
|
switch (option.id) {
|
|
@@ -3562,6 +3578,20 @@ export const CometChatMessageList = memo(
|
|
|
3562
3578
|
const BottomView = useMemo(() => {
|
|
3563
3579
|
const moderationStatus = getModerationStatus(message);
|
|
3564
3580
|
const isOutgoing = message.getSender()?.getUid() === loggedInUser.current?.getUid();
|
|
3581
|
+
|
|
3582
|
+
// Check for MIME type error (ERR_PERMISSION_DENIED)
|
|
3583
|
+
const hasErrorMetadata = (message as any)?.getData?.()?.metaData?.error;
|
|
3584
|
+
const hasErrorInMetadata = (message as any)?.getMetadata?.()?.error;
|
|
3585
|
+
if (isOutgoing && (hasErrorMetadata || hasErrorInMetadata) && !isAgenticUser) {
|
|
3586
|
+
return (
|
|
3587
|
+
<MimeErrorBottomView
|
|
3588
|
+
moderationStyle={
|
|
3589
|
+
mergedTheme.messageListStyles.outgoingMessageBubbleStyles.moderationStyle
|
|
3590
|
+
}
|
|
3591
|
+
/>
|
|
3592
|
+
);
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3565
3595
|
if (effectiveHideModeration) {
|
|
3566
3596
|
return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
|
|
3567
3597
|
} else {
|
|
@@ -3847,7 +3877,7 @@ export const CometChatMessageList = memo(
|
|
|
3847
3877
|
</React.Fragment>
|
|
3848
3878
|
);
|
|
3849
3879
|
},
|
|
3850
|
-
[] //
|
|
3880
|
+
[themeMode] // Only recreate when theme mode changes - MessageView accessed via closure
|
|
3851
3881
|
);
|
|
3852
3882
|
|
|
3853
3883
|
const keyExtractor = useCallback((item: any, index: number) => {
|
|
@@ -4374,6 +4404,7 @@ export const CometChatMessageList = memo(
|
|
|
4374
4404
|
isHighlighted={isHighlighted}
|
|
4375
4405
|
highlightAnimatedValue={highlightAnimatedValue}
|
|
4376
4406
|
theme={mergedTheme}
|
|
4407
|
+
themeMode={themeMode}
|
|
4377
4408
|
timestamp={ms}
|
|
4378
4409
|
dayHeaderString={dayHeaderString}
|
|
4379
4410
|
RenderMessageItem={RenderMessageItem}
|
|
@@ -4390,6 +4421,7 @@ export const CometChatMessageList = memo(
|
|
|
4390
4421
|
},
|
|
4391
4422
|
[
|
|
4392
4423
|
mergedTheme,
|
|
4424
|
+
themeMode,
|
|
4393
4425
|
highlightedMessageId,
|
|
4394
4426
|
highlightAnimatedValue,
|
|
4395
4427
|
sentAtToMs,
|
|
@@ -4458,6 +4490,7 @@ export const CometChatMessageList = memo(
|
|
|
4458
4490
|
scrollEventThrottle={16}
|
|
4459
4491
|
keyboardShouldPersistTaps={(Platform.OS === "ios" ? "handled" : "always") as "handled" | "always"}
|
|
4460
4492
|
data={messagesList}
|
|
4493
|
+
extraData={themeMode}
|
|
4461
4494
|
keyExtractor={keyExtractor}
|
|
4462
4495
|
renderItem={memoizedRenderItem}
|
|
4463
4496
|
ListHeaderComponent={renderFooter}
|
|
@@ -14,6 +14,7 @@ interface MessageListItemProps {
|
|
|
14
14
|
isHighlighted: boolean;
|
|
15
15
|
highlightAnimatedValue: Animated.Value;
|
|
16
16
|
theme: CometChatTheme;
|
|
17
|
+
themeMode: string;
|
|
17
18
|
timestamp: number;
|
|
18
19
|
dayHeaderString: string | undefined;
|
|
19
20
|
RenderMessageItem: React.ComponentType<any>;
|
|
@@ -33,6 +34,7 @@ const MessageListItemComponent: React.FC<MessageListItemProps> = ({
|
|
|
33
34
|
isHighlighted,
|
|
34
35
|
highlightAnimatedValue,
|
|
35
36
|
theme,
|
|
37
|
+
themeMode,
|
|
36
38
|
timestamp,
|
|
37
39
|
dayHeaderString,
|
|
38
40
|
RenderMessageItem,
|
|
@@ -99,9 +101,12 @@ const MessageListItemComponent: React.FC<MessageListItemProps> = ({
|
|
|
99
101
|
export const MessageListItem = memo(MessageListItemComponent, (prevProps, nextProps) => {
|
|
100
102
|
// Return true if props are equal (skip re-render)
|
|
101
103
|
// Return false if props changed (re-render needed)
|
|
102
|
-
|
|
104
|
+
|
|
103
105
|
const itemUnchanged = prevProps.item === nextProps.item;
|
|
104
|
-
|
|
106
|
+
|
|
107
|
+
// Theme mode change should trigger re-render for theme updates
|
|
108
|
+
const themeModeUnchanged = prevProps.themeMode === nextProps.themeMode;
|
|
109
|
+
|
|
105
110
|
const visualsUnchanged =
|
|
106
111
|
prevProps.isHighlighted === nextProps.isHighlighted &&
|
|
107
112
|
prevProps.showSeparator === nextProps.showSeparator &&
|
|
@@ -109,19 +114,17 @@ export const MessageListItem = memo(MessageListItemComponent, (prevProps, nextPr
|
|
|
109
114
|
prevProps.dayHeaderString === nextProps.dayHeaderString &&
|
|
110
115
|
prevProps.showNewMessageIndicator === nextProps.showNewMessageIndicator &&
|
|
111
116
|
prevProps.newMessageIndicatorText === nextProps.newMessageIndicatorText;
|
|
112
|
-
|
|
117
|
+
|
|
113
118
|
const styleUnchanged =
|
|
114
|
-
prevProps.theme === nextProps.theme &&
|
|
115
119
|
prevProps.staticStyles === nextProps.staticStyles &&
|
|
116
120
|
prevProps.newMessageIndicatorStyle === nextProps.newMessageIndicatorStyle;
|
|
117
|
-
|
|
121
|
+
|
|
118
122
|
const functionsUnchanged =
|
|
119
|
-
prevProps.RenderMessageItem === nextProps.RenderMessageItem &&
|
|
120
123
|
prevProps.itemSeparator === nextProps.itemSeparator &&
|
|
121
124
|
prevProps.highlightAnimatedValue === nextProps.highlightAnimatedValue &&
|
|
122
125
|
prevProps.onLayout === nextProps.onLayout;
|
|
123
|
-
|
|
124
|
-
return itemUnchanged && visualsUnchanged && styleUnchanged && functionsUnchanged;
|
|
126
|
+
|
|
127
|
+
return itemUnchanged && themeModeUnchanged && visualsUnchanged && styleUnchanged && functionsUnchanged;
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
MessageListItem.displayName = 'MessageListItem';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
2
|
+
import { requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type Double = number;
|
|
5
|
+
type Int32 = number;
|
|
6
|
+
type DirectEventHandler<T> = (event: { nativeEvent: T }) => void;
|
|
7
|
+
|
|
8
|
+
// New prop types for CometChat integration
|
|
9
|
+
type SelectionProp = Readonly<{
|
|
10
|
+
start: Int32;
|
|
11
|
+
end: Int32;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
type TextStyleProp = Readonly<{
|
|
15
|
+
fontSize?: Double;
|
|
16
|
+
color?: string;
|
|
17
|
+
fontFamily?: string;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export type StyleRange = Readonly<{
|
|
21
|
+
style: string;
|
|
22
|
+
start: Int32;
|
|
23
|
+
end: Int32;
|
|
24
|
+
url?: string;
|
|
25
|
+
highlightColor?: string;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
export type Block = Readonly<{
|
|
29
|
+
type: string;
|
|
30
|
+
text: string;
|
|
31
|
+
styles: ReadonlyArray<StyleRange>;
|
|
32
|
+
alignment?: string;
|
|
33
|
+
checked?: boolean;
|
|
34
|
+
indentLevel?: Int32;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
type ContentChangeEventData = Readonly<{
|
|
38
|
+
text: string;
|
|
39
|
+
blocksJson: string;
|
|
40
|
+
}>;
|
|
41
|
+
|
|
42
|
+
type SelectionChangeEventData = Readonly<{
|
|
43
|
+
start: Int32;
|
|
44
|
+
end: Int32;
|
|
45
|
+
}>;
|
|
46
|
+
|
|
47
|
+
type SizeChangeEventData = Readonly<{
|
|
48
|
+
height: Double;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
type ActiveStylesEventData = Readonly<{
|
|
52
|
+
bold: boolean;
|
|
53
|
+
italic: boolean;
|
|
54
|
+
underline: boolean;
|
|
55
|
+
strikethrough: boolean;
|
|
56
|
+
code: boolean;
|
|
57
|
+
codeBlock: boolean;
|
|
58
|
+
highlight: boolean;
|
|
59
|
+
blockType: string;
|
|
60
|
+
alignment: string;
|
|
61
|
+
}>;
|
|
62
|
+
|
|
63
|
+
type LinkTapEventData = Readonly<{
|
|
64
|
+
url: string;
|
|
65
|
+
text: string;
|
|
66
|
+
location: Int32;
|
|
67
|
+
length: Int32;
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
export interface NativeProps extends ViewProps {
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
editable?: boolean;
|
|
73
|
+
maxHeight?: Double;
|
|
74
|
+
numberOfLines?: Int32;
|
|
75
|
+
showToolbar?: boolean;
|
|
76
|
+
toolbarOptions?: ReadonlyArray<string>;
|
|
77
|
+
variant?: string;
|
|
78
|
+
initialContentJson?: string;
|
|
79
|
+
toolbarMode?: string;
|
|
80
|
+
enterKeyBehavior?: string;
|
|
81
|
+
|
|
82
|
+
// New props for CometChat integration
|
|
83
|
+
selection?: SelectionProp;
|
|
84
|
+
textStyle?: TextStyleProp;
|
|
85
|
+
placeholderTextColor?: string;
|
|
86
|
+
text?: string;
|
|
87
|
+
showTextSelectionMenuItems?: boolean;
|
|
88
|
+
codeBackgroundColor?: string;
|
|
89
|
+
codeBorderColor?: string;
|
|
90
|
+
codeTextColor?: string;
|
|
91
|
+
codeFontSize?: Double;
|
|
92
|
+
|
|
93
|
+
onContentChange?: DirectEventHandler<ContentChangeEventData>;
|
|
94
|
+
onSelectionChange?: DirectEventHandler<SelectionChangeEventData>;
|
|
95
|
+
onEditorFocus?: DirectEventHandler<Readonly<{}>>;
|
|
96
|
+
onEditorBlur?: DirectEventHandler<Readonly<{}>>;
|
|
97
|
+
onSizeChange?: DirectEventHandler<SizeChangeEventData>;
|
|
98
|
+
onActiveStylesChange?: DirectEventHandler<ActiveStylesEventData>;
|
|
99
|
+
onLinkTap?: DirectEventHandler<LinkTapEventData>;
|
|
100
|
+
onSendRequest?: DirectEventHandler<Readonly<{}>>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default requireNativeComponent<NativeProps>(
|
|
104
|
+
'RichTextEditorView',
|
|
105
|
+
) as HostComponent<NativeProps>;
|