The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/components/CustomText.tsx

29 lines
932 B

import React, { memo, ReactElement } from 'react';
import { highlightWords as getHighlightHtml } from '../../app/highlight-words/client/helper';
import Katex from './Katex';
type CustomTextProps = {
text: string;
wordsToHighlight?: {
highlight: string;
regex: RegExp;
urlRegex: RegExp;
}[];
katex?: {
dollarSyntaxEnabled: boolean;
parenthesisSyntaxEnabled: boolean;
};
};
const CustomText = ({ text, wordsToHighlight, katex }: CustomTextProps): ReactElement => {
// TODO: chapter day frontend: remove dangerouslySetInnerHTML, convert to tokens and do not mix with katex
const html = wordsToHighlight?.length ? getHighlightHtml(text, wordsToHighlight) : text;
if (katex) {
return <Katex text={html} options={{ dollarSyntax: katex.dollarSyntaxEnabled, parenthesisSyntax: katex.parenthesisSyntaxEnabled }} />;
}
return <span dangerouslySetInnerHTML={{ __html: html }} />;
};
export default memo(CustomText);