|
|
@@ -36,7 +36,6 @@ class CommentEditor extends React.Component {
|
|
|
const isUploadableFile = config.upload.file;
|
|
|
|
|
|
this.state = {
|
|
|
- isLayoutTypeGrowi: false,
|
|
|
comment: '',
|
|
|
isMarkdown: true,
|
|
|
html: '',
|
|
|
@@ -60,15 +59,6 @@ class CommentEditor extends React.Component {
|
|
|
this.toggleEditor = this.toggleEditor.bind(this);
|
|
|
}
|
|
|
|
|
|
- componentWillMount() {
|
|
|
- this.init();
|
|
|
- }
|
|
|
-
|
|
|
- init() {
|
|
|
- const layoutType = this.props.appContainer.getConfig().layoutType;
|
|
|
- this.setState({ isLayoutTypeGrowi: layoutType === 'crowi-plus' || layoutType === 'growi' });
|
|
|
- }
|
|
|
-
|
|
|
updateState(value) {
|
|
|
this.setState({ comment: value });
|
|
|
}
|
|
|
@@ -214,7 +204,8 @@ class CommentEditor extends React.Component {
|
|
|
const commentPreview = this.state.isMarkdown ? this.getCommentHtml() : null;
|
|
|
const emojiStrategy = appContainer.getEmojiStrategy();
|
|
|
|
|
|
- const isLayoutTypeGrowi = this.state.isLayoutTypeGrowi;
|
|
|
+ const layoutType = this.props.appContainer.getConfig().layoutType;
|
|
|
+ const isBaloonStyle = layoutType.match(/crowi-plus|growi|kibela/);
|
|
|
|
|
|
const errorMessage = <span className="text-danger text-right mr-2">{this.state.errorMessage}</span>;
|
|
|
const submitButton = (
|
|
|
@@ -229,98 +220,86 @@ class CommentEditor extends React.Component {
|
|
|
|
|
|
return (
|
|
|
<div className="form page-comment-form">
|
|
|
-
|
|
|
- { username
|
|
|
- && (
|
|
|
- <div className="comment-form">
|
|
|
- { isLayoutTypeGrowi
|
|
|
- && (
|
|
|
- <div className="comment-form-user">
|
|
|
- <UserPicture user={user} />
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
- <div className="comment-form-main">
|
|
|
- <div className="comment-write">
|
|
|
- <Tabs activeKey={this.state.key} id="comment-form-tabs" onSelect={this.handleSelect} animation={false}>
|
|
|
- <Tab eventKey={1} title="Write">
|
|
|
- <Editor
|
|
|
- ref={(c) => { this.editor = c }}
|
|
|
- value={this.state.comment}
|
|
|
- isGfmMode={this.state.isMarkdown}
|
|
|
- lineNumbers={false}
|
|
|
- isMobile={appContainer.isMobile}
|
|
|
- isUploadable={this.state.isUploadable && this.state.isLayoutTypeGrowi} // enable only when GROWI layout
|
|
|
- isUploadableFile={this.state.isUploadableFile}
|
|
|
- emojiStrategy={emojiStrategy}
|
|
|
- onChange={this.updateState}
|
|
|
- onUpload={this.uploadHandler}
|
|
|
- onCtrlEnter={this.postHandler}
|
|
|
- />
|
|
|
+ <div className="comment-form">
|
|
|
+ { isBaloonStyle && (
|
|
|
+ <div className="comment-form-user">
|
|
|
+ <UserPicture user={user} />
|
|
|
+ </div>
|
|
|
+ ) }
|
|
|
+ <div className="comment-form-main">
|
|
|
+ <div className="comment-write">
|
|
|
+ <Tabs activeKey={this.state.key} id="comment-form-tabs" onSelect={this.handleSelect} animation={false}>
|
|
|
+ <Tab eventKey={1} title="Write">
|
|
|
+ <Editor
|
|
|
+ ref={(c) => { this.editor = c }}
|
|
|
+ value={this.state.comment}
|
|
|
+ isGfmMode={this.state.isMarkdown}
|
|
|
+ lineNumbers={false}
|
|
|
+ isMobile={appContainer.isMobile}
|
|
|
+ isUploadable={this.state.isUploadable && this.state.isLayoutTypeGrowi} // enable only when GROWI layout
|
|
|
+ isUploadableFile={this.state.isUploadableFile}
|
|
|
+ emojiStrategy={emojiStrategy}
|
|
|
+ onChange={this.updateState}
|
|
|
+ onUpload={this.uploadHandler}
|
|
|
+ onCtrlEnter={this.postHandler}
|
|
|
+ />
|
|
|
+ </Tab>
|
|
|
+ { this.state.isMarkdown && (
|
|
|
+ <Tab eventKey={2} title="Preview">
|
|
|
+ <div className="comment-form-preview">
|
|
|
+ {commentPreview}
|
|
|
+ </div>
|
|
|
</Tab>
|
|
|
- { this.state.isMarkdown
|
|
|
- && (
|
|
|
- <Tab eventKey={2} title="Preview">
|
|
|
- <div className="comment-form-preview">
|
|
|
- {commentPreview}
|
|
|
- </div>
|
|
|
- </Tab>
|
|
|
- )
|
|
|
- }
|
|
|
- </Tabs>
|
|
|
- </div>
|
|
|
- <div className="comment-submit">
|
|
|
- <div className="d-flex">
|
|
|
- <label style={{ flex: 1 }}>
|
|
|
- { isLayoutTypeGrowi && this.state.key === 1
|
|
|
- && (
|
|
|
- <span>
|
|
|
- <input
|
|
|
- type="checkbox"
|
|
|
- id="comment-form-is-markdown"
|
|
|
- name="isMarkdown"
|
|
|
- checked={this.state.isMarkdown}
|
|
|
- value="1"
|
|
|
- onChange={this.updateStateCheckbox}
|
|
|
- />
|
|
|
- <span className="ml-2">Markdown</span>
|
|
|
- </span>
|
|
|
- )
|
|
|
- }
|
|
|
- </label>
|
|
|
- <span className="hidden-xs">{ this.state.errorMessage && errorMessage }</span>
|
|
|
- { this.state.hasSlackConfig
|
|
|
- && (
|
|
|
- <div className="form-inline align-self-center mr-md-2">
|
|
|
- <SlackNotification
|
|
|
- isSlackEnabled={commentContainer.state.isSlackEnabled}
|
|
|
- slackChannels={commentContainer.state.slackChannels}
|
|
|
- onEnabledFlagChange={this.onSlackEnabledFlagChange}
|
|
|
- onChannelChange={this.onSlackChannelsChange}
|
|
|
+ ) }
|
|
|
+ </Tabs>
|
|
|
+ </div>
|
|
|
+ <div className="comment-submit">
|
|
|
+ <div className="d-flex">
|
|
|
+ <label style={{ flex: 1 }}>
|
|
|
+ { isBaloonStyle && this.state.key === 1 && (
|
|
|
+ <span>
|
|
|
+ <input
|
|
|
+ type="checkbox"
|
|
|
+ id="comment-form-is-markdown"
|
|
|
+ name="isMarkdown"
|
|
|
+ checked={this.state.isMarkdown}
|
|
|
+ value="1"
|
|
|
+ onChange={this.updateStateCheckbox}
|
|
|
/>
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
- <div>
|
|
|
- <Button bsStyle="danger" className="fcbtn btn btn-xs btn-danger btn-outline btn-rounded" onClick={this.toggleEditor}>
|
|
|
- Cancel
|
|
|
- </Button>
|
|
|
+ <span className="ml-2">Markdown</span>
|
|
|
+ </span>
|
|
|
+ ) }
|
|
|
+ </label>
|
|
|
+ <span className="hidden-xs">{ this.state.errorMessage && errorMessage }</span>
|
|
|
+ { this.state.hasSlackConfig
|
|
|
+ && (
|
|
|
+ <div className="form-inline align-self-center mr-md-2">
|
|
|
+ <SlackNotification
|
|
|
+ isSlackEnabled={commentContainer.state.isSlackEnabled}
|
|
|
+ slackChannels={commentContainer.state.slackChannels}
|
|
|
+ onEnabledFlagChange={this.onSlackEnabledFlagChange}
|
|
|
+ onChannelChange={this.onSlackChannelsChange}
|
|
|
+ />
|
|
|
</div>
|
|
|
-
|
|
|
- <div className="hidden-xs">{submitButton}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ <div>
|
|
|
+ <Button bsStyle="danger" className="fcbtn btn btn-xs btn-danger btn-outline btn-rounded" onClick={this.toggleEditor}>
|
|
|
+ Cancel
|
|
|
+ </Button>
|
|
|
</div>
|
|
|
- <div className="visible-xs mt-2">
|
|
|
- <div className="d-flex justify-content-end">
|
|
|
- { this.state.errorMessage && errorMessage }
|
|
|
- <div>{submitButton}</div>
|
|
|
- </div>
|
|
|
+
|
|
|
+ <div className="hidden-xs">{submitButton}</div>
|
|
|
+ </div>
|
|
|
+ <div className="visible-xs mt-2">
|
|
|
+ <div className="d-flex justify-content-end">
|
|
|
+ { this.state.errorMessage && errorMessage }
|
|
|
+ <div>{submitButton}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
+ </div>
|
|
|
</div>
|
|
|
);
|
|
|
}
|