Commit f3b9eda9 authored by Jacques Erasmus's avatar Jacques Erasmus Committed by Kushal Pandya

Add syntax highlighting to suggestion preview

parent cbad001c
...@@ -28,6 +28,11 @@ export default { ...@@ -28,6 +28,11 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
helpPagePath: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
...mapState({ ...mapState({
...@@ -95,6 +100,7 @@ export default { ...@@ -95,6 +100,7 @@ export default {
:is-editing="true" :is-editing="true"
:line-code="line.line_code" :line-code="line.line_code"
:line="line" :line="line"
:help-page-path="helpPagePath"
save-button-title="Comment" save-button-title="Comment"
class="diff-comment-form" class="diff-comment-form"
@cancelForm="handleCancelCommentForm" @cancelForm="handleCancelCommentForm"
......
...@@ -54,6 +54,7 @@ export default { ...@@ -54,6 +54,7 @@ export default {
:diff-file-hash="diffFileHash" :diff-file-hash="diffFileHash"
:line="line" :line="line"
:note-target-line="line" :note-target-line="line"
:help-page-path="helpPagePath"
/> />
</div> </div>
</td> </td>
......
...@@ -101,6 +101,7 @@ export default { ...@@ -101,6 +101,7 @@ export default {
:diff-file-hash="diffFileHash" :diff-file-hash="diffFileHash"
:line="line.left" :line="line.left"
:note-target-line="line.left" :note-target-line="line.left"
:help-page-path="helpPagePath"
line-position="left" line-position="left"
/> />
</td> </td>
......
...@@ -182,9 +182,9 @@ export default { ...@@ -182,9 +182,9 @@ export default {
this.hasSuggestion = data.references.suggestions && data.references.suggestions.length; this.hasSuggestion = data.references.suggestions && data.references.suggestions.length;
} }
this.$nextTick(() => { this.$nextTick()
$(this.$refs['markdown-preview']).renderGFM(); .then(() => $(this.$refs['markdown-preview']).renderGFM())
}); .catch(() => new Flash(__('Error rendering markdown preview')));
}, },
versionedPreviewPath() { versionedPreviewPath() {
......
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
<div class="md-suggestion-header border-bottom-0 mt-2"> <div class="md-suggestion-header border-bottom-0 mt-2">
<div class="qa-suggestion-diff-header font-weight-bold"> <div class="qa-suggestion-diff-header font-weight-bold">
{{ __('Suggested change') }} {{ __('Suggested change') }}
<a v-if="helpPagePath" :href="helpPagePath" :aria-label="__('Help')"> <a v-if="helpPagePath" :href="helpPagePath" :aria-label="__('Help')" class="js-help-btn">
<icon name="question-o" css-classes="link-highlight" /> <icon name="question-o" css-classes="link-highlight" />
</a> </a>
</div> </div>
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
max-height: calc(100vh - 100px); max-height: calc(100vh - 100px);
} }
table { table:not(.js-syntax-highlight) {
@include markdown-table; @include markdown-table;
} }
} }
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
margin: 0 0 16px; margin: 0 0 16px;
} }
table { table:not(.js-syntax-highlight) {
@extend .table; @extend .table;
@extend .table-bordered; @extend .table-bordered;
margin: 16px 0; margin: 16px 0;
......
---
title: Fix syntax highlighting for suggested changes preview
merge_request: 24358
author:
type: fixed
...@@ -2956,6 +2956,9 @@ msgstr "" ...@@ -2956,6 +2956,9 @@ msgstr ""
msgid "Error occurred when toggling the notification subscription" msgid "Error occurred when toggling the notification subscription"
msgstr "" msgstr ""
msgid "Error rendering markdown preview"
msgstr ""
msgid "Error saving label update." msgid "Error saving label update."
msgstr "" msgstr ""
......
...@@ -31,6 +31,12 @@ describe('Suggestion Diff component', () => { ...@@ -31,6 +31,12 @@ describe('Suggestion Diff component', () => {
expect(header.innerHTML.includes('Suggested change')).toBe(true); expect(header.innerHTML.includes('Suggested change')).toBe(true);
}); });
it('renders a help button', () => {
const helpBtn = vm.$el.querySelector('.js-help-btn');
expect(helpBtn).not.toBeNull();
});
it('renders an apply button', () => { it('renders an apply button', () => {
const applyBtn = vm.$el.querySelector('.qa-apply-btn'); const applyBtn = vm.$el.querySelector('.qa-apply-btn');
......
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