@bcc-code/vue-bcc-chat-ui 2.1.0 → 2.1.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/dist/style.css +1 -1
- package/dist/vue-bcc-chat-ui.js +55230 -70800
- package/package.json +1 -1
- package/src/components/BccChatMessageBubble.vue +22 -3
package/package.json
CHANGED
|
@@ -4,11 +4,29 @@ import VueMarkdown from 'vue-markdown-render'
|
|
|
4
4
|
defineProps<{
|
|
5
5
|
text: string
|
|
6
6
|
}>()
|
|
7
|
+
|
|
8
|
+
// Replacing URLs in the string with Markdown links
|
|
9
|
+
function linkify(str: string) {
|
|
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;
|
|
12
|
+
|
|
13
|
+
// Function to format a URL into a Markdown link
|
|
14
|
+
const formatUrlToMarkdown = (match: string) => {
|
|
15
|
+
let url = match;
|
|
16
|
+
// Prepend "http://" to URLs starting with "www."
|
|
17
|
+
if (url.startsWith('www.')) {
|
|
18
|
+
url = 'http://' + url;
|
|
19
|
+
}
|
|
20
|
+
const hostname = new URL(url).hostname;
|
|
21
|
+
return `[${hostname}](${url})`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return str.replace(urlRegex, formatUrlToMarkdown);
|
|
25
|
+
}
|
|
7
26
|
</script>
|
|
8
27
|
|
|
9
28
|
<template>
|
|
10
|
-
<vue-markdown :source="text" :options="{
|
|
11
|
-
linkify: true,
|
|
29
|
+
<vue-markdown :source="linkify(text)" :options="{
|
|
12
30
|
typographer: true,
|
|
13
31
|
}" class="bcc-chat-msg-bubble" />
|
|
14
32
|
</template>
|
|
@@ -18,11 +36,12 @@ defineProps<{
|
|
|
18
36
|
padding: 8px 12px;
|
|
19
37
|
width: auto;
|
|
20
38
|
max-width: 500px;
|
|
39
|
+
line-height: 1.2;
|
|
21
40
|
font: 400 14px Archivo, sans-serif, Inter;
|
|
22
41
|
|
|
23
42
|
p {
|
|
24
43
|
color: var(--cc__text-color);
|
|
25
|
-
|
|
44
|
+
line-height: 1.2;
|
|
26
45
|
word-break: break-word;
|
|
27
46
|
text-align: left;
|
|
28
47
|
white-space: pre-line;
|