2018-07-20 18:42:17 -04:00
|
|
|
<template>
|
2019-06-19 20:57:14 -04:00
|
|
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
2018-07-20 18:42:17 -04:00
|
|
|
<div v-html="output" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2021-05-13 15:54:21 -04:00
|
|
|
import awaitMD, {getMD} from 'utilities/markdown';
|
2018-07-20 18:42:17 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
source: String
|
|
|
|
},
|
|
|
|
|
2021-05-13 15:54:21 -04:00
|
|
|
data() {
|
|
|
|
return {
|
2021-11-19 17:12:17 -05:00
|
|
|
output: ''
|
2021-05-13 15:54:21 -04:00
|
|
|
}
|
|
|
|
},
|
2018-07-20 18:42:17 -04:00
|
|
|
|
2021-11-19 17:12:17 -05:00
|
|
|
watch: {
|
|
|
|
source() {
|
|
|
|
this.rebuild();
|
2018-07-20 18:42:17 -04:00
|
|
|
}
|
2021-05-13 15:54:21 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2021-11-19 17:12:17 -05:00
|
|
|
this.md = getMD();
|
2021-05-13 15:54:21 -04:00
|
|
|
if ( ! this.md )
|
2021-11-19 17:12:17 -05:00
|
|
|
awaitMD().then(md => {
|
|
|
|
this.md = md;
|
|
|
|
this.rebuild();
|
|
|
|
});
|
|
|
|
else
|
|
|
|
this.rebuild();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
rebuild() {
|
|
|
|
if ( ! this.md )
|
|
|
|
this.output = '';
|
|
|
|
else
|
|
|
|
this.output = this.md.render(this.source);
|
|
|
|
}
|
2018-07-20 18:42:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|