@quidgest/chatbot 0.4.0 → 0.4.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quidgest/chatbot",
3
3
  "private": false,
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "main": "dist/index.cjs",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "axios": "^1.7.0",
36
- "uuid": "^11.1.0",
37
- "vue-markdown-render": "^2.2.1"
36
+ "markdown-it": "^14.1.0",
37
+ "uuid": "^11.1.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/markdown-it": "^14.1.2",
@@ -19,7 +19,7 @@
19
19
  <!-- When loading is true, show bouncing dots animation -->
20
20
  <pulse-dots v-if="loading" />
21
21
  <template v-else>
22
- <vue-markdown-render
22
+ <markdown-renderer
23
23
  v-if="props.sender === 'bot'"
24
24
  class="q-chatbot__text"
25
25
  :source="props.message || ''" />
@@ -93,7 +93,7 @@
93
93
  import PulseDots from '@/components/PulseDots.vue'
94
94
  import type { ChatBotMessageSender } from '@/types/message.type'
95
95
  import { ResourceStrings } from '@/types/texts.type'
96
- import VueMarkdownRender from 'vue-markdown-render'
96
+ import MarkdownRenderer from '@/components/MarkdownRenderer.vue'
97
97
  import Axios from 'axios'
98
98
 
99
99
  export interface CBMessageProps {
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div
3
+ class="markdown-renderer"
4
+ ref="markdownContainer"
5
+ v-html="renderedContent">
6
+ </div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { ref, computed } from 'vue'
11
+ import type { Options, PluginSimple } from "markdown-it";
12
+ import MarkdownIt from 'markdown-it'
13
+
14
+ interface MarkdownRenderProps {
15
+ source: string;
16
+ options?: Options;
17
+ plugins?: PluginSimple[];
18
+ }
19
+
20
+ const props = defineProps<MarkdownRenderProps>();
21
+
22
+ const md = ref(
23
+ new MarkdownIt({
24
+ html: true,
25
+ ...(props.options ?? {}),
26
+ })
27
+ )
28
+
29
+ if (props.plugins)
30
+ props.plugins.forEach(plugin => md.value.use(plugin));
31
+
32
+ const renderedContent = computed(() => md.value.render(props.source))
33
+
34
+ const markdownContainer = ref<HTMLElement | null>(null)
35
+ </script>