Added image upload indicator
This commit is contained in:
@ -26,6 +26,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
// This is actually not used but it triggers
|
// This is actually not used but it triggers
|
||||||
// re-render to help with CodeMirror focus issues
|
// re-render to help with CodeMirror focus issues
|
||||||
preview: React.PropTypes.bool,
|
preview: React.PropTypes.bool,
|
||||||
|
toggleUploadingIndicator: React.PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = (newText) => {
|
onChange = (newText) => {
|
||||||
@ -42,6 +43,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
const insertOnNewLine = cursorPosition.ch !== 0;
|
const insertOnNewLine = cursorPosition.ch !== 0;
|
||||||
let newCursorPositionLine;
|
let newCursorPositionLine;
|
||||||
|
|
||||||
|
this.props.toggleUploadingIndicator();
|
||||||
|
|
||||||
// Lets set up the upload text
|
// Lets set up the upload text
|
||||||
const pendingUploadTag = ``;
|
const pendingUploadTag = ``;
|
||||||
if (insertOnNewLine) {
|
if (insertOnNewLine) {
|
||||||
@ -78,6 +81,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
body: formData,
|
body: formData,
|
||||||
})
|
})
|
||||||
.then(_s3Response => {
|
.then(_s3Response => {
|
||||||
|
this.props.toggleUploadingIndicator();
|
||||||
this.props.replaceText({
|
this.props.replaceText({
|
||||||
original: pendingUploadTag,
|
original: pendingUploadTag,
|
||||||
new: ``,
|
new: ``,
|
||||||
@ -85,12 +89,16 @@ class MarkdownEditor extends React.Component {
|
|||||||
editor.setCursor(newCursorPositionLine, 0);
|
editor.setCursor(newCursorPositionLine, 0);
|
||||||
})
|
})
|
||||||
.catch(_err => {
|
.catch(_err => {
|
||||||
|
this.props.toggleUploadingIndicator();
|
||||||
this.props.replaceText({
|
this.props.replaceText({
|
||||||
original: pendingUploadTag,
|
original: pendingUploadTag,
|
||||||
new: '',
|
new: '',
|
||||||
});
|
});
|
||||||
editor.setCursor(newCursorPositionLine, 0);
|
editor.setCursor(newCursorPositionLine, 0);
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch(_err => {
|
||||||
|
this.props.toggleUploadingIndicator();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,6 @@ class DocumentEdit extends Component {
|
|||||||
params: React.PropTypes.object,
|
params: React.PropTypes.object,
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
|
||||||
scrollTop: 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.store = new DocumentEditStore(
|
this.store = new DocumentEditStore(
|
||||||
@ -45,6 +41,10 @@ class DocumentEdit extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state = {
|
||||||
|
scrollTop: 0,
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
if (this.props.route.newDocument) {
|
if (this.props.route.newDocument) {
|
||||||
this.store.collectionId = this.props.params.id;
|
this.store.collectionId = this.props.params.id;
|
||||||
@ -70,7 +70,7 @@ class DocumentEdit extends Component {
|
|||||||
if (this.store.hasPendingChanges) {
|
if (this.store.hasPendingChanges) {
|
||||||
return confirm(DISREGARD_CHANGES);
|
return confirm(DISREGARD_CHANGES);
|
||||||
}
|
}
|
||||||
return;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class DocumentEdit extends Component {
|
|||||||
title={ title }
|
title={ title }
|
||||||
titleText={ titleText }
|
titleText={ titleText }
|
||||||
fixed
|
fixed
|
||||||
loading={ this.store.isSaving }
|
loading={ this.store.isSaving || this.store.isUploading }
|
||||||
search={ false }
|
search={ false }
|
||||||
>
|
>
|
||||||
{ (this.store.isFetching || !('Editor' in this.state)) ? (
|
{ (this.store.isFetching || !('Editor' in this.state)) ? (
|
||||||
|
@ -32,6 +32,7 @@ class DocumentEditStore {
|
|||||||
@observable preview;
|
@observable preview;
|
||||||
@observable isFetching;
|
@observable isFetching;
|
||||||
@observable isSaving;
|
@observable isSaving;
|
||||||
|
@observable isUploading;
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
@ -122,6 +123,10 @@ class DocumentEditStore {
|
|||||||
this.text = '# Lets start with a title\n\nAnd continue from there...';
|
this.text = '# Lets start with a title\n\nAnd continue from there...';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action toggleUploadingIndicator = () => {
|
||||||
|
this.isUploading = !this.isUploading;
|
||||||
|
}
|
||||||
|
|
||||||
// Generic
|
// Generic
|
||||||
|
|
||||||
persistSettings = () => {
|
persistSettings = () => {
|
||||||
|
@ -25,6 +25,7 @@ const Editor = observer((props) => {
|
|||||||
onSave={ props.onSave }
|
onSave={ props.onSave }
|
||||||
onCancel={ props.onCancel }
|
onCancel={ props.onCancel }
|
||||||
togglePreview={ props.togglePreview }
|
togglePreview={ props.togglePreview }
|
||||||
|
toggleUploadingIndicator={ store.toggleUploadingIndicator }
|
||||||
/>
|
/>
|
||||||
</EditorPane>
|
</EditorPane>
|
||||||
{ store.preview ? (
|
{ store.preview ? (
|
||||||
|
Reference in New Issue
Block a user