1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-21 12:10:32 +00:00
bramw_baserow/web-frontend/modules/core/components/MarkdownIt.vue
2023-04-28 10:56:33 +00:00

44 lines
855 B
Vue

<template>
<!-- eslint-disable-next-line vue/no-v-html vue/no-v-text-v-html-on-component -->
<component :is="tag" class="markdown" v-html="htmlContent" />
</template>
<script>
export default {
name: 'MarkdownIt',
props: {
content: {
required: true,
type: String,
},
tag: {
required: false,
type: String,
default: 'div',
},
},
data() {
return {
htmlContent: '',
}
},
computed: {
// Makes content watchable
localContent() {
return this.content
},
},
watch: {
localContent(newValue) {
if (this.md) {
this.htmlContent = this.md.render(newValue)
}
},
},
async created() {
const Markdown = (await import('markdown-it')).default
this.md = new Markdown()
this.htmlContent = this.md.render(this.content)
},
}
</script>