vue-advanced-chat icon indicating copy to clipboard operation
vue-advanced-chat copied to clipboard

Option to render html as message content

Open MatthewLoffredo opened this issue 3 years ago • 2 comments
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!

MatthewLoffredo avatar Apr 20 '22 14:04 MatthewLoffredo

Indeed that could be useful, will try to implement that soon

antoine92190 avatar May 07 '22 07:05 antoine92190

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>

vesper8 avatar Nov 30 '23 19:11 vesper8