import React from 'react'; import PropTypes from 'prop-types'; import { processor } from '@seafile/seafile-editor'; const commentItemPropTypes = { time: PropTypes.string, item: PropTypes.object, showResolvedComment: PropTypes.bool, onClickComment: PropTypes.func, }; class CommentItemReadOnly extends React.Component { constructor(props) { super(props); this.state = { html: '', newComment: this.props.item.comment, }; } convertComment = (mdFile) => { processor.process(mdFile).then((result) => { let html = String(result); this.setState({ html: html }); }); }; handleCommentChange = (event) => { this.setState({ newComment: event.target.value, }); }; componentWillMount() { this.convertComment(this.props.item.comment); } componentWillReceiveProps(nextProps) { this.convertComment(nextProps.item.comment); } onCommentContentClick = (e) => { // click participant link, page shouldn't jump if (e.target.nodeName !== 'A') return; const preNode = e.target.previousSibling; if (preNode && preNode.nodeType === 3 && preNode.nodeValue.slice(-1) === '@') { e.preventDefault(); } }; render() { const item = this.props.item; const replies = item.replies || []; const lastReply = replies[replies.length - 1]; return (
  • this.props.onClickComment(item)}>
    {item.user_name}
    {this.props.time} {item.resolved && }
    this.onCommentContentClick(e)} >
    {replies.length > 0 &&
    {replies.length}

    {lastReply.reply}

    }
  • ); } } CommentItemReadOnly.propTypes = commentItemPropTypes; export default CommentItemReadOnly;