fix: add a style to prevent Android from breaking when rendering a katex via webview (#5570)

This commit is contained in:
Gleidson Daniel Silva 2024-02-19 12:06:09 -03:00 committed by GitHub
parent 1beb0d0efa
commit c4a3f9ce19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -1,9 +1,11 @@
import React from 'react';
import { KaTeX as KaTeXProps } from '@rocket.chat/message-parser';
import React from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import Katex from 'react-native-katex';
// eslint-disable-next-line import/no-unresolved
import MathView, { MathText } from 'react-native-math-view';
import Katex from 'react-native-katex';
import { isAndroid } from '../../../lib/methods/helpers';
import { useTheme } from '../../../theme';
import { DEFAULT_MESSAGE_HEIGHT } from '../../message/utils';
@ -13,11 +15,14 @@ interface IKaTeXProps {
export const KaTeX = ({ value }: IKaTeXProps): React.ReactElement | null => {
const { colors } = useTheme();
const fixAndroidWebviewCrashStyle: StyleProp<ViewStyle> = isAndroid ? { opacity: 0.99, overflow: 'hidden' } : {};
return (
<MathView
math={value}
style={{ color: colors.bodyText }}
renderError={() => <Katex expression={value} style={{ flex: 1, height: DEFAULT_MESSAGE_HEIGHT }} />}
renderError={() => (
<Katex expression={value} style={[{ flex: 1, height: DEFAULT_MESSAGE_HEIGHT }, fixAndroidWebviewCrashStyle]} />
)}
/>
);
};