@bcc-code/vue-bcc-chat-ui 2.1.1 → 2.2.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
@@ -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.1",
5
+ "version": "2.2.0",
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
- "vue-markdown-render": "^2.1.1"
41
+ "markdown-it": "^14.1.0"
41
42
  },
42
43
  "scripts": {
43
44
  "dev": "vite",
@@ -1,12 +1,11 @@
1
1
  <script setup lang="ts">
2
- import VueMarkdown from 'vue-markdown-render'
2
+ import MarkdownIt from 'markdown-it'
3
3
 
4
4
  defineProps<{
5
5
  text: string
6
6
  }>()
7
7
 
8
- // Replacing URLs in the string with Markdown links
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,19 @@ function linkify(str: string) {
21
20
  return `[${hostname}](${url})`;
22
21
  };
23
22
 
24
- return str.replace(urlRegex, formatUrlToMarkdown);
23
+ // Replacing URLs in the string with Markdown links
24
+ const outStr = str.replace(urlRegex, formatUrlToMarkdown);
25
+ const md = new MarkdownIt({
26
+ breaks: true,
27
+ typographer: true,
28
+ });
29
+
30
+ return md.render(outStr);
25
31
  }
26
32
  </script>
27
33
 
28
34
  <template>
29
- <vue-markdown :source="linkify(text)" :options="{
30
- typographer: true,
31
- }" class="bcc-chat-msg-bubble" />
35
+ <div v-html="toMarkdownHtml(text)" class="bcc-chat-msg-bubble" />
32
36
  </template>
33
37
 
34
38
  <style lang="scss">
@@ -45,6 +49,7 @@ function linkify(str: string) {
45
49
  word-break: break-word;
46
50
  text-align: left;
47
51
  white-space: pre-line;
52
+ margin: 8px 0;
48
53
  }
49
54
 
50
55
  p:first-child {
@@ -54,6 +59,23 @@ function linkify(str: string) {
54
59
  margin-bottom: 0;
55
60
  }
56
61
 
62
+ h1 {
63
+ font-size: 1.6em;
64
+ font-weight: 800;
65
+ }
66
+ h2 {
67
+ font-size: 1.4em;
68
+ font-weight: 700;
69
+ }
70
+ h3 {
71
+ font-size: 1.2em;
72
+ font-weight: 600;
73
+ }
74
+ h4 {
75
+ font-size: 1em;
76
+ font-weight: 500;
77
+ }
78
+
57
79
  a {
58
80
  color: var(--cc__link-color);
59
81
  text-decoration: underline;
@@ -62,6 +84,13 @@ function linkify(str: string) {
62
84
 
63
85
  ul {
64
86
  padding-left: 16px;
87
+ list-style: disc;
88
+ margin: 8px 0;
89
+ }
90
+ ol {
91
+ padding-left: 16px;
92
+ list-style: decimal;
93
+ margin: 8px 0;
65
94
  }
66
95
  }
67
96
  </style>