2023-05-02 22:53:27 +02:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="group rounded-lg m-2 shadow-lg hover:border-primary dark:hover:border-primary hover:border-solid hover:border-2 border-2 border-transparent even:bg-bg-light-discussion-odd dark:even:bg-bg-dark-discussion-odd flex-row p-4 pb-2">
|
|
|
|
<div class="w-30 flex">
|
|
|
|
<!-- SENDER -->
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="w-10 h-10 rounded-lg object-fill drop-shadow-md">
|
|
|
|
|
|
|
|
<img :src="getImgUrl()" class="w-10 h-10 rounded-full object-fill text-red-700">
|
|
|
|
|
2023-05-02 22:53:27 +02:00
|
|
|
|
|
|
|
</div>
|
|
|
|
<p class="drop-shadow-sm py-0 px-2 text-lg text-opacity-95 font-bold ">{{ message.sender }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="-mt-4 ml-10 mr-0 pt-1 px-2 max-w-screen-2xl ">
|
|
|
|
<!-- CONTENT/MESSAGE -->
|
2023-05-07 10:20:59 +02:00
|
|
|
<markdown-renderer :markdown-text="message.content"></markdown-renderer>
|
|
|
|
|
2023-05-02 22:53:27 +02:00
|
|
|
</div>
|
|
|
|
<div class="invisible group-hover:visible flex flex-row mt-3 -mb-2">
|
|
|
|
<!-- MESSAGE CONTROLS -->
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Edit message">
|
2023-05-02 22:53:27 +02:00
|
|
|
<i data-feather="edit"></i>
|
|
|
|
</div>
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Copy message to clipboard"
|
|
|
|
@click.stop="copyContentToClipboard()">
|
2023-05-02 22:53:27 +02:00
|
|
|
<i data-feather="copy"></i>
|
|
|
|
</div>
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Resend message">
|
2023-05-02 22:53:27 +02:00
|
|
|
<i data-feather="refresh-cw"></i>
|
|
|
|
</div>
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-red-600 duration-75 active:scale-90 p-2" title="Remove message">
|
2023-05-02 22:53:27 +02:00
|
|
|
<i data-feather="trash"></i>
|
|
|
|
</div>
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Upvote">
|
2023-05-02 22:53:27 +02:00
|
|
|
<i data-feather="thumbs-up"></i>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-row items-center">
|
2023-05-07 18:01:05 +03:00
|
|
|
<div class="text-lg hover:text-red-600 duration-75 active:scale-90 p-2" title="Downvote">
|
|
|
|
<i data-feather="thumbs-down"></i>
|
|
|
|
</div>
|
2023-05-02 22:53:27 +02:00
|
|
|
<div v-if="message.rank != 0" class="rounded-full px-2 text-sm flex items-center justify-center font-bold"
|
|
|
|
:class="message.rank > 0 ? 'bg-secondary' : 'bg-red-600'" title="Rank">{{ message.rank }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-07 18:01:05 +03:00
|
|
|
</div>
|
2023-05-02 22:53:27 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-07 18:01:05 +03:00
|
|
|
import botImgPlaceholder from "../assets/logo.svg"
|
|
|
|
import userImgPlaceholder from "../assets/default_user.svg"
|
|
|
|
import { nextTick } from 'vue'
|
2023-05-02 22:53:27 +02:00
|
|
|
import feather from 'feather-icons'
|
2023-05-07 10:20:59 +02:00
|
|
|
import MarkdownRenderer from './MarkdownRenderer.vue';
|
2023-05-02 22:53:27 +02:00
|
|
|
export default {
|
|
|
|
name: 'Message',
|
2023-05-07 15:40:57 +03:00
|
|
|
emits: ['copy'],
|
2023-05-07 10:20:59 +02:00
|
|
|
components: {
|
|
|
|
MarkdownRenderer
|
|
|
|
},
|
2023-05-02 22:53:27 +02:00
|
|
|
props: {
|
|
|
|
message: Object
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-05-07 18:01:05 +03:00
|
|
|
|
|
|
|
senderImg: ''
|
2023-05-02 22:53:27 +02:00
|
|
|
}
|
2023-05-07 18:01:05 +03:00
|
|
|
}, mounted() {
|
|
|
|
this.senderImg = botImgPlaceholder
|
|
|
|
nextTick(() => {
|
|
|
|
feather.replace()
|
2023-05-02 22:53:27 +02:00
|
|
|
|
2023-05-07 18:01:05 +03:00
|
|
|
})
|
|
|
|
}, methods: {
|
|
|
|
copyContentToClipboard() {
|
2023-05-07 15:40:57 +03:00
|
|
|
this.$emit('copy', this.message.content)
|
|
|
|
navigator.clipboard.writeText(this.message.content);
|
2023-05-07 18:01:05 +03:00
|
|
|
},
|
|
|
|
getImgUrl() {
|
|
|
|
|
|
|
|
if (this.message.sender == "user") {
|
|
|
|
return userImgPlaceholder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return botImgPlaceholder;
|
2023-05-07 15:40:57 +03:00
|
|
|
}
|
2023-05-07 18:01:05 +03:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2023-05-02 22:53:27 +02:00
|
|
|
}
|
|
|
|
</script>
|