@bcc-code/vue-bcc-chat-ui 2.1.1 → 2.1.2
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/vue-bcc-chat-ui.js +21271 -24067
- package/package.json +3 -2
- package/src/components/BccChatMessageBubble.vue +10 -7
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.1.
|
|
5
|
+
"version": "2.1.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"vue": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"@types/markdown-it": "^13.0.7",
|
|
25
26
|
"@types/node": "^20.11.25",
|
|
26
27
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
27
28
|
"path": "^0.12.7",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"@cometchat/uikit-resources": "^4.2.2",
|
|
38
39
|
"@cometchat/uikit-shared": "^4.2.2",
|
|
39
40
|
"jwt-decode": "^4.0.0",
|
|
40
|
-
"
|
|
41
|
+
"markdown-it": "npm:@esm-bundle/markdown-it@^13.0.1"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"dev": "vite",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import markdownit from 'markdown-it/esm';
|
|
3
3
|
|
|
4
4
|
defineProps<{
|
|
5
5
|
text: string
|
|
6
6
|
}>()
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
function linkify(str: string) {
|
|
8
|
+
function toMarkdownHtml(str: string) {
|
|
10
9
|
// Regex to match URLs that may or may not start with "www." and are not already part of a Markdown link
|
|
11
10
|
const urlRegex = /(?<!\]\()((?:https?|ftp):\/\/[^\s\]\)]*|www\.[^\s\]\)]+)(?=[\s\]\)](?!\()|$)/g;
|
|
12
11
|
|
|
@@ -21,14 +20,18 @@ function linkify(str: string) {
|
|
|
21
20
|
return `[${hostname}](${url})`;
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
// Replacing URLs in the string with Markdown links
|
|
24
|
+
const outStr = str.replace(urlRegex, formatUrlToMarkdown);
|
|
25
|
+
const md = new markdownit({
|
|
26
|
+
typographer: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return md.render(outStr);
|
|
25
30
|
}
|
|
26
31
|
</script>
|
|
27
32
|
|
|
28
33
|
<template>
|
|
29
|
-
<
|
|
30
|
-
typographer: true,
|
|
31
|
-
}" class="bcc-chat-msg-bubble" />
|
|
34
|
+
<div v-html="toMarkdownHtml(text)" class="bcc-chat-msg-bubble" />
|
|
32
35
|
</template>
|
|
33
36
|
|
|
34
37
|
<style lang="scss">
|