|
@@ -1,12 +1,9 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
-// TODO: GW-333
|
|
|
|
|
-// import Tab from 'react-bootstrap/es/Tab';
|
|
|
|
|
-// import Tabs from 'react-bootstrap/es/Tabs';
|
|
|
|
|
-
|
|
|
|
|
import {
|
|
import {
|
|
|
Button,
|
|
Button,
|
|
|
|
|
+ TabContent, TabPane, Nav, NavItem, NavLink,
|
|
|
} from 'reactstrap';
|
|
} from 'reactstrap';
|
|
|
|
|
|
|
|
import * as toastr from 'toastr';
|
|
import * as toastr from 'toastr';
|
|
@@ -44,7 +41,7 @@ class CommentEditor extends React.Component {
|
|
|
comment: this.props.commentBody || '',
|
|
comment: this.props.commentBody || '',
|
|
|
isMarkdown: true,
|
|
isMarkdown: true,
|
|
|
html: '',
|
|
html: '',
|
|
|
- key: 1,
|
|
|
|
|
|
|
+ activeTab: 1,
|
|
|
isUploadable,
|
|
isUploadable,
|
|
|
isUploadableFile,
|
|
isUploadableFile,
|
|
|
errorMessage: undefined,
|
|
errorMessage: undefined,
|
|
@@ -75,8 +72,8 @@ class CommentEditor extends React.Component {
|
|
|
this.editor.setGfmMode(value);
|
|
this.editor.setGfmMode(value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- handleSelect(key) {
|
|
|
|
|
- this.setState({ key });
|
|
|
|
|
|
|
+ handleSelect(activeTab) {
|
|
|
|
|
+ this.setState({ activeTab });
|
|
|
this.renderHtml(this.state.comment);
|
|
this.renderHtml(this.state.comment);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -217,6 +214,8 @@ class CommentEditor extends React.Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const { appContainer, commentContainer } = this.props;
|
|
const { appContainer, commentContainer } = this.props;
|
|
|
|
|
+ const { activeTab } = this.state;
|
|
|
|
|
+
|
|
|
const username = appContainer.me;
|
|
const username = appContainer.me;
|
|
|
const user = appContainer.findUser(username);
|
|
const user = appContainer.findUser(username);
|
|
|
const commentPreview = this.state.isMarkdown ? this.getCommentHtml() : null;
|
|
const commentPreview = this.state.isMarkdown ? this.getCommentHtml() : null;
|
|
@@ -226,6 +225,11 @@ class CommentEditor extends React.Component {
|
|
|
const isBaloonStyle = layoutType.match(/crowi-plus|growi|kibela/);
|
|
const isBaloonStyle = layoutType.match(/crowi-plus|growi|kibela/);
|
|
|
|
|
|
|
|
const errorMessage = <span className="text-danger text-right mr-2">{this.state.errorMessage}</span>;
|
|
const errorMessage = <span className="text-danger text-right mr-2">{this.state.errorMessage}</span>;
|
|
|
|
|
+ const cancelButton = (
|
|
|
|
|
+ <Button outline color="danger" size="xs" className="fcbtn btn-rounded" onClick={this.toggleEditor}>
|
|
|
|
|
+ Cancel
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ );
|
|
|
const submitButton = (
|
|
const submitButton = (
|
|
|
<Button
|
|
<Button
|
|
|
outline
|
|
outline
|
|
@@ -247,8 +251,20 @@ class CommentEditor extends React.Component {
|
|
|
) }
|
|
) }
|
|
|
<div className="comment-form-main">
|
|
<div className="comment-form-main">
|
|
|
<div className="comment-write">
|
|
<div className="comment-write">
|
|
|
- <Tabs activeKey={this.state.key} id="comment-form-tabs" onSelect={this.handleSelect} animation={false}>
|
|
|
|
|
- <Tab eventKey={1} title="Write">
|
|
|
|
|
|
|
+ <Nav tabs>
|
|
|
|
|
+ <NavItem>
|
|
|
|
|
+ <NavLink type="button" className={activeTab === 1 ? 'active' : ''} onClick={() => this.handleSelect(1)}>
|
|
|
|
|
+ Write
|
|
|
|
|
+ </NavLink>
|
|
|
|
|
+ </NavItem>
|
|
|
|
|
+ <NavItem>
|
|
|
|
|
+ <NavLink type="button" className={activeTab === 2 ? 'active' : ''} onClick={() => this.handleSelect(2)}>
|
|
|
|
|
+ Preview
|
|
|
|
|
+ </NavLink>
|
|
|
|
|
+ </NavItem>
|
|
|
|
|
+ </Nav>
|
|
|
|
|
+ <TabContent activeTab={activeTab}>
|
|
|
|
|
+ <TabPane tabId={1}>
|
|
|
<Editor
|
|
<Editor
|
|
|
ref={(c) => { this.editor = c }}
|
|
ref={(c) => { this.editor = c }}
|
|
|
value={this.state.comment}
|
|
value={this.state.comment}
|
|
@@ -262,20 +278,20 @@ class CommentEditor extends React.Component {
|
|
|
onUpload={this.uploadHandler}
|
|
onUpload={this.uploadHandler}
|
|
|
onCtrlEnter={this.postHandler}
|
|
onCtrlEnter={this.postHandler}
|
|
|
/>
|
|
/>
|
|
|
- </Tab>
|
|
|
|
|
|
|
+ </TabPane>
|
|
|
{ this.state.isMarkdown && (
|
|
{ this.state.isMarkdown && (
|
|
|
- <Tab eventKey={2} title="Preview">
|
|
|
|
|
|
|
+ <TabPane tabId={2}>
|
|
|
<div className="comment-form-preview">
|
|
<div className="comment-form-preview">
|
|
|
{commentPreview}
|
|
{commentPreview}
|
|
|
</div>
|
|
</div>
|
|
|
- </Tab>
|
|
|
|
|
|
|
+ </TabPane>
|
|
|
) }
|
|
) }
|
|
|
- </Tabs>
|
|
|
|
|
|
|
+ </TabContent>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="comment-submit">
|
|
<div className="comment-submit">
|
|
|
<div className="d-flex">
|
|
<div className="d-flex">
|
|
|
<label style={{ flex: 1 }}>
|
|
<label style={{ flex: 1 }}>
|
|
|
- { isBaloonStyle && this.state.key === 1 && (
|
|
|
|
|
|
|
+ { isBaloonStyle && activeTab === 1 && (
|
|
|
<span>
|
|
<span>
|
|
|
<input
|
|
<input
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
@@ -289,7 +305,7 @@ class CommentEditor extends React.Component {
|
|
|
</span>
|
|
</span>
|
|
|
) }
|
|
) }
|
|
|
</label>
|
|
</label>
|
|
|
- <span className="hidden-xs">{ this.state.errorMessage && errorMessage }</span>
|
|
|
|
|
|
|
+ <span className="d-none d-sm-inline">{ this.state.errorMessage && errorMessage }</span>
|
|
|
{ this.state.hasSlackConfig
|
|
{ this.state.hasSlackConfig
|
|
|
&& (
|
|
&& (
|
|
|
<div className="form-inline align-self-center mr-md-2">
|
|
<div className="form-inline align-self-center mr-md-2">
|
|
@@ -302,18 +318,14 @@ class CommentEditor extends React.Component {
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- <div>
|
|
|
|
|
- <Button outline color="danger" size="xs" className="fcbtn btn-rounded" onClick={this.toggleEditor}>
|
|
|
|
|
- Cancel
|
|
|
|
|
- </Button>
|
|
|
|
|
|
|
+ <div className="d-none d-sm-block">
|
|
|
|
|
+ <span className="mr-2">{cancelButton}</span><span>{submitButton}</span>
|
|
|
</div>
|
|
</div>
|
|
|
-
|
|
|
|
|
- <div className="hidden-xs">{submitButton}</div>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="visible-xs mt-2">
|
|
|
|
|
|
|
+ <div className="d-block d-sm-none mt-2">
|
|
|
<div className="d-flex justify-content-end">
|
|
<div className="d-flex justify-content-end">
|
|
|
{ this.state.errorMessage && errorMessage }
|
|
{ this.state.errorMessage && errorMessage }
|
|
|
- <div>{submitButton}</div>
|
|
|
|
|
|
|
+ <span className="mr-2">{cancelButton}</span><span>{submitButton}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|