Merge branch 'develop' into fix/next-message-bubbles

This commit is contained in:
Sivin Varghese
2025-02-03 15:21:15 +05:30
committed by GitHub
4 changed files with 27 additions and 40 deletions
@@ -171,6 +171,10 @@ watch(
{ immediate: true, deep: true }
);
const handleClickOutside = () => {
showComposeNewConversation.value = false;
};
onMounted(() => resetContacts());
const keyboardEvents = {
@@ -188,7 +192,12 @@ useKeyboardEvents(keyboardEvents);
<template>
<div
v-on-click-outside="() => (showComposeNewConversation = false)"
v-on-click-outside="[
handleClickOutside,
// Fixed and edge case https://github.com/chatwoot/chatwoot/issues/10785
// This will prevent closing the compose conversation modal when the editor Create link popup is open.
{ ignore: ['div.ProseMirror-prompt'] },
]"
class="relative"
:class="{
'z-40': showComposeNewConversation,
@@ -1,6 +1,7 @@
<script setup>
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { getFileInfo } from '@chatwoot/utils';
import FileIcon from 'next/icon/FileIcon.vue';
import Icon from 'next/icon/Icon.vue';
@@ -14,43 +15,20 @@ const { attachment } = defineProps({
const { t } = useI18n();
const fileName = computed(() => {
const url = attachment.dataUrl;
if (!url) return t('CONVERSATION.UNKNOWN_FILE_TYPE');
try {
const encodedFilename = url.substring(url.lastIndexOf('/') + 1);
return decodeURIComponent(encodedFilename);
} catch {
return t('CONVERSATION.UNKNOWN_FILE_TYPE');
}
});
const fileType = computed(() => fileName.value.split('.').pop()?.toLowerCase());
const fileNameWithoutExt = computed(() => {
const parts = fileName.value.split('.');
// If there's no extension (no dots in filename)
if (parts.length === 1) {
return fileName.value.trim();
}
// Take all parts except the last one (extension)
const nameWithoutExt = parts.slice(0, -1).join('.');
return nameWithoutExt.trim();
const fileDetails = computed(() => {
return getFileInfo(attachment?.dataUrl || '');
});
const displayFileName = computed(() => {
const name = fileNameWithoutExt.value;
const { base, type } = fileDetails.value;
const truncatedName = (str, maxLength, hasExt) =>
str.length > maxLength
? `${str.substring(0, maxLength).trimEnd()}${hasExt ? '..' : '...'}`
: str;
return fileType.value
? `${truncatedName(name, 12, true)}.${fileType.value}`
: truncatedName(name, 14, false);
return type
? `${truncatedName(base, 12, true)}.${type}`
: truncatedName(base, 14, false);
});
const textColorClass = computed(() => {
@@ -73,7 +51,7 @@ const textColorClass = computed(() => {
zip: 'dark:text-[#EDEEF0] text-[#2F265F]',
};
return colorMap[fileType.value] || 'text-n-slate-12';
return colorMap[fileDetails.value.type] || 'text-n-slate-12';
});
</script>
@@ -81,10 +59,10 @@ const textColorClass = computed(() => {
<div
class="h-9 bg-n-alpha-white gap-2 overflow-hidden items-center flex px-2 rounded-lg border border-n-container"
>
<FileIcon class="flex-shrink-0" :file-type="fileType" />
<FileIcon class="flex-shrink-0" :file-type="fileDetails.type" />
<span
class="flex-1 min-w-0 whitespace-nowrap overflow-hidden text-sm max-w-36"
:title="fileName"
class="flex-1 min-w-0 text-sm max-w-36"
:title="fileDetails.name"
:class="textColorClass"
>
{{ displayFileName }}