@bcc-code/vue-bcc-chat-ui 5.6.4 → 5.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bcc-code/vue-bcc-chat-ui",
3
3
  "author": "bcc-code",
4
4
  "license": "Apache-2.0",
5
- "version": "5.6.4",
5
+ "version": "5.6.5",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -1,12 +1,11 @@
1
1
  <script setup lang="ts">
2
- import MarkdownIt from 'markdown-it'
3
- import { BaseMessage, CometChat, MediaMessage, User } from '@cometchat/chat-sdk-javascript'
4
- import DOMPurify from 'dompurify';
5
- import { inject, ref } from 'vue';
2
+ import { BaseMessage, CometChat, MediaMessage, User } from '@cometchat/chat-sdk-javascript';
6
3
  import { CometChatTheme, fontHelper } from '@cometchat/uikit-resources';
7
- import BccReplyPreview from "./BccReplyPreview.vue";
8
- import BccImageBubble from './BccImageBubble.vue';
4
+ import { inject, ref } from 'vue';
5
+ import chat from "../chat";
9
6
  import { offlineStore } from '../offline';
7
+ import BccImageBubble from './BccImageBubble.vue';
8
+ import BccReplyPreview from "./BccReplyPreview.vue";
10
9
 
11
10
  const props = defineProps({
12
11
  id: {
@@ -42,51 +41,6 @@ const props = defineProps({
42
41
  }
43
42
  })
44
43
 
45
- function toMarkdownHtml(str: string) {
46
- str = formatMentionsInText(str);
47
-
48
- const md = new MarkdownIt({
49
- breaks: true,
50
- typographer: true,
51
- linkify: true,
52
- html: true
53
- });
54
-
55
- str = md.render(str);
56
-
57
- str = DOMPurify.sanitize(str, {
58
- ALLOWED_TAGS: [
59
- "a", // links
60
- "ul", "ol", "li", // lists
61
- "p", // paragraphs
62
- "b", "strong", // bold
63
- "i", "em", // italics
64
- "u", // underline
65
- "s", // strikethrough
66
- "img", // images
67
- "blockquote", // indented text
68
- "hr", // horizontal line
69
- "pre", // constant width text
70
- "br", // newline
71
- "div" // newline on mobile
72
- ]
73
- })
74
-
75
- return str
76
- }
77
-
78
- function formatMentionsInText(text: string) {
79
- return text.replace(/<@uid:(.*?)>/g, (_match: string, uid: string) => {
80
- const user = (props.mentionedUsers || []).find((user) => user.getUid() === uid);
81
- // Check if a userName exists for the given uid; if not, keep the original match
82
- if (user) {
83
- return `**${user.getName()}**`;
84
- } else {
85
- return `**@unknown**`;
86
- }
87
- });
88
- }
89
-
90
44
  let parentMsgRef = ref<BaseMessage>();
91
45
  if (props.metadata?.replyToMessageId) {
92
46
  let guidString = props.guid?.toString()
@@ -141,9 +95,9 @@ const replyPreviewStyle = {
141
95
  :src="src"
142
96
  />
143
97
  </div>
144
- <div v-if="text && metadata && metadata.translated_message" v-html="toMarkdownHtml(metadata.translated_message)"
98
+ <div v-if="text && metadata && metadata.translated_message" v-html="chat.toMarkdownHtml(metadata.translated_message, mentionedUsers)"
145
99
  class="bcc-chat-msg-bubble bcc-chat-msg-bubble--translation" />
146
- <div v-if="text" v-html="toMarkdownHtml(text)" class="bcc-chat-msg-bubble" :id="id"
100
+ <div v-if="text" v-html="chat.toMarkdownHtml(text, mentionedUsers)" class="bcc-chat-msg-bubble" :id="id"
147
101
  :class="{ 'bcc-chat-msg-bubble--translated': metadata && !!metadata.translated_message }" />
148
102
  </div>
149
103
  </template>
@@ -1,9 +1,10 @@
1
1
  <script setup lang="ts">
2
+ import { BaseMessage, MediaMessage } from "@cometchat/chat-sdk-javascript";
2
3
  import { CometChatTheme, CometChatUIKitConstants } from "@cometchat/uikit-resources";
3
4
  import { inject, ref } from "vue";
5
+ import chat from '../chat';
6
+ import { getMessageTextPreview, getSenderDisplayName, proxyImage } from "../chat/data";
4
7
  import { ReplyPreviewStyle } from "../chat/replyStyle";
5
- import { BaseMessage, MediaMessage } from "@cometchat/chat-sdk-javascript";
6
- import { getMessageTextPreview, proxyImage, getSenderDisplayName } from "../chat/data";
7
8
 
8
9
  const props = defineProps({
9
10
  replyToMessage: { type: BaseMessage },
@@ -64,9 +65,7 @@ function getThumbnailURL() {
64
65
  <p class="bcc__reply_preview__title" :style="titleStyle()">
65
66
  {{ props.titlePrefix + ( getSenderDisplayName(props.replyToMessage) || "" ) || "Reply to ..." }}
66
67
  </p>
67
- <p class="cc__preview__subtitle" :style="subtitleStyle()">
68
- {{ getMessageTextPreview(props?.replyToMessage) || "‎" }}
69
- </p>
68
+ <p class="cc__preview__subtitle" v-html="chat.toMarkdownHtml(getMessageTextPreview(props?.replyToMessage), props.replyToMessage?.getMentionedUsers()) || '‎'" :style="subtitleStyle()"/>
70
69
  </div>
71
70
  </div>
72
71
  </template>
@@ -92,7 +91,7 @@ function getThumbnailURL() {
92
91
  overflow: hidden;
93
92
  display: -webkit-box;
94
93
  -webkit-box-orient: vertical;
95
- -webkit-line-clamp: 1;
94
+ -webkit-line-clamp: 8;
96
95
  word-break: break-all;
97
96
  }
98
97
  .bcc__reply_preview__content > .bcc__reply_preview__title {