@bcc-code/vue-bcc-chat-ui 2.2.3 → 3.0.0-alpha.1

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": "2.2.3",
5
+ "version": "3.0.0-alpha.1",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -23,20 +23,20 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/markdown-it": "^13.0.7",
26
- "@types/node": "^20.11.25",
26
+ "@types/node": "^20.11.30",
27
27
  "@vitejs/plugin-vue": "^4.6.2",
28
28
  "path": "^0.12.7",
29
- "sass": "^1.71.1",
30
- "typescript": "^5.4.2",
31
- "vite": "^5.1.5",
29
+ "sass": "^1.72.0",
30
+ "typescript": "^5.4.3",
31
+ "vite": "^5.2.6",
32
32
  "vite-plugin-dts": "^3.7.3",
33
33
  "vue": "^3.4.21"
34
34
  },
35
35
  "dependencies": {
36
- "@cometchat/chat-sdk-javascript": "^4.0.3",
37
- "@cometchat/chat-uikit-vue": "^4.2.1",
38
- "@cometchat/uikit-resources": "^4.2.2",
39
- "@cometchat/uikit-shared": "^4.2.2",
36
+ "@cometchat/chat-sdk-javascript": "^4.0.4",
37
+ "@cometchat/chat-uikit-vue": "^4.3.1",
38
+ "@cometchat/uikit-resources": "^4.3.1",
39
+ "@cometchat/uikit-shared": "^4.3.2",
40
40
  "jwt-decode": "^4.0.0",
41
41
  "markdown-it": "^14.1.0"
42
42
  },
@@ -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 = /(?<!\]\()((?:https?|ftp):\/\/[^\s\]\)]*|www\.[^\s\]\)]+)(?=[\s\]\)](?!\()|$)/g;
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 = (match: string) => {
15
- let url = match;
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 `[${hostname}](${url})`;
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 (status: OnlineStatus) => {
40
- if (status === "online") {
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
- if (!chatReady.value) chatReady.value = true;
44
- }, { immediate: true });
46
+ }
47
+
48
+ onBeforeMount(() => {
49
+ tryConnect(true);
50
+ });
45
51
 
46
52
  onMounted(() => {
47
53
  watchAndApplyStyle(".bcc-chat-message-list-wrapper", [
@@ -71,23 +77,21 @@ onMounted(() => {
71
77
  shadowDomSelector: "link-preview",
72
78
  },
73
79
  {
74
- selector: ".cc__messageinput",
80
+ selector: ".messageinput",
75
81
  style: {
76
82
  "border-radius": "8px 8px 0 0",
77
83
  "box-shadow":
78
84
  "0px -1px 2px 0px rgba(17, 24, 39, 0.05), 1px -1px 3px 0px rgba(17, 24, 39, 0.1)",
79
85
  },
80
- shadowDomSelector: "cometchat-message-input",
81
86
  },
82
87
  {
83
- selector: ".cc__messageinput-input",
88
+ selector: ".messageinput-input",
84
89
  style: {
85
90
  "font-size": "16px",
86
91
  padding: "8px",
87
92
  "max-height": "none",
88
93
  height: "64px",
89
94
  },
90
- shadowDomSelector: "cometchat-message-input",
91
95
  },
92
96
  ]);
93
97
  });
@@ -100,7 +104,7 @@ onUnmounted(async () => {
100
104
 
101
105
  <template>
102
106
  <div class="bcc-chat-message-list-wrapper">
103
- <div v-if="chatGroup && chatReady" class="bcc-chat-message-list">
107
+ <div v-if="chatGroup && (chat.connected.value || chat.onlineStatus.value === 'offline')" class="bcc-chat-message-list">
104
108
  <CometChatMessages
105
109
  :hideMessageHeader="true"
106
110
  :disableSoundForMessages="true"