|
@@ -54,6 +54,7 @@ export default class Editor extends React.Component {
|
|
|
value: this.props.value,
|
|
value: this.props.value,
|
|
|
dropzoneActive: false,
|
|
dropzoneActive: false,
|
|
|
isUploading: false,
|
|
isUploading: false,
|
|
|
|
|
+ isLoadingKeymap: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.loadedThemeSet = new Set(['eclipse', 'elegant']); // themes imported in _vendor.scss
|
|
this.loadedThemeSet = new Set(['eclipse', 'elegant']); // themes imported in _vendor.scss
|
|
@@ -78,7 +79,9 @@ export default class Editor extends React.Component {
|
|
|
|
|
|
|
|
this.getDropzoneAccept = this.getDropzoneAccept.bind(this);
|
|
this.getDropzoneAccept = this.getDropzoneAccept.bind(this);
|
|
|
this.getDropzoneClassName = this.getDropzoneClassName.bind(this);
|
|
this.getDropzoneClassName = this.getDropzoneClassName.bind(this);
|
|
|
- this.renderOverlay = this.renderOverlay.bind(this);
|
|
|
|
|
|
|
+ this.renderDropzoneOverlay = this.renderDropzoneOverlay.bind(this);
|
|
|
|
|
+
|
|
|
|
|
+ this.renderLoadingKeymapOverlay = this.renderLoadingKeymapOverlay.bind(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -194,7 +197,13 @@ export default class Editor extends React.Component {
|
|
|
this.loadedKeymapSet.add(keymapMode);
|
|
this.loadedKeymapSet.add(keymapMode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return Promise.all(scriptList.concat(cssList));
|
|
|
|
|
|
|
+ // set loading state
|
|
|
|
|
+ this.setState({ isLoadingKeymap: true });
|
|
|
|
|
+
|
|
|
|
|
+ return Promise.all(scriptList.concat(cssList))
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ this.setState({ isLoadingKeymap: false });
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -211,9 +220,9 @@ export default class Editor extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.loadKeymapMode(keymapMode)
|
|
this.loadKeymapMode(keymapMode)
|
|
|
- .then(() => {
|
|
|
|
|
- this.getCodeMirror().setOption('keyMap', keymapMode);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ this.getCodeMirror().setOption('keyMap', keymapMode);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -376,8 +385,8 @@ export default class Editor extends React.Component {
|
|
|
return className;
|
|
return className;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- renderOverlay() {
|
|
|
|
|
- const overlayStyle = {
|
|
|
|
|
|
|
+ getOverlayStyle() {
|
|
|
|
|
+ return {
|
|
|
position: 'absolute',
|
|
position: 'absolute',
|
|
|
zIndex: 4, // forward than .CodeMirror-gutters
|
|
zIndex: 4, // forward than .CodeMirror-gutters
|
|
|
top: 0,
|
|
top: 0,
|
|
@@ -385,20 +394,36 @@ export default class Editor extends React.Component {
|
|
|
bottom: 0,
|
|
bottom: 0,
|
|
|
left: 0,
|
|
left: 0,
|
|
|
};
|
|
};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ renderDropzoneOverlay() {
|
|
|
|
|
+ const overlayStyle = this.getOverlayStyle();
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <div style={overlayStyle} className="dropzone-overlay">
|
|
|
|
|
|
|
+ <div style={overlayStyle} className="overlay">
|
|
|
{this.state.isUploading &&
|
|
{this.state.isUploading &&
|
|
|
- <span className="dropzone-overlay-content">
|
|
|
|
|
- <i className="fa fa-spinner fa-pulse fa-fw"></i>
|
|
|
|
|
|
|
+ <span className="overlay-content">
|
|
|
|
|
+ <div className="speeding-wheel d-inline-block"></div>
|
|
|
<span className="sr-only">Uploading...</span>
|
|
<span className="sr-only">Uploading...</span>
|
|
|
</span>
|
|
</span>
|
|
|
}
|
|
}
|
|
|
- {!this.state.isUploading && <span className="dropzone-overlay-content"></span>}
|
|
|
|
|
|
|
+ {!this.state.isUploading && <span className="overlay-content"></span>}
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ renderLoadingKeymapOverlay() {
|
|
|
|
|
+ const overlayStyle = this.getOverlayStyle();
|
|
|
|
|
+
|
|
|
|
|
+ return this.state.isLoadingKeymap
|
|
|
|
|
+ ? <div style={overlayStyle} className="loading-keymap overlay">
|
|
|
|
|
+ <span className="overlay-content">
|
|
|
|
|
+ <div className="speeding-wheel d-inline-block"></div> Loading Keymap ...
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ : '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const flexContainer = {
|
|
const flexContainer = {
|
|
|
height: '100%',
|
|
height: '100%',
|
|
@@ -408,7 +433,7 @@ export default class Editor extends React.Component {
|
|
|
|
|
|
|
|
const theme = this.props.editorOptions.theme || 'elegant';
|
|
const theme = this.props.editorOptions.theme || 'elegant';
|
|
|
const styleActiveLine = this.props.editorOptions.styleActiveLine || undefined;
|
|
const styleActiveLine = this.props.editorOptions.styleActiveLine || undefined;
|
|
|
- return (
|
|
|
|
|
|
|
+ return <React.Fragment>
|
|
|
<div style={flexContainer}>
|
|
<div style={flexContainer}>
|
|
|
<Dropzone
|
|
<Dropzone
|
|
|
ref="dropzone"
|
|
ref="dropzone"
|
|
@@ -422,7 +447,7 @@ export default class Editor extends React.Component {
|
|
|
onDragLeave={this.onDragLeave}
|
|
onDragLeave={this.onDragLeave}
|
|
|
onDrop={this.onDrop}
|
|
onDrop={this.onDrop}
|
|
|
>
|
|
>
|
|
|
- { this.state.dropzoneActive && this.renderOverlay() }
|
|
|
|
|
|
|
+ { this.state.dropzoneActive && this.renderDropzoneOverlay() }
|
|
|
|
|
|
|
|
<ReactCodeMirror
|
|
<ReactCodeMirror
|
|
|
ref="cm"
|
|
ref="cm"
|
|
@@ -480,15 +505,19 @@ export default class Editor extends React.Component {
|
|
|
</Dropzone>
|
|
</Dropzone>
|
|
|
|
|
|
|
|
<button type="button" className="btn btn-default btn-block btn-open-dropzone"
|
|
<button type="button" className="btn btn-default btn-block btn-open-dropzone"
|
|
|
- onClick={() => {this.refs.dropzone.open()}}>
|
|
|
|
|
|
|
+ onClick={() => {this.refs.dropzone.open()}}>
|
|
|
|
|
|
|
|
<i className="icon-paper-clip" aria-hidden="true"></i>
|
|
<i className="icon-paper-clip" aria-hidden="true"></i>
|
|
|
Attach files by dragging & dropping,
|
|
Attach files by dragging & dropping,
|
|
|
<span className="btn-link">selecting them</span>,
|
|
<span className="btn-link">selecting them</span>,
|
|
|
or pasting from the clipboard.
|
|
or pasting from the clipboard.
|
|
|
</button>
|
|
</button>
|
|
|
|
|
+
|
|
|
|
|
+ { this.renderLoadingKeymapOverlay() }
|
|
|
|
|
+
|
|
|
</div>
|
|
</div>
|
|
|
- );
|
|
|
|
|
|
|
+
|
|
|
|
|
+ </React.Fragment>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|