Fixes: Image uploads not working
This commit is contained in:
@ -19,6 +19,7 @@ class DropToImport extends Component {
|
|||||||
activeClassName?: string,
|
activeClassName?: string,
|
||||||
rejectClassName?: string,
|
rejectClassName?: string,
|
||||||
documents: DocumentsStore,
|
documents: DocumentsStore,
|
||||||
|
disabled: boolean,
|
||||||
history: Object,
|
history: Object,
|
||||||
};
|
};
|
||||||
state = {
|
state = {
|
||||||
@ -83,9 +84,12 @@ class DropToImport extends Component {
|
|||||||
'history',
|
'history',
|
||||||
'documentId',
|
'documentId',
|
||||||
'collectionId',
|
'collectionId',
|
||||||
'documents'
|
'documents',
|
||||||
|
'disabled'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.props.disabled) return this.props.children;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropzone
|
<Dropzone
|
||||||
accept="text/markdown, text/plain"
|
accept="text/markdown, text/plain"
|
||||||
|
@ -26,8 +26,8 @@ const createPlugins = ({ onImageUploadStart, onImageUploadStop }: Options) => {
|
|||||||
DropOrPasteImages({
|
DropOrPasteImages({
|
||||||
extensions: ['png', 'jpg', 'gif'],
|
extensions: ['png', 'jpg', 'gif'],
|
||||||
applyTransform: async (transform, file) => {
|
applyTransform: async (transform, file) => {
|
||||||
|
onImageUploadStart();
|
||||||
try {
|
try {
|
||||||
onImageUploadStart();
|
|
||||||
const asset = await uploadFile(file);
|
const asset = await uploadFile(file);
|
||||||
const alt = file.name;
|
const alt = file.name;
|
||||||
const src = asset.url;
|
const src = asset.url;
|
||||||
@ -39,6 +39,7 @@ const createPlugins = ({ onImageUploadStart, onImageUploadStop }: Options) => {
|
|||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// TODO: Show a failure alert
|
// TODO: Show a failure alert
|
||||||
|
console.error(err);
|
||||||
} finally {
|
} finally {
|
||||||
onImageUploadStop();
|
onImageUploadStop();
|
||||||
}
|
}
|
||||||
|
@ -124,13 +124,13 @@ type Props = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onImageUploadStart() {
|
onImageUploadStart = () => {
|
||||||
this.setState({ isLoading: true });
|
this.setState({ isLoading: true });
|
||||||
}
|
};
|
||||||
|
|
||||||
onImageUploadStop() {
|
onImageUploadStop = () => {
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
}
|
};
|
||||||
|
|
||||||
onChange = text => {
|
onChange = text => {
|
||||||
if (!this.document) return;
|
if (!this.document) return;
|
||||||
@ -166,7 +166,7 @@ type Props = {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const isNew = this.props.newDocument;
|
const isNew = this.props.newDocument;
|
||||||
const isEditing = this.props.match.params.edit || isNew;
|
const isEditing = !!this.props.match.params.edit || isNew;
|
||||||
const isFetching = !this.document;
|
const isFetching = !this.document;
|
||||||
const titleText = get(this.document, 'title', 'Loading');
|
const titleText = get(this.document, 'title', 'Loading');
|
||||||
|
|
||||||
@ -190,6 +190,7 @@ type Props = {
|
|||||||
onDragEnter={this.onStartDragging}
|
onDragEnter={this.onStartDragging}
|
||||||
onDragLeave={this.onStopDragging}
|
onDragLeave={this.onStopDragging}
|
||||||
onDrop={this.onStopDragging}
|
onDrop={this.onStopDragging}
|
||||||
|
disabled={isEditing}
|
||||||
>
|
>
|
||||||
<Flex justify="center" auto>
|
<Flex justify="center" auto>
|
||||||
<Prompt
|
<Prompt
|
||||||
|
Reference in New Issue
Block a user