@bcc-code/vue-bcc-chat-ui 2.0.1 → 2.1.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/dist/chat/index.d.ts +182 -0
- package/dist/components/BccChatMessageBubble.vue.d.ts +15 -0
- package/dist/offline/connectivity.d.ts +5 -0
- package/dist/offline/index.d.ts +5 -0
- package/dist/offline/types.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/vue-bcc-chat-ui.js +30951 -26527
- package/package.json +3 -2
- package/src/components/BccChatMessageBubble.vue +48 -0
- package/src/components/BccChatMessageList.vue +36 -19
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": "2.0
|
|
5
|
+
"version": "2.1.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"@cometchat/chat-uikit-vue": "^4.2.1",
|
|
37
37
|
"@cometchat/uikit-resources": "^4.2.2",
|
|
38
38
|
"@cometchat/uikit-shared": "^4.2.2",
|
|
39
|
-
"jwt-decode": "^4.0.0"
|
|
39
|
+
"jwt-decode": "^4.0.0",
|
|
40
|
+
"vue-markdown-render": "^2.1.1"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"dev": "vite",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import VueMarkdown from 'vue-markdown-render'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
text: string
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<vue-markdown :source="text" :options="{
|
|
11
|
+
linkify: true,
|
|
12
|
+
typographer: true,
|
|
13
|
+
}" class="bcc-chat-msg-bubble" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss">
|
|
17
|
+
.bcc-chat-msg-bubble {
|
|
18
|
+
padding: 8px 12px;
|
|
19
|
+
width: auto;
|
|
20
|
+
max-width: 500px;
|
|
21
|
+
font: 400 14px Archivo, sans-serif, Inter;
|
|
22
|
+
|
|
23
|
+
p {
|
|
24
|
+
color: var(--cc__text-color);
|
|
25
|
+
|
|
26
|
+
word-break: break-word;
|
|
27
|
+
text-align: left;
|
|
28
|
+
white-space: pre-line;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
p:first-child {
|
|
32
|
+
margin-top: 0;
|
|
33
|
+
}
|
|
34
|
+
p:last-child {
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
color: var(--cc__link-color);
|
|
40
|
+
text-decoration: underline;
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ul {
|
|
45
|
+
padding-left: 16px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
nextTick,
|
|
4
|
-
onBeforeMount,
|
|
5
3
|
onMounted,
|
|
6
4
|
onUnmounted,
|
|
7
5
|
ref,
|
|
8
|
-
|
|
6
|
+
watch,
|
|
9
7
|
} from "vue";
|
|
10
8
|
import chat from "../chat";
|
|
11
9
|
import { connect, disconnect } from "../chat/connection";
|
|
@@ -17,6 +15,7 @@ import {
|
|
|
17
15
|
messageComposerConfiguration,
|
|
18
16
|
messageListConfiguration,
|
|
19
17
|
} from "../chat/uiKit";
|
|
18
|
+
import { OnlineStatus } from "../offline/types";
|
|
20
19
|
|
|
21
20
|
const props = defineProps({
|
|
22
21
|
chatUid: { type: String, required: true },
|
|
@@ -26,6 +25,23 @@ const componentId = ref(
|
|
|
26
25
|
`component-${Math.random().toString(36).substring(2, 11)}`
|
|
27
26
|
);
|
|
28
27
|
const chatGroup = ref<Group>();
|
|
28
|
+
const chatReady = ref(false);
|
|
29
|
+
|
|
30
|
+
watch([loggedIn, ()=>props.chatUid, chat.initialized], async ([_loggedIn, _chatUid, _initialized]) => {
|
|
31
|
+
if (_loggedIn && _chatUid && _initialized) {
|
|
32
|
+
chatGroup.value = (await chat.getGroup(props.chatUid)) ?? undefined;
|
|
33
|
+
await chat.clearGroupChatCount(props.chatUid);
|
|
34
|
+
} else if (chatGroup.value) {
|
|
35
|
+
chatGroup.value = undefined;
|
|
36
|
+
}
|
|
37
|
+
}, { immediate: true });
|
|
38
|
+
|
|
39
|
+
watch(chat.onlineStatus, async (status: OnlineStatus) => {
|
|
40
|
+
if (status === "online") {
|
|
41
|
+
await connect(componentId.value);
|
|
42
|
+
}
|
|
43
|
+
if (!chatReady.value) chatReady.value = true;
|
|
44
|
+
}, { immediate: true });
|
|
29
45
|
|
|
30
46
|
onMounted(() => {
|
|
31
47
|
watchAndApplyStyle(".bcc-chat-message-list-wrapper", [
|
|
@@ -39,11 +55,21 @@ onMounted(() => {
|
|
|
39
55
|
style: { color: "var(--cc__text-color)" },
|
|
40
56
|
shadowDomSelector: "cometchat-text-bubble",
|
|
41
57
|
},
|
|
58
|
+
{
|
|
59
|
+
selector: ".cc__linkpreview",
|
|
60
|
+
style: { height: "auto" },
|
|
61
|
+
shadowDomSelector: "link-preview",
|
|
62
|
+
},
|
|
42
63
|
{
|
|
43
64
|
selector: ".cc__linkpreview-title",
|
|
44
65
|
style: { color: "var(--cc__text-color)" },
|
|
45
66
|
shadowDomSelector: "link-preview",
|
|
46
67
|
},
|
|
68
|
+
{
|
|
69
|
+
selector: ".cc__linkpreview-favicon",
|
|
70
|
+
style: { 'flex-shrink': '0' },
|
|
71
|
+
shadowDomSelector: "link-preview",
|
|
72
|
+
},
|
|
47
73
|
{
|
|
48
74
|
selector: ".cc__messageinput",
|
|
49
75
|
style: {
|
|
@@ -66,27 +92,15 @@ onMounted(() => {
|
|
|
66
92
|
]);
|
|
67
93
|
});
|
|
68
94
|
|
|
69
|
-
onBeforeMount(async () => {
|
|
70
|
-
await connect(componentId.value);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
95
|
onUnmounted(async () => {
|
|
74
96
|
await disconnect(componentId.value);
|
|
75
97
|
});
|
|
76
98
|
|
|
77
|
-
watchEffect(async () => {
|
|
78
|
-
if (loggedIn.value && props.chatUid && chat.initialized.value) {
|
|
79
|
-
chatGroup.value = (await chat.getGroup(props.chatUid)) ?? undefined;
|
|
80
|
-
await chat.clearGroupChatCount(props.chatUid);
|
|
81
|
-
} else {
|
|
82
|
-
chatGroup.value = undefined;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
99
|
</script>
|
|
86
100
|
|
|
87
101
|
<template>
|
|
88
102
|
<div class="bcc-chat-message-list-wrapper">
|
|
89
|
-
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
103
|
+
<div v-if="chatGroup && chatReady" class="bcc-chat-message-list">
|
|
90
104
|
<CometChatMessages
|
|
91
105
|
:hideMessageHeader="true"
|
|
92
106
|
:disableSoundForMessages="true"
|
|
@@ -96,6 +110,9 @@ watchEffect(async () => {
|
|
|
96
110
|
:hideDetails="true"
|
|
97
111
|
:group="chatGroup"
|
|
98
112
|
/>
|
|
113
|
+
<div v-if="chat.onlineStatus.value === 'offline' || !chat.connected.value" class="bcc-chat-message-composer-offline">
|
|
114
|
+
<span>Waiting for connection...</span>
|
|
115
|
+
</div>
|
|
99
116
|
</div>
|
|
100
117
|
<div class="bcc-chat-message-list-offline">
|
|
101
118
|
<span>Waiting for connection...</span>
|
|
@@ -147,6 +164,7 @@ accent900: text in avatar
|
|
|
147
164
|
--cc__accent800: rgba(62, 142, 117, 0.82);
|
|
148
165
|
--cc__accent900: #f3faf7;
|
|
149
166
|
--cc__text-color: #000;
|
|
167
|
+
--cc__link-color: #57639e;
|
|
150
168
|
|
|
151
169
|
@media (prefers-color-scheme: dark) {
|
|
152
170
|
--cc__primary: #57639e;
|
|
@@ -164,6 +182,7 @@ accent900: text in avatar
|
|
|
164
182
|
--cc__accent800: rgba(98, 116, 174, 0.92);
|
|
165
183
|
--cc__accent900: #f3faf7;
|
|
166
184
|
--cc__text-color: #fff;
|
|
185
|
+
--cc__link-color: #cfeac8;
|
|
167
186
|
}
|
|
168
187
|
|
|
169
188
|
/* 1. Wrapper for Messages component */
|
|
@@ -194,8 +213,6 @@ accent900: text in avatar
|
|
|
194
213
|
top: -96px;
|
|
195
214
|
height: 96px;
|
|
196
215
|
width: 100%;
|
|
197
|
-
box-sizing: border-box;
|
|
198
|
-
padding: 16px 14px;
|
|
199
216
|
color: rgb(176, 176, 176);
|
|
200
217
|
font: 700 1rem sans-serif;
|
|
201
218
|
|
|
@@ -207,7 +224,7 @@ accent900: text in avatar
|
|
|
207
224
|
justify-content: center;
|
|
208
225
|
align-items: center;
|
|
209
226
|
background: rgba(255, 255, 255, 0.75);
|
|
210
|
-
border-radius:
|
|
227
|
+
border-radius: 8px 8px 0 0;
|
|
211
228
|
}
|
|
212
229
|
}
|
|
213
230
|
}
|