@cometchat/chat-uikit-react-native 5.3.2 → 5.3.4
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/src/main/java/com/reactnativecometchatuikit/CometChatWebView.java +9 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +16 -10
- package/ios/RichTextEditorView.swift +49 -2
- package/ios/WebViewManager.m +13 -2
- package/package.json +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +50 -30
- package/src/CometChatConversations/CometChatConversations.tsx +23 -42
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +3 -3
- package/src/CometChatMessageList/CometChatMessageList.tsx +53 -11
- package/src/shared/constants/UIKitConstants.ts +1 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +6 -4
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +93 -27
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -2
- package/src/shared/framework/MessageDataSource.tsx +10 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +2 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +2 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +26 -23
- package/src/shared/utils/MarkdownUtils.ts +6 -1
- package/src/shared/utils/MessageUtils.tsx +66 -1
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +1 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +26 -10
- package/src/theme/CometChatThemeHelper.ts +9 -0
- package/src/theme/default/color/dark.ts +13 -0
- package/src/theme/default/color/light.ts +13 -1
|
@@ -159,7 +159,29 @@ export const CometChatTextBubbleText = (
|
|
|
159
159
|
const isViewBased = React.isValidElement(formattedText) &&
|
|
160
160
|
(formattedText as React.ReactElement<any>).type === View;
|
|
161
161
|
|
|
162
|
-
//
|
|
162
|
+
// For View-based content, count children to determine truncatability and slice when collapsed.
|
|
163
|
+
// This avoids pixel-based clipping that cuts through the middle of list items.
|
|
164
|
+
const viewChildren = useMemo(() => {
|
|
165
|
+
if (!isViewBased) return null;
|
|
166
|
+
const children = React.Children.toArray(
|
|
167
|
+
(formattedText as React.ReactElement<any>).props.children
|
|
168
|
+
).filter(React.isValidElement) as React.ReactElement<any>[];
|
|
169
|
+
return children;
|
|
170
|
+
}, [isViewBased, formattedText]);
|
|
171
|
+
|
|
172
|
+
const viewChildCount = viewChildren?.length ?? 0;
|
|
173
|
+
const isViewTruncatable = isViewBased && viewChildCount > collapseLines;
|
|
174
|
+
|
|
175
|
+
// Memoize styled children to avoid re-running applyTextStyleDeep on every render/toggle
|
|
176
|
+
const styledViewChildren = useMemo(() => {
|
|
177
|
+
if (!viewChildren) return null;
|
|
178
|
+
return viewChildren.map((child) => {
|
|
179
|
+
if (!React.isValidElement(child)) return child;
|
|
180
|
+
return applyTextStyleDeep(child as React.ReactElement<any>, textStyle);
|
|
181
|
+
});
|
|
182
|
+
}, [viewChildren, textStyle]);
|
|
183
|
+
|
|
184
|
+
// Only measure string content via onTextLayout — View-based uses child count instead
|
|
163
185
|
const needsMeasurement = containerWidth !== null && !isViewBased && !measuredCacheRef.current[hiddenTextKey];
|
|
164
186
|
|
|
165
187
|
return (
|
|
@@ -181,15 +203,9 @@ export const CometChatTextBubbleText = (
|
|
|
181
203
|
)}
|
|
182
204
|
|
|
183
205
|
{/* Visible text — View-based content (blockquotes, lists) rendered directly */}
|
|
184
|
-
{isViewBased ? (
|
|
206
|
+
{isViewBased && styledViewChildren ? (
|
|
185
207
|
<View style={VIEW_BASED_WRAPPER_STYLE}>
|
|
186
|
-
{
|
|
187
|
-
(formattedText as React.ReactElement<any>).props.children,
|
|
188
|
-
(child) => {
|
|
189
|
-
if (!React.isValidElement(child)) return child;
|
|
190
|
-
return applyTextStyleDeep(child as React.ReactElement<any>, textStyle);
|
|
191
|
-
}
|
|
192
|
-
)}
|
|
208
|
+
{isExpanded || !isViewTruncatable ? styledViewChildren : styledViewChildren.slice(0, collapseLines)}
|
|
193
209
|
</View>
|
|
194
210
|
) : (
|
|
195
211
|
<Text
|
|
@@ -202,7 +218,7 @@ export const CometChatTextBubbleText = (
|
|
|
202
218
|
)}
|
|
203
219
|
|
|
204
220
|
{/* Toggle - only show after measurement is complete to prevent flicker */}
|
|
205
|
-
{measurementComplete && isTruncatable && (
|
|
221
|
+
{((measurementComplete && isTruncatable) || isViewTruncatable) && (
|
|
206
222
|
<View style={[{ alignItems: "flex-end", marginTop: 6 }, toggleContainerStyle]}>
|
|
207
223
|
<TouchableOpacity onPress={toggle} accessibilityRole='button'>
|
|
208
224
|
<Text style={[{ alignSelf: "flex-end" }, textStyle, toggleTextStyle]}>
|
|
@@ -267,6 +267,15 @@ export class CometChatThemeHelper {
|
|
|
267
267
|
color.receiveBubbleIcon =
|
|
268
268
|
color.receiveBubbleIcon === undefined ? color.primary : color.receiveBubbleIcon;
|
|
269
269
|
|
|
270
|
+
color.previewInlineCodeBackground =
|
|
271
|
+
color.previewInlineCodeBackground === undefined ? defaultColor.previewInlineCodeBackground : color.previewInlineCodeBackground;
|
|
272
|
+
|
|
273
|
+
color.previewCodeBlockBackground =
|
|
274
|
+
color.previewCodeBlockBackground === undefined ? defaultColor.previewCodeBlockBackground : color.previewCodeBlockBackground;
|
|
275
|
+
|
|
276
|
+
color.previewCodeBlockBorder =
|
|
277
|
+
color.previewCodeBlockBorder === undefined ? defaultColor.previewCodeBlockBorder : color.previewCodeBlockBorder;
|
|
278
|
+
|
|
270
279
|
return color;
|
|
271
280
|
}
|
|
272
281
|
|
|
@@ -40,6 +40,12 @@ const staticColors = {
|
|
|
40
40
|
staticWhite: "#FFFFFF",
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const overlayColors = {
|
|
44
|
+
overlayLight: neutralColors.neutral300,
|
|
45
|
+
overlayCodeBlock: "rgba(255, 255, 255, 0.20)",
|
|
46
|
+
overlayCodeBlockBorder: "rgba(255, 255, 255, 0.30)",
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
export const defaultColorDark: Color = {
|
|
44
50
|
primary: primaryColor,
|
|
45
51
|
...extendedPrimaryColors,
|
|
@@ -96,4 +102,11 @@ export const defaultColorDark: Color = {
|
|
|
96
102
|
receiveBubbleLink: alertColors.info,
|
|
97
103
|
receiveBubbleTimestamp: neutralColors.neutral600,
|
|
98
104
|
receiveBubbleIcon: primaryColor,
|
|
105
|
+
|
|
106
|
+
// Reply preview inline code background
|
|
107
|
+
previewInlineCodeBackground: overlayColors.overlayLight,
|
|
108
|
+
// Reply preview code block background
|
|
109
|
+
previewCodeBlockBackground: overlayColors.overlayCodeBlock,
|
|
110
|
+
// Reply preview code block border
|
|
111
|
+
previewCodeBlockBorder: overlayColors.overlayCodeBlockBorder,
|
|
99
112
|
};
|
|
@@ -40,6 +40,12 @@ const staticColors = {
|
|
|
40
40
|
staticWhite: "#FFFFFF",
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const overlayColors = {
|
|
44
|
+
overlayLight: "rgba(120, 120, 128, 0.70)",
|
|
45
|
+
overlayCodeBlock: "rgba(255, 255, 255, 0.20)",
|
|
46
|
+
overlayCodeBlockBorder: neutralColors.neutral300,
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
export const defaultColorLight = {
|
|
44
50
|
primary: primaryColor,
|
|
45
51
|
...extendedPrimaryColors,
|
|
@@ -96,8 +102,14 @@ export const defaultColorLight = {
|
|
|
96
102
|
receiveBubbleLink: alertColors.info,
|
|
97
103
|
receiveBubbleTimestamp: neutralColors.neutral600,
|
|
98
104
|
receiveBubbleIcon: primaryColor,
|
|
99
|
-
};
|
|
100
105
|
|
|
106
|
+
// Reply preview inline code background
|
|
107
|
+
previewInlineCodeBackground: overlayColors.overlayLight,
|
|
108
|
+
// Reply preview code block background
|
|
109
|
+
previewCodeBlockBackground: overlayColors.overlayCodeBlock,
|
|
110
|
+
// Reply preview code block border
|
|
111
|
+
previewCodeBlockBorder: overlayColors.overlayCodeBlockBorder,
|
|
112
|
+
};
|
|
101
113
|
type EachColorValue<T extends typeof defaultColorLight> = {
|
|
102
114
|
[P in keyof T]: ColorValue;
|
|
103
115
|
};
|