Fix issues with saving files in web app

Fix several web app UI details
This commit is contained in:
JannisX11 2021-03-10 13:05:44 +01:00
parent ce6ba0e178
commit 98c3ccbd6e
5 changed files with 15 additions and 6 deletions

View File

@ -284,6 +284,7 @@
height: 100%;
overflow-x: hidden;
overflow-y: auto;
flex-grow: 1;
}
.toolbar_wrapper > .toolbar.vertical {
width: 40px;

View File

@ -254,12 +254,15 @@ Object.assign(Blockbench, {
} else {
let a = document.createElement('a');
a.target = '_blank'
if (options.savetype === 'image') {
a.href = options.content;
} else if (options.savetype === 'zip' || options.savetype === 'buffer' || options.savetype === 'binary') {
let blob = new Blob(data, {type: "octet/stream"});
let blob = options.content instanceof Blob
? options.content
: new Blob(options.content, {type: "octet/stream"});
a.href = window.URL.createObjectURL(blob);
} else {
@ -269,7 +272,12 @@ Object.assign(Blockbench, {
a.download = file_name;
if (Blockbench.browser === 'firefox') document.body.appendChild(a);
a.click();
var event = document.createEvent("MouseEvents");
event.initMouseEvent(
"click", true, false, window, 0, 0, 0, 0, 0
, false, false, false, false, 0, null
);
a.dispatchEvent(event);
if (Blockbench.browser === 'firefox') document.body.removeChild(a);
}

View File

@ -478,8 +478,10 @@ window.Dialog = class Dialog {
if (this.width) {
jq_dialog.css('width', this.width+'px');
}
let first_focus = jq_dialog.find('.focusable_input').first();
if (first_focus) first_focus.focus();
if (!Blockbench.isTouch) {
let first_focus = jq_dialog.find('.focusable_input').first();
if (first_focus) first_focus.trigger('focus');
}
open_dialog = this.id;
open_interface = this;

View File

@ -119,7 +119,6 @@ class Plugin {
})
});
});
return this;
}
async loadFromFile(file, first) {
var scope = this;

View File

@ -6,7 +6,6 @@ workbox.generateSW({
globPatterns: [
'./index.html',
'./favicon.png',
'./service_worker.js',
'./js/**/*',
'./lib/**/*',