vue-advanced-chat
vue-advanced-chat copied to clipboard
Option to render html as message content
trafficstars
For certain messages in an application, it's necessary to display them in a certain way/have custom functionality built into them. Being able to render html for a message would serve this use case and many others. There could be a prop on the message object with the intended html to render. I think this would be a very useful feature for many people!
Indeed that could be useful, will try to implement that soon
I was able to achieve this using the :slot="'message_' + message._id" slot
Here's the code I used
<div
v-for="message in transformedMessages"
:slot="'message_' + message._id"
>
<div class="my-1 flex flex-row items-center justify-center space-x-2 pr-2">
<div class="">
<Avatar
:name="message.username"
color="white"
:size="35"
:inverted="false"
:inline="false"
:rounded="true"
/>
</div>
<div
class="rounded-xl bg-white p-2 shadow-sm"
v-html="message.content"
/>
</div>
</div>