mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +01:00
Ref: attachment image paste
This commit is contained in:
parent
e2934b9b09
commit
ae8d4c1bbd
1 changed files with 22 additions and 20 deletions
|
|
@ -67,7 +67,6 @@ Template.cardAttachmentsPopup.events({
|
||||||
const uploader = Attachments.insert(
|
const uploader = Attachments.insert(
|
||||||
{
|
{
|
||||||
file: event.currentTarget.files[0],
|
file: event.currentTarget.files[0],
|
||||||
streams: 'dynamic',
|
|
||||||
chunkSize: 'dynamic',
|
chunkSize: 'dynamic',
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
|
@ -136,26 +135,29 @@ Template.previewClipboardImagePopup.events({
|
||||||
if (results && results.file) {
|
if (results && results.file) {
|
||||||
window.oPasted = pastedResults;
|
window.oPasted = pastedResults;
|
||||||
const card = this;
|
const card = this;
|
||||||
const file = new FS.File(results.file);
|
const uploader = Attachments.insert(
|
||||||
if (!results.name) {
|
{
|
||||||
// if no filename, it's from clipboard. then we give it a name, with ext name from MIME type
|
file: results.file,
|
||||||
if (typeof results.file.type === 'string') {
|
fileName:
|
||||||
file.name(results.file.type.replace('image/', 'clipboard.'));
|
results.name || results.file.type.replace('image/', 'clipboard.'),
|
||||||
|
chunkSize: 'dynamic',
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
uploader.on('uploaded', (error, fileObj) => {
|
||||||
|
if (!error) {
|
||||||
|
if (fileObj.isImage) {
|
||||||
|
card.setCover(fileObj._id);
|
||||||
}
|
}
|
||||||
|
Utils.addCommonMetaToAttachment(card, fileObj);
|
||||||
}
|
}
|
||||||
file.updatedAt(new Date());
|
});
|
||||||
file.boardId = card.boardId;
|
uploader.on('end', (error, fileObj) => {
|
||||||
file.cardId = card._id;
|
|
||||||
file.userId = Meteor.userId();
|
|
||||||
const attachment = Attachments.insert(file);
|
|
||||||
|
|
||||||
if (attachment && attachment._id && attachment.isImage()) {
|
|
||||||
card.setCover(attachment._id);
|
|
||||||
}
|
|
||||||
|
|
||||||
pastedResults = null;
|
pastedResults = null;
|
||||||
$(document.body).pasteImageReader(() => {});
|
$(document.body).pasteImageReader(() => {});
|
||||||
Popup.back();
|
Popup.back();
|
||||||
|
});
|
||||||
|
uploader.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue