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) { let mk = this.state.isMarkdown ? 'Markdown' : 'Plain'; alert(mk + ' Comment: ' + this.state.comment); // this.props.crowi.apiPost('/comments.add', {page_id: this.props.pageId}); event.preventDefault(); } render() { //{% if not user %}disabled{% endif %}をtextareaとbuttonに追加 return (
{{ user.name }}
Markdown
); } } CommentForm.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, };