import React from 'react'; import PropTypes from 'prop-types'; import FormControl from 'react-bootstrap/es/FormControl'; import Button from 'react-bootstrap/es/Button'; import UserPicture from '../User/UserPicture'; /** * * @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.updateState = this.updateState.bind(this); this.postComment = this.postComment.bind(this); } updateState(event) { const target = event.target; const value = target.type === 'checkbox' ? target.checked : target.value; const name = target.name; this.setState({ [name]: value }); } /** * Load data of comments and rerender */ postComment(event) { event.preventDefault(); this.props.crowi.apiPost('/comments.add', { commentForm: { comment: this.state.comment, _csrf: this.props.crowi.csrfToken, page_id: this.props.pageId, revision_id: this.props.revisionId, is_markdown: this.state.isMarkdown, } }) .then((res) => { if (this.props.onPostComplete != null) { this.props.onPostComplete(res.comment); } this.setState({ comment: '', isMarkdown: false, }); }); } render() { //{% if not user %}disabled{% endif %}をtextareaとbuttonに追加 // denounce/throttle return (
{/* */} Markdown
); } } CommentForm.propTypes = { crowi: PropTypes.object.isRequired, onPostComplete: PropTypes.func, pageId: PropTypes.string, revisionId: PropTypes.string, };