mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
fix: Add multiple file paste support and fix for bugs (#4066)
- Add multiple files paste support. - Fixes showing file name in the editor field when we paste the file from finder. - Fixes showing the image in the advance editor when we paste the image as an attachment from the clipboard. Fixes: #4036 Co-authored-by: Nithin David <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="preview-item__wrap">
|
||||||
<div
|
<div
|
||||||
v-for="(attachment, index) in attachments"
|
v-for="(attachment, index) in attachments"
|
||||||
:key="attachment.id"
|
:key="attachment.id"
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="file-size-wrap">
|
<div class="file-size-wrap">
|
||||||
<span class="item">
|
<span class="item text-truncate">
|
||||||
{{ formatFileSize(attachment.resource) }}
|
{{ formatFileSize(attachment.resource) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,15 +70,23 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.preview-item__wrap {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: auto;
|
||||||
|
margin-top: var(--space-normal);
|
||||||
|
max-height: 20rem;
|
||||||
|
}
|
||||||
|
|
||||||
.preview-item {
|
.preview-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: var(--space-slab) 0 0;
|
padding: var(--space-slab) 0 0;
|
||||||
background: var(--color-background-light);
|
background: var(--color-background-light);
|
||||||
background: var(--b-50);
|
background: var(--b-50);
|
||||||
border-radius: var(--border-radius-normal);
|
border-radius: var(--border-radius-normal);
|
||||||
width: fit-content;
|
width: 24rem;
|
||||||
padding: var(--space-smaller);
|
padding: var(--space-smaller);
|
||||||
margin-top: var(--space-normal);
|
margin-bottom: var(--space-one);
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumb-wrap {
|
.thumb-wrap {
|
||||||
@@ -114,6 +122,7 @@ export default {
|
|||||||
|
|
||||||
> .item {
|
> .item {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
font-size: var(--font-size-mini);
|
font-size: var(--font-size-mini);
|
||||||
font-weight: var(--font-weight-medium);
|
font-weight: var(--font-weight-medium);
|
||||||
}
|
}
|
||||||
@@ -124,7 +133,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.file-name-wrap {
|
.file-name-wrap {
|
||||||
max-width: 50%;
|
max-width: 60%;
|
||||||
|
min-width: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin-left: var(--space-small);
|
margin-left: var(--space-small);
|
||||||
|
|||||||
@@ -186,6 +186,12 @@ export default {
|
|||||||
blur: () => {
|
blur: () => {
|
||||||
this.onBlur();
|
this.onBlur();
|
||||||
},
|
},
|
||||||
|
paste: (view, event) => {
|
||||||
|
const data = event.clipboardData.files;
|
||||||
|
if (data.length > 0) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.focusEditorInputField();
|
this.focusEditorInputField();
|
||||||
|
|||||||
@@ -452,12 +452,16 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
onPaste(e) {
|
onPaste(e) {
|
||||||
const data = e.clipboardData.files;
|
const data = e.clipboardData.files;
|
||||||
|
if (!this.showRichContentEditor && data.length !== 0) {
|
||||||
|
this.$refs.messageInput.$el.blur();
|
||||||
|
}
|
||||||
if (!data.length || !data[0]) {
|
if (!data.length || !data[0]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const file = data[0];
|
data.forEach(file => {
|
||||||
const { name, type, size } = file;
|
const { name, type, size } = file;
|
||||||
this.onFileUpload({ name, type, size, file });
|
this.onFileUpload({ name, type, size, file: file });
|
||||||
|
});
|
||||||
},
|
},
|
||||||
toggleUserMention(currentMentionState) {
|
toggleUserMention(currentMentionState) {
|
||||||
this.hasUserMention = currentMentionState;
|
this.hasUserMention = currentMentionState;
|
||||||
|
|||||||
Reference in New Issue
Block a user