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/app/highlight-words/client/client.js

18 lines
489 B

import { highlightWords, getRegexHighlight, getRegexHighlightUrl } from './helper';
export const createHighlightWordsMessageRenderer = ({ wordsToHighlight }) => {
const highlights = wordsToHighlight.map((highlight) => ({
highlight,
regex: getRegexHighlight(highlight),
urlRegex: getRegexHighlightUrl(highlight),
}));
return (message) => {
if (!message.html?.trim()) {
return message;
}
message.html = highlightWords(message.html, highlights);
return message;
};
};