import React from 'react'; import PropTypes from 'prop-types'; /** * * @author Yuki Takei * * @export * @class Comment * @extends {React.Component} */ export default class CommentForm extends React.Component { constructor(props) { super(props); this.state = { comment: '', isMarkdown: false, }; this.testComment = new Comment(); this.handleChange = this.handleChange.bind(this); this.postComment = this.postComment.bind(this); } handleChange(event) { const target = event.target; const value = target.type === 'checkbox' ? target.checked : target.value; const name = target.name; this.setState({ [name]: value }); } postComment(event) { event.preventDefault(); console.log(this.props.crowi.csrfToken); this.props.crowi.apiPost('/comments.add', JSON.stringify({comment: this.state.comment, page_id: this.props.pageId, revision_id: this.props.revisionId})); } render() { //{% if not user %}disabled{% endif %}をtextareaとbuttonに追加 return (
{{ user.name }}
Markdown
); } } CommentForm.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, revisionId: PropTypes.string, };