Rocket.Chat.ReactNative/app/containers/markdown/Preview.tsx

37 lines
812 B
TypeScript
Raw Normal View History

import React from 'react';
import { Text, TextStyle } from 'react-native';
import { themes } from '../../lib/constants';
import { useTheme } from '../../theme';
import styles from './styles';
import { previewFormatText } from './previewFormatText';
interface IMarkdownPreview {
msg?: string;
numberOfLines?: number;
testID?: string;
style?: TextStyle[];
}
const MarkdownPreview = ({ msg, numberOfLines = 1, style = [], testID }: IMarkdownPreview) => {
const { theme } = useTheme();
if (!msg) {
return null;
}
const m = previewFormatText(msg);
return (
<Text
accessibilityLabel={m}
style={[styles.text, { color: themes[theme].bodyText }, ...style]}
numberOfLines={numberOfLines}
2023-07-04 18:47:53 +00:00
testID={testID || `markdown-preview-${m}`}
>
{m}
</Text>
);
};
export default MarkdownPreview;