meteorlxy / vue-showdown

:page_with_curl: Use showdown as a vue component
https://vue-showdown.js.org
MIT License
129 stars 23 forks source link

Add props to add customs components to h render of vueTemplate #49

Closed NtchPlayer closed 1 year ago

NtchPlayer commented 1 year ago

Clear and concise description of the problem

Hi ! I just discover your plugin for Showdown with vue 3 and it's absolutely amazing !!

I propose here a little improvment to add possibility to use custom component with vueTemplate options. Add an options vueTemplateComponents where we can pass custom to h render function like that.

Suggested solution

I see that in this issue you had a render function h.

So I propose something like this:

// user component
<template>
    <VueShowdown :markdown="myMarkedown" :vue-template="true" :vue-template-components="{ myCustomComponent }" />
</template>

<script setup>
import myCustomComponent from '@/components/myCustomComponent'
</script>

In your plugin code

// Plugin code
render (h) {
  return h({
    template: `<${this.tag}>${this.outputHtml}</${this.tag}>`,
    components: vueTemplateComponents // add custom component pass throw vue-template-components props
  })
},

Alternative

No response

Additional context

No response