mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
This PR has fixes for the following issues - Inconsistent spacing between meta and text in text bubble - Activity bubble overflows for longer text (for now I have truncated it, I'll work with @absurdiya on a better solution) - Ugly lookinh gradient for expand button on email bubble - Email bubble overflow issues and text rendering issues - Alignment for error message - Minute-wise grouping not working - Link color should not be blue - Use `gray-3` for bubble background instead of `gray-4`
115 lines
3.1 KiB
Vue
115 lines
3.1 KiB
Vue
<script setup>
|
|
import { computed } from 'vue';
|
|
|
|
import MessageMeta from '../MessageMeta.vue';
|
|
|
|
import { emitter } from 'shared/helpers/mitt';
|
|
import { useMessageContext } from '../provider.js';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
|
import { MESSAGE_VARIANTS, ORIENTATION } from '../constants';
|
|
|
|
const { variant, orientation, inReplyTo, shouldGroupWithNext } =
|
|
useMessageContext();
|
|
const { t } = useI18n();
|
|
|
|
const varaintBaseMap = {
|
|
[MESSAGE_VARIANTS.AGENT]: 'bg-n-solid-blue text-n-slate-12',
|
|
[MESSAGE_VARIANTS.PRIVATE]:
|
|
'bg-n-solid-amber text-n-amber-12 [&_.prosemirror-mention-node]:font-semibold',
|
|
[MESSAGE_VARIANTS.USER]: 'bg-n-gray-3 text-n-slate-12',
|
|
[MESSAGE_VARIANTS.ACTIVITY]: 'bg-n-alpha-1 text-n-slate-11 text-sm',
|
|
[MESSAGE_VARIANTS.BOT]: 'bg-n-solid-iris text-n-slate-12',
|
|
[MESSAGE_VARIANTS.TEMPLATE]: 'bg-n-solid-iris text-n-slate-12',
|
|
[MESSAGE_VARIANTS.ERROR]: 'bg-n-ruby-4 text-n-ruby-12',
|
|
[MESSAGE_VARIANTS.EMAIL]: 'bg-n-gray-3 w-full',
|
|
[MESSAGE_VARIANTS.UNSUPPORTED]:
|
|
'bg-n-solid-amber/70 border border-dashed border-n-amber-12 text-n-amber-12',
|
|
};
|
|
|
|
const orientationMap = {
|
|
[ORIENTATION.LEFT]: 'rounded-xl rounded-bl-sm',
|
|
[ORIENTATION.RIGHT]: 'rounded-xl rounded-br-sm',
|
|
[ORIENTATION.CENTER]: 'rounded-md',
|
|
};
|
|
|
|
const flexOrientationClass = computed(() => {
|
|
const map = {
|
|
[ORIENTATION.LEFT]: 'justify-start',
|
|
[ORIENTATION.RIGHT]: 'justify-end',
|
|
[ORIENTATION.CENTER]: 'justify-center',
|
|
};
|
|
|
|
return map[orientation.value];
|
|
});
|
|
|
|
const messageClass = computed(() => {
|
|
const classToApply = [varaintBaseMap[variant.value]];
|
|
|
|
if (variant.value !== MESSAGE_VARIANTS.ACTIVITY) {
|
|
classToApply.push(orientationMap[orientation.value]);
|
|
} else {
|
|
classToApply.push('rounded-lg');
|
|
}
|
|
|
|
return classToApply;
|
|
});
|
|
|
|
const scrollToMessage = () => {
|
|
emitter.emit(BUS_EVENTS.SCROLL_TO_MESSAGE, {
|
|
messageId: this.message.id,
|
|
});
|
|
};
|
|
|
|
const previewMessage = computed(() => {
|
|
if (!inReplyTo) return '';
|
|
|
|
const { content, attachments } = inReplyTo;
|
|
|
|
if (content) return content;
|
|
if (attachments?.length) {
|
|
const firstAttachment = attachments[0];
|
|
const fileType = firstAttachment.fileType ?? firstAttachment.file_type;
|
|
|
|
return t(`CHAT_LIST.ATTACHMENTS.${fileType}.CONTENT`);
|
|
}
|
|
|
|
return t('CONVERSATION.REPLY_MESSAGE_NOT_FOUND');
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
class="text-sm"
|
|
:class="[
|
|
messageClass,
|
|
{
|
|
'max-w-lg': variant !== MESSAGE_VARIANTS.EMAIL,
|
|
},
|
|
]"
|
|
>
|
|
<div
|
|
v-if="inReplyTo"
|
|
class="bg-n-alpha-black1 rounded-lg p-2"
|
|
@click="scrollToMessage"
|
|
>
|
|
<span class="line-clamp-2">
|
|
{{ previewMessage }}
|
|
</span>
|
|
</div>
|
|
<slot />
|
|
<MessageMeta
|
|
v-if="!shouldGroupWithNext && variant !== MESSAGE_VARIANTS.ACTIVITY"
|
|
:class="[
|
|
flexOrientationClass,
|
|
variant === MESSAGE_VARIANTS.EMAIL ? 'px-3 pb-3' : '',
|
|
variant === MESSAGE_VARIANTS.PRIVATE
|
|
? 'text-n-amber-12/50'
|
|
: 'text-n-slate-11',
|
|
]"
|
|
class="mt-2"
|
|
/>
|
|
</div>
|
|
</template>
|