mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Fix image uploading after pasting from clipboard [SCI-10549]
This commit is contained in:
parent
0f805d3896
commit
53786e2980
1 changed files with 17 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue