mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 20:03:00 +08:00
30 lines
782 B
JavaScript
30 lines
782 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { PLUGIN_NAME } from '../constants';
|
|
import cn from 'classnames';
|
|
import styles from './CommentContent.css';
|
|
import Linkify from 'react-linkify';
|
|
|
|
class CommentContent extends React.Component {
|
|
render() {
|
|
const { comment } = this.props;
|
|
const className = cn(`${PLUGIN_NAME}-text`, styles.content);
|
|
return comment.richTextBody ? (
|
|
<div
|
|
className={className}
|
|
dangerouslySetInnerHTML={{ __html: comment.richTextBody }}
|
|
/>
|
|
) : (
|
|
<Linkify properties={{ target: '_blank' }}>
|
|
<div className={className}>{comment.body}</div>
|
|
</Linkify>
|
|
);
|
|
}
|
|
}
|
|
|
|
CommentContent.propTypes = {
|
|
comment: PropTypes.object.isRequired,
|
|
};
|
|
|
|
export default CommentContent;
|