feat: Enable attachment paste in new conversation modal (#13082)
This commit is contained in:
@@ -9,6 +9,8 @@ import { useAlert } from 'dashboard/composables';
|
|||||||
import { ExceptionWithMessage } from 'shared/helpers/CustomErrors';
|
import { ExceptionWithMessage } from 'shared/helpers/CustomErrors';
|
||||||
import { debounce } from '@chatwoot/utils';
|
import { debounce } from '@chatwoot/utils';
|
||||||
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
||||||
|
import { emitter } from 'shared/helpers/mitt';
|
||||||
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
import {
|
import {
|
||||||
searchContacts,
|
searchContacts,
|
||||||
createNewContact,
|
createNewContact,
|
||||||
@@ -226,6 +228,8 @@ const keyboardEvents = {
|
|||||||
action: () => {
|
action: () => {
|
||||||
if (showComposeNewConversation.value) {
|
if (showComposeNewConversation.value) {
|
||||||
showComposeNewConversation.value = false;
|
showComposeNewConversation.value = false;
|
||||||
|
emit('close');
|
||||||
|
emitter.emit(BUS_EVENTS.NEW_CONVERSATION_MODAL, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { useUISettings } from 'dashboard/composables/useUISettings';
|
import { useUISettings } from 'dashboard/composables/useUISettings';
|
||||||
import { useFileUpload } from 'dashboard/composables/useFileUpload';
|
import { useFileUpload } from 'dashboard/composables/useFileUpload';
|
||||||
import { vOnClickOutside } from '@vueuse/components';
|
import { vOnClickOutside } from '@vueuse/components';
|
||||||
|
import { useEventListener } from '@vueuse/core';
|
||||||
import { ALLOWED_FILE_TYPES } from 'shared/constants/messages';
|
import { ALLOWED_FILE_TYPES } from 'shared/constants/messages';
|
||||||
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
||||||
import FileUpload from 'vue-upload-component';
|
import FileUpload from 'vue-upload-component';
|
||||||
@@ -163,6 +164,20 @@ const keyboardEvents = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
useKeyboardEvents(keyboardEvents);
|
useKeyboardEvents(keyboardEvents);
|
||||||
|
|
||||||
|
const onPaste = e => {
|
||||||
|
if (!props.isEmailOrWebWidgetInbox) return;
|
||||||
|
|
||||||
|
const files = e.clipboardData?.files;
|
||||||
|
if (!files?.length) return;
|
||||||
|
|
||||||
|
Array.from(files).forEach(file => {
|
||||||
|
const { name, type, size } = file;
|
||||||
|
onFileUpload({ file, name, type, size });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEventListener(document, 'paste', onPaste);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { useStorage } from '@vueuse/core';
|
import { useStorage } from '@vueuse/core';
|
||||||
import { useSidebarKeyboardShortcuts } from './useSidebarKeyboardShortcuts';
|
import { useSidebarKeyboardShortcuts } from './useSidebarKeyboardShortcuts';
|
||||||
import { vOnClickOutside } from '@vueuse/components';
|
import { vOnClickOutside } from '@vueuse/components';
|
||||||
|
import { emitter } from 'shared/helpers/mitt';
|
||||||
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
|
|
||||||
import Button from 'dashboard/components-next/button/Button.vue';
|
import Button from 'dashboard/components-next/button/Button.vue';
|
||||||
import SidebarGroup from './SidebarGroup.vue';
|
import SidebarGroup from './SidebarGroup.vue';
|
||||||
@@ -97,6 +99,15 @@ const closeMobileSidebar = () => {
|
|||||||
emit('closeMobileSidebar');
|
emit('closeMobileSidebar');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onComposeOpen = toggleFn => {
|
||||||
|
toggleFn();
|
||||||
|
emitter.emit(BUS_EVENTS.NEW_CONVERSATION_MODAL, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onComposeClose = () => {
|
||||||
|
emitter.emit(BUS_EVENTS.NEW_CONVERSATION_MODAL, false);
|
||||||
|
};
|
||||||
|
|
||||||
const newReportRoutes = () => [
|
const newReportRoutes = () => [
|
||||||
{
|
{
|
||||||
name: 'Reports Agent',
|
name: 'Reports Agent',
|
||||||
@@ -624,14 +635,14 @@ const menuItems = computed(() => {
|
|||||||
{{ searchShortcut }}
|
{{ searchShortcut }}
|
||||||
</span>
|
</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<ComposeConversation align-position="right">
|
<ComposeConversation align-position="right" @close="onComposeClose">
|
||||||
<template #trigger="{ toggle }">
|
<template #trigger="{ toggle }">
|
||||||
<Button
|
<Button
|
||||||
icon="i-lucide-pen-line"
|
icon="i-lucide-pen-line"
|
||||||
color="slate"
|
color="slate"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="!h-7 !bg-n-solid-3 dark:!bg-n-black/30 !outline-n-weak !text-n-slate-11"
|
class="!h-7 !bg-n-solid-3 dark:!bg-n-black/30 !outline-n-weak !text-n-slate-11"
|
||||||
@click="toggle"
|
@click="onComposeOpen(toggle)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</ComposeConversation>
|
</ComposeConversation>
|
||||||
|
|||||||
@@ -688,6 +688,10 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
onPaste(e) {
|
onPaste(e) {
|
||||||
|
// Don't handle paste if compose new conversation modal is open
|
||||||
|
if (this.newConversationModalActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const data = e.clipboardData.files;
|
const data = e.clipboardData.files;
|
||||||
if (!this.showRichContentEditor && data.length !== 0) {
|
if (!this.showRichContentEditor && data.length !== 0) {
|
||||||
this.$refs.messageInput?.$el?.blur();
|
this.$refs.messageInput?.$el?.blur();
|
||||||
|
|||||||
Reference in New Issue
Block a user