Fix image uploading after pasting from clipboard [SCI-10549]

This commit is contained in:
Andrej 2024-03-29 15:11:00 +01:00
parent 0f805d3896
commit 53786e2980

View file

@ -111,6 +111,23 @@ export default {
this.extension = extension;
this.imageBlob = imageBlob;
}
},
uploadImage() {
const newName = this.fileName;
const imageBlog = this.imageBlob;
// check if the name is set
if (newName && newName.length > 0) {
const extension = imageBlog.name.slice(
(Math.max(0, imageBlog.name.lastIndexOf('.')) || Infinity) + 1
);
// hack to inject custom name in File object
const name = newName + '.' + extension;
const blob = imageBlog.slice(0, imageBlog.size, imageBlog.type);
// make new blob with the correct name;
this.imageBlob = new File([blob], name, { type: imageBlog.type });
}
$(this.$refs.modal).modal('hide');
this.$emit('files', this.imageBlob, this.target);
}
}
};