mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
feat: Adds support for paste attachment with keys. (#3293)
* copy paste files * Minor fixes * Adds support for pasting attachment * Minor files * Review fixes
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
@toggle-canned-menu="toggleCannedMenu"
|
@toggle-canned-menu="toggleCannedMenu"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="hasAttachments" class="attachment-preview-box">
|
<div v-if="hasAttachments" class="attachment-preview-box" @paste="onPaste">
|
||||||
<attachment-preview
|
<attachment-preview
|
||||||
:attachments="attachedFiles"
|
:attachments="attachedFiles"
|
||||||
:remove-attachment="removeAttachment"
|
:remove-attachment="removeAttachment"
|
||||||
@@ -314,11 +314,22 @@ export default {
|
|||||||
// Donot use the keyboard listener mixin here as the events here are supposed to be
|
// Donot use the keyboard listener mixin here as the events here are supposed to be
|
||||||
// working even if input/textarea is focussed.
|
// working even if input/textarea is focussed.
|
||||||
document.addEventListener('keydown', this.handleKeyEvents);
|
document.addEventListener('keydown', this.handleKeyEvents);
|
||||||
|
document.addEventListener('paste', this.onPaste);
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
document.removeEventListener('keydown', this.handleKeyEvents);
|
document.removeEventListener('keydown', this.handleKeyEvents);
|
||||||
|
document.removeEventListener('paste', this.onPaste);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onPaste(e) {
|
||||||
|
const data = e.clipboardData.files;
|
||||||
|
if (!data.length || !data[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const file = data[0];
|
||||||
|
const { name, type, size } = file;
|
||||||
|
this.onFileUpload({ name, type, size, file });
|
||||||
|
},
|
||||||
toggleUserMention(currentMentionState) {
|
toggleUserMention(currentMentionState) {
|
||||||
this.hasUserMention = currentMentionState;
|
this.hasUserMention = currentMentionState;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user