|
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import dateFnsFormat from 'date-fns/format';
|
|
import dateFnsFormat from 'date-fns/format';
|
|
|
|
|
|
|
|
|
|
+import RevisionBody from '../Page/RevisionBody';
|
|
|
|
|
+
|
|
|
import ReactUtils from '../ReactUtils';
|
|
import ReactUtils from '../ReactUtils';
|
|
|
import UserPicture from '../User/UserPicture';
|
|
import UserPicture from '../User/UserPicture';
|
|
|
|
|
|
|
@@ -19,6 +21,10 @@ export default class Comment extends React.Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
+ this.state = {
|
|
|
|
|
+ html: '',
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
this.isCurrentUserIsAuthor = this.isCurrentUserEqualsToAuthor.bind(this);
|
|
this.isCurrentUserIsAuthor = this.isCurrentUserEqualsToAuthor.bind(this);
|
|
|
this.isCurrentRevision = this.isCurrentRevision.bind(this);
|
|
this.isCurrentRevision = this.isCurrentRevision.bind(this);
|
|
|
this.getRootClassName = this.getRootClassName.bind(this);
|
|
this.getRootClassName = this.getRootClassName.bind(this);
|
|
@@ -109,15 +115,11 @@ export default class Comment extends React.Component {
|
|
|
render() {
|
|
render() {
|
|
|
const comment = this.props.comment;
|
|
const comment = this.props.comment;
|
|
|
const creator = comment.creator;
|
|
const creator = comment.creator;
|
|
|
-
|
|
|
|
|
- // temporary from here
|
|
|
|
|
const isMarkdown = comment.isMarkdown;
|
|
const isMarkdown = comment.isMarkdown;
|
|
|
- let markdownText = isMarkdown ? 'markdown' : 'plain';
|
|
|
|
|
- // to here
|
|
|
|
|
|
|
|
|
|
const rootClassName = this.getRootClassName();
|
|
const rootClassName = this.getRootClassName();
|
|
|
const commentDate = dateFnsFormat(comment.createdAt, 'YYYY/MM/DD HH:mm');
|
|
const commentDate = dateFnsFormat(comment.createdAt, 'YYYY/MM/DD HH:mm');
|
|
|
- const commentBody = ReactUtils.nl2br(comment.comment);
|
|
|
|
|
|
|
+ const commentBody = isMarkdown ? this.renderRevisionBody(): ReactUtils.nl2br(comment.comment);
|
|
|
const creatorsPage = `/user/${creator.username}`;
|
|
const creatorsPage = `/user/${creator.username}`;
|
|
|
const revHref = `?revision=${comment.revision}`;
|
|
const revHref = `?revision=${comment.revision}`;
|
|
|
const revFirst8Letters = comment.revision.substr(-8);
|
|
const revFirst8Letters = comment.revision.substr(-8);
|
|
@@ -131,7 +133,6 @@ export default class Comment extends React.Component {
|
|
|
<div className="page-comment-main">
|
|
<div className="page-comment-main">
|
|
|
<div className="page-comment-creator">
|
|
<div className="page-comment-creator">
|
|
|
<a href={creatorsPage}>{creator.username}</a>
|
|
<a href={creatorsPage}>{creator.username}</a>
|
|
|
- <p>{markdownText}!!!</p>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
<div className="page-comment-body">{commentBody}</div>
|
|
<div className="page-comment-body">{commentBody}</div>
|
|
|
<div className="page-comment-meta">
|
|
<div className="page-comment-meta">
|