@bcc-code/vue-bcc-chat-ui 2.2.3 → 2.3.0
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
|
@@ -8,17 +8,17 @@ defineProps<{
|
|
|
8
8
|
|
|
9
9
|
function toMarkdownHtml(str: string) {
|
|
10
10
|
// Regex to match URLs that may or may not start with "www." and are not already part of a Markdown link
|
|
11
|
-
const urlRegex = /(
|
|
11
|
+
const urlRegex = /([^\]]\(|[^\(]|^\(?)((?:https?|ftp):\/\/[^\s\]\)]*|www\.[^\s\]\)]+)(?=[\s\]\)](?!\()|$)/g;
|
|
12
12
|
|
|
13
13
|
// Function to format a URL into a Markdown link
|
|
14
|
-
const formatUrlToMarkdown = (
|
|
15
|
-
let url =
|
|
14
|
+
const formatUrlToMarkdown = (_match: string, group1: string, group2: string) => {
|
|
15
|
+
let url = group2;
|
|
16
16
|
// Prepend "http://" to URLs starting with "www."
|
|
17
17
|
if (url.startsWith('www.')) {
|
|
18
18
|
url = 'http://' + url;
|
|
19
19
|
}
|
|
20
20
|
const hostname = new URL(url).hostname;
|
|
21
|
-
return
|
|
21
|
+
return `${group1}[${hostname}](${url})`;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// Replacing URLs in the string with Markdown links
|
|
@@ -33,14 +33,14 @@ function toMarkdownHtml(str: string) {
|
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
35
|
<template>
|
|
36
|
-
<div v-if="metadata.translated_message"
|
|
36
|
+
<div v-if="metadata && metadata.translated_message"
|
|
37
37
|
v-html="toMarkdownHtml(metadata.translated_message)"
|
|
38
38
|
class="bcc-chat-msg-bubble bcc-chat-msg-bubble--translation"
|
|
39
39
|
/>
|
|
40
40
|
<div
|
|
41
41
|
v-html="toMarkdownHtml(text)"
|
|
42
42
|
class="bcc-chat-msg-bubble"
|
|
43
|
-
:class="{'bcc-chat-msg-bubble--translated': !!metadata.translated_message}"
|
|
43
|
+
:class="{'bcc-chat-msg-bubble--translated': metadata && !!metadata.translated_message}"
|
|
44
44
|
/>
|
|
45
45
|
</template>
|
|
46
46
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
+
onBeforeMount,
|
|
3
4
|
onMounted,
|
|
4
5
|
onUnmounted,
|
|
5
6
|
ref,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
messageComposerConfiguration,
|
|
16
17
|
messageListConfiguration,
|
|
17
18
|
} from "../chat/uiKit";
|
|
18
|
-
import { OnlineStatus } from "../offline/types";
|
|
19
19
|
|
|
20
20
|
const props = defineProps({
|
|
21
21
|
chatUid: { type: String, required: true },
|
|
@@ -25,7 +25,6 @@ const componentId = ref(
|
|
|
25
25
|
`component-${Math.random().toString(36).substring(2, 11)}`
|
|
26
26
|
);
|
|
27
27
|
const chatGroup = ref<Group>();
|
|
28
|
-
const chatReady = ref(false);
|
|
29
28
|
|
|
30
29
|
watch([loggedIn, ()=>props.chatUid, chat.initialized], async ([_loggedIn, _chatUid, _initialized]) => {
|
|
31
30
|
if (_loggedIn && _chatUid && _initialized) {
|
|
@@ -36,12 +35,19 @@ watch([loggedIn, ()=>props.chatUid, chat.initialized], async ([_loggedIn, _chatU
|
|
|
36
35
|
}
|
|
37
36
|
}, { immediate: true });
|
|
38
37
|
|
|
39
|
-
watch(chat.onlineStatus, async (
|
|
40
|
-
|
|
38
|
+
watch(chat.onlineStatus, async () => {
|
|
39
|
+
await tryConnect(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
async function tryConnect(force: boolean) {
|
|
43
|
+
if (chat.onlineStatus.value === "online" || force) {
|
|
41
44
|
await connect(componentId.value);
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onBeforeMount(() => {
|
|
49
|
+
tryConnect(true);
|
|
50
|
+
});
|
|
45
51
|
|
|
46
52
|
onMounted(() => {
|
|
47
53
|
watchAndApplyStyle(".bcc-chat-message-list-wrapper", [
|
|
@@ -100,7 +106,7 @@ onUnmounted(async () => {
|
|
|
100
106
|
|
|
101
107
|
<template>
|
|
102
108
|
<div class="bcc-chat-message-list-wrapper">
|
|
103
|
-
<div v-if="chatGroup &&
|
|
109
|
+
<div v-if="chatGroup && (chat.connected.value || chat.onlineStatus.value === 'offline')" class="bcc-chat-message-list">
|
|
104
110
|
<CometChatMessages
|
|
105
111
|
:hideMessageHeader="true"
|
|
106
112
|
:disableSoundForMessages="true"
|