Files
talk/client/coral-admin/src/components/CommentBodyHighlighter.js
T
2017-08-17 13:12:07 -03:00

25 lines
524 B
JavaScript

import React from 'react';
import Highlighter from 'react-highlight-words';
import Linkify from 'react-linkify';
const linkify = new Linkify();
export default ({suspectWords, bannedWords, body, ...rest}) => {
const links = linkify.getMatches(body);
const linkText = links ? links.map((link) => link.raw) : [];
const searchWords = [
...suspectWords,
...bannedWords,
...linkText
];
return (
<Highlighter
{...rest}
searchWords={searchWords}
textToHighlight={body}
/>
);
};