From 6b0d2d68e6ca5009d32d9fa81d383617ecc05a22 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Sat, 20 Apr 2024 09:12:49 +0700 Subject: [PATCH] render emojis as EmojiWithTooltip instead of Text to keep emoji tooltip --- src/components/InlineCodeBlock/index.native.tsx | 4 ++-- src/components/InlineCodeBlock/index.tsx | 4 ++-- ...mojisAsTextComponents.tsx => renderEmojis.tsx} | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) rename src/components/InlineCodeBlock/{renderEmojisAsTextComponents.tsx => renderEmojis.tsx} (74%) diff --git a/src/components/InlineCodeBlock/index.native.tsx b/src/components/InlineCodeBlock/index.native.tsx index 099ae9e48613..c6969e91934b 100644 --- a/src/components/InlineCodeBlock/index.native.tsx +++ b/src/components/InlineCodeBlock/index.native.tsx @@ -1,13 +1,13 @@ import React from 'react'; import useThemeStyles from '@hooks/useThemeStyles'; -import renderEmojisAsTextComponents from './renderEmojisAsTextComponents'; +import renderEmojis from './renderEmojis'; import type InlineCodeBlockProps from './types'; import type {TTextOrTPhrasing} from './types'; import WrappedText from './WrappedText'; function InlineCodeBlock({TDefaultRenderer, defaultRendererProps, textStyle, boxModelStyle}: InlineCodeBlockProps) { const styles = useThemeStyles(); - const {elements, hasLargeStyle} = renderEmojisAsTextComponents(defaultRendererProps, styles); + const {elements, hasLargeStyle} = renderEmojis(defaultRendererProps, styles); return ( ({TDefaultRenderer, const styles = useThemeStyles(); const flattenTextStyle = StyleSheet.flatten(textStyle); const {textDecorationLine, ...textStyles} = flattenTextStyle; - const {elements, hasLargeStyle} = renderEmojisAsTextComponents(defaultRendererProps, styles); + const {elements, hasLargeStyle} = renderEmojis(defaultRendererProps, styles); return ( , styles: ThemeStyles) { +function renderEmojis(defaultRendererProps: TDefaultRendererProps, styles: ThemeStyles) { const elements: Array = []; let hasLargeStyle = false; @@ -28,12 +28,11 @@ function renderEmojisAsTextComponents(defaultRendererProps: TDefaultRendererProp hasLargeStyle = true; } elements.push( - - {child.data} - , + emojiCode={child.data} + />, ); } else { elements.push(child.data); @@ -43,4 +42,4 @@ function renderEmojisAsTextComponents(defaultRendererProps: TDefaultRendererProp return {elements, hasLargeStyle}; } -export default renderEmojisAsTextComponents; +export default renderEmojis;