Commit 35f1082c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'Remove-v-html-from-markdown.vue' into 'master'

Refactor-v-html-markdown.vue

See merge request gitlab-org/gitlab!70901
parents d079cd00 44090f41
<script> <script>
import katex from 'katex'; import katex from 'katex';
import marked from 'marked'; import marked from 'marked';
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import { sanitize } from '~/lib/dompurify'; import { sanitize } from '~/lib/dompurify';
import { hasContent, markdownConfig } from '~/lib/utils/text_utility'; import { hasContent, markdownConfig } from '~/lib/utils/text_utility';
import Prompt from './prompt.vue'; import Prompt from './prompt.vue';
...@@ -138,6 +139,9 @@ export default { ...@@ -138,6 +139,9 @@ export default {
components: { components: {
prompt: Prompt, prompt: Prompt,
}, },
directives: {
SafeHtml,
},
inject: ['relativeRawPath'], inject: ['relativeRawPath'],
props: { props: {
cell: { cell: {
...@@ -150,16 +154,17 @@ export default { ...@@ -150,16 +154,17 @@ export default {
renderer.attachments = this.cell.attachments; renderer.attachments = this.cell.attachments;
renderer.relativeRawPath = this.relativeRawPath; renderer.relativeRawPath = this.relativeRawPath;
return sanitize(marked(this.cell.source.join('').replace(/\\/g, '\\\\')), markdownConfig); return marked(this.cell.source.join('').replace(/\\/g, '\\\\'));
}, },
}, },
markdownConfig,
}; };
</script> </script>
<template> <template>
<div class="cell text-cell"> <div class="cell text-cell">
<prompt /> <prompt />
<div class="markdown" v-html="markdown /* eslint-disable-line vue/no-v-html */"></div> <div v-safe-html:[$options.markdownConfig]="markdown" class="markdown"></div>
</div> </div>
</template> </template>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment