mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 20:48:50 +08:00
Updates
This commit is contained in:
@@ -63,12 +63,18 @@ function markLinks(body) {
|
||||
return content;
|
||||
}
|
||||
|
||||
function format(body, { suspectWords, bannedWords, className = 'comment' }) {
|
||||
const CommentFormatter = (
|
||||
body,
|
||||
suspectWords,
|
||||
bannedWords,
|
||||
className = 'comment',
|
||||
...rest
|
||||
) => {
|
||||
// Breaking the body by line break
|
||||
const textbreaks = body.split('\n');
|
||||
|
||||
return (
|
||||
<span className={`${className}-text`}>
|
||||
<span className={`${className}-text`} {...rest}>
|
||||
{textbreaks.map((line, i) => {
|
||||
const content = markLinks(line).map((element, index) => {
|
||||
// Keep highlighted links.
|
||||
@@ -91,14 +97,12 @@ function format(body, { suspectWords, bannedWords, className = 'comment' }) {
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
const CommentFormatter = ({ body, settings, ...rest }) => {
|
||||
return <div {...rest}>{format(body, settings)}</div>;
|
||||
};
|
||||
|
||||
CommentFormatter.propTypes = {
|
||||
settings: PropTypes.object,
|
||||
className: PropTypes.string,
|
||||
bannedWords: PropTypes.array,
|
||||
suspectWords: PropTypes.array,
|
||||
body: PropTypes.string,
|
||||
};
|
||||
|
||||
|
||||
@@ -79,12 +79,11 @@ class UserDetailComment extends React.Component {
|
||||
<div className={styles.bodyContainer}>
|
||||
<div className={styles.body}>
|
||||
<CommentFormatter
|
||||
settings={{
|
||||
suspectWords: suspect,
|
||||
bannedWords: banned,
|
||||
}}
|
||||
suspectWords={suspect}
|
||||
bannedWords={banned}
|
||||
body={comment.body}
|
||||
/>{' '}
|
||||
className="talk-admin-user-detail-comment"
|
||||
/>
|
||||
<a
|
||||
className={styles.external}
|
||||
href={`${comment.asset.url}?commentId=${comment.id}`}
|
||||
|
||||
@@ -127,11 +127,9 @@ class Comment extends React.Component {
|
||||
<div className={styles.itemBody}>
|
||||
<div className={styles.body}>
|
||||
<CommentFormatter
|
||||
settings={{
|
||||
suspectWords: settings.wordlist.suspect,
|
||||
bannedWords: settings.wordlist.banned,
|
||||
className: 'talk-admin-comment',
|
||||
}}
|
||||
suspectWords={settings.wordlist.suspect}
|
||||
bannedWords={settings.wordlist.banned}
|
||||
className="talk-admin-comment"
|
||||
body={comment.body}
|
||||
/>
|
||||
<a
|
||||
|
||||
Reference in New Issue
Block a user