mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-07 19:34:33 +08:00
Image manager: fix upload control for drawing, updated styles
- Tightened image manager styles to address things that looked akward. - Prevented visiblity/use of upload controls for drawings. - Updated dropzone to use error handling from validation messages.
This commit is contained in:
@ -12,6 +12,8 @@ export class Dropzone extends Component {
|
||||
this.dropTarget = this.$refs.dropTarget;
|
||||
this.selectButtons = this.$manyRefs.selectButton || [];
|
||||
|
||||
this.isActive = true;
|
||||
|
||||
this.url = this.$opts.url;
|
||||
this.successMessage = this.$opts.successMessage;
|
||||
this.errorMessage = this.$opts.errorMessage;
|
||||
@ -23,6 +25,14 @@ export class Dropzone extends Component {
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Public method to allow external disabling/enabling of this drag+drop dropzone.
|
||||
* @param {Boolean} active
|
||||
*/
|
||||
toggleActive(active) {
|
||||
this.isActive = active;
|
||||
}
|
||||
|
||||
setupListeners() {
|
||||
onSelect(this.selectButtons, this.manualSelectHandler.bind(this));
|
||||
this.setupDropTargetHandlers();
|
||||
@ -40,7 +50,7 @@ export class Dropzone extends Component {
|
||||
event.preventDefault();
|
||||
depth += 1;
|
||||
|
||||
if (depth === 1) {
|
||||
if (depth === 1 && this.isActive) {
|
||||
this.showOverlay();
|
||||
}
|
||||
});
|
||||
@ -59,6 +69,11 @@ export class Dropzone extends Component {
|
||||
this.dropTarget.addEventListener('drop', event => {
|
||||
event.preventDefault();
|
||||
reset();
|
||||
|
||||
if (!this.isActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clipboard = new Clipboard(event.dataTransfer);
|
||||
const files = clipboard.getFiles();
|
||||
for (const file of files) {
|
||||
@ -158,7 +173,7 @@ export class Dropzone extends Component {
|
||||
} else if (this.readyState === XMLHttpRequest.DONE && this.status >= 400) {
|
||||
const content = this.responseText;
|
||||
const data = content.startsWith('{') ? JSON.parse(content) : {message: content};
|
||||
const message = data?.message || content;
|
||||
const message = data?.message || data?.error || content;
|
||||
upload.markError(message);
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user