Commit 99b6bec5 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch 'djadminv-html-notes-body' into 'master'

Switch to v-safe-html for rendering notes

See merge request gitlab-org/gitlab!72877
parents f969e6bf 3f63da94
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton, GlSafeHtmlDirective } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import NoteableNote from '~/notes/components/noteable_note.vue'; import NoteableNote from '~/notes/components/noteable_note.vue';
import PublishButton from './publish_button.vue'; import PublishButton from './publish_button.vue';
...@@ -10,6 +10,9 @@ export default { ...@@ -10,6 +10,9 @@ export default {
PublishButton, PublishButton,
GlButton, GlButton,
}, },
directives: {
SafeHtml: GlSafeHtmlDirective,
},
props: { props: {
draft: { draft: {
type: Object, type: Object,
...@@ -72,6 +75,9 @@ export default { ...@@ -72,6 +75,9 @@ export default {
} }
}, },
}, },
safeHtmlConfig: {
ADD_TAGS: ['use', 'gl-emoji'],
},
}; };
</script> </script>
<template> <template>
...@@ -104,8 +110,8 @@ export default { ...@@ -104,8 +110,8 @@ export default {
<template v-if="!isEditingDraft"> <template v-if="!isEditingDraft">
<div <div
v-if="draftCommands" v-if="draftCommands"
v-safe-html:[$options.safeHtmlConfig]="draftCommands"
class="referenced-commands draft-note-commands" class="referenced-commands draft-note-commands"
v-html="draftCommands /* eslint-disable-line vue/no-v-html */"
></div> ></div>
<p class="draft-note-actions d-flex"> <p class="draft-note-actions d-flex">
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import { GlSafeHtmlDirective } from '@gitlab/ui';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
...@@ -19,6 +20,9 @@ export default { ...@@ -19,6 +20,9 @@ export default {
noteForm, noteForm,
Suggestions, Suggestions,
}, },
directives: {
SafeHtml: GlSafeHtmlDirective,
},
mixins: [autosave], mixins: [autosave],
props: { props: {
note: { note: {
...@@ -144,6 +148,9 @@ export default { ...@@ -144,6 +148,9 @@ export default {
this.removeSuggestionInfoFromBatch(suggestionId); this.removeSuggestionInfoFromBatch(suggestionId);
}, },
}, },
safeHtmlConfig: {
ADD_TAGS: ['use', 'gl-emoji'],
},
}; };
</script> </script>
...@@ -163,11 +170,7 @@ export default { ...@@ -163,11 +170,7 @@ export default {
@addToBatch="addSuggestionToBatch" @addToBatch="addSuggestionToBatch"
@removeFromBatch="removeSuggestionFromBatch" @removeFromBatch="removeSuggestionFromBatch"
/> />
<div <div v-else v-safe-html:[$options.safeHtmlConfig]="note.note_html" class="note-text md"></div>
v-else
class="note-text md"
v-html="note.note_html /* eslint-disable-line vue/no-v-html */"
></div>
<note-form <note-form
v-if="isEditing" v-if="isEditing"
ref="noteForm" ref="noteForm"
......
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