|
|
@@ -3,14 +3,17 @@ import PropTypes from 'prop-types';
|
|
|
|
|
|
import { Subscribe } from 'unstated';
|
|
|
|
|
|
+import Modal from 'react-bootstrap/es/Modal';
|
|
|
import Dropzone from 'react-dropzone';
|
|
|
+
|
|
|
+import EditorContainer from '../../services/EditorContainer';
|
|
|
+
|
|
|
+import Cheatsheet from './Cheatsheet';
|
|
|
import AbstractEditor from './AbstractEditor';
|
|
|
import CodeMirrorEditor from './CodeMirrorEditor';
|
|
|
import TextAreaEditor from './TextAreaEditor';
|
|
|
|
|
|
-
|
|
|
import pasteHelper from './PasteHelper';
|
|
|
-import EditorContainer from '../../services/EditorContainer';
|
|
|
|
|
|
export default class Editor extends AbstractEditor {
|
|
|
|
|
|
@@ -21,6 +24,7 @@ export default class Editor extends AbstractEditor {
|
|
|
isComponentDidMount: false,
|
|
|
dropzoneActive: false,
|
|
|
isUploading: false,
|
|
|
+ isCheatsheetModalShown: false,
|
|
|
};
|
|
|
|
|
|
this.getEditorSubstance = this.getEditorSubstance.bind(this);
|
|
|
@@ -31,6 +35,8 @@ export default class Editor extends AbstractEditor {
|
|
|
this.dragLeaveHandler = this.dragLeaveHandler.bind(this);
|
|
|
this.dropHandler = this.dropHandler.bind(this);
|
|
|
|
|
|
+ this.showMarkdownHelp = this.showMarkdownHelp.bind(this);
|
|
|
+
|
|
|
this.getAcceptableType = this.getAcceptableType.bind(this);
|
|
|
this.getDropzoneClassName = this.getDropzoneClassName.bind(this);
|
|
|
this.renderDropzoneOverlay = this.renderDropzoneOverlay.bind(this);
|
|
|
@@ -174,6 +180,10 @@ export default class Editor extends AbstractEditor {
|
|
|
this.setState({ isUploading: true });
|
|
|
}
|
|
|
|
|
|
+ showMarkdownHelp() {
|
|
|
+ this.setState({ isCheatsheetModalShown: true });
|
|
|
+ }
|
|
|
+
|
|
|
getDropzoneClassName(isDragAccept, isDragReject) {
|
|
|
let className = 'dropzone';
|
|
|
if (!this.props.isUploadable) {
|
|
|
@@ -240,6 +250,23 @@ export default class Editor extends AbstractEditor {
|
|
|
return navbarItems.concat(this.getEditorSubstance().getNavbarItems());
|
|
|
}
|
|
|
|
|
|
+ renderCheatsheetModal() {
|
|
|
+ const hideCheatsheetModal = () => {
|
|
|
+ this.setState({ isCheatsheetModalShown: false });
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Modal className="modal-gfm-cheatsheet" show={this.state.isCheatsheetModalShown} onHide={() => { hideCheatsheetModal() }}>
|
|
|
+ <Modal.Header closeButton>
|
|
|
+ <Modal.Title><i className="icon-fw icon-question" />Markdown Help</Modal.Title>
|
|
|
+ </Modal.Header>
|
|
|
+ <Modal.Body className="pt-1">
|
|
|
+ <Cheatsheet />
|
|
|
+ </Modal.Body>
|
|
|
+ </Modal>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
const flexContainer = {
|
|
|
height: '100%',
|
|
|
@@ -282,6 +309,7 @@ export default class Editor extends AbstractEditor {
|
|
|
editorOptions={editorContainer.state.editorOptions}
|
|
|
onPasteFiles={this.pasteFilesHandler}
|
|
|
onDragEnter={this.dragEnterHandler}
|
|
|
+ onMarkdownHelpButtonClicked={this.showMarkdownHelp}
|
|
|
{...this.props}
|
|
|
/>
|
|
|
)}
|
|
|
@@ -322,6 +350,9 @@ export default class Editor extends AbstractEditor {
|
|
|
</button>
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+ { this.renderCheatsheetModal() }
|
|
|
+
|
|
|
</div>
|
|
|
);
|
|
|
}
|