vue3-markdown-it icon indicating copy to clipboard operation
vue3-markdown-it copied to clipboard

When I write MarkDown in <vue3-markdown-it></vue3-markdown-it> it is not working.

Open otabekoff opened this issue 4 years ago • 3 comments

Describe the bug When I write MarkDown in it is not working. But, when I use :source="source". It is displaying some of the markdown, but some of them are not working.

To Reproduce Steps to reproduce the behavior:

  1. Create a Quasar framework(Vue) project.
  2. Include framework settings in boot file.
  3. Create a test page with some example.
  4. See error

Expected behavior Using Markdown between tags.

Screenshots No, screenshot!

Additional context No additional context.

otabekoff avatar Feb 22 '21 16:02 otabekoff

Hi @OtabekSadiridinov!

Can you elaborate more on which markdown functionality isn't working?

JanGuillermo avatar Feb 24 '21 06:02 JanGuillermo

The main issue being reported here is that you can't pass data along with slots; it has to be passed in via source which can be somewhat unwieldy in some cases

Kruptein avatar Apr 27 '21 15:04 Kruptein

Yes, it does not work, I solve the problem by making one component and wrap the data into that markdown component:

CustomMarkdown.vue

<template>
  <div>
    <span ref="markdownCode">
      <slot></slot>
    </span>
    <Markdown :source="markdownCode" />
  </div>
</template>

<script lang="js">

import Markdown from 'vue3-markdown-it';

export default {
    name: "CustomMarkdown",
    components: {
        Markdown,
    },
    data () {
        return {
            markdownCode: ""
        }
    },
    mounted() {
        let elem = this.$refs.markdownCode
        this.markdownCode = elem.textContent;
        elem.remove();
    }
}
</script>

And I can use that component anywhere like.


<template>
      <vue-markdown># this is the default slot</vue-markdown>
</template>

<script lang="js">
import CustomMarkdown from '@/components/CustomMarkdown';

export default {
      name: "Post",
      components: {
          'vue-markdown': CustomMarkdown,
      },
}

That's all.

But it will be good if that component support that functionality out of the box.

lablnet avatar Mar 12 '22 07:03 lablnet