diff options
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/markdown')
3 files changed, 41 insertions, 10 deletions
diff --git a/app/assets/javascripts/vue_shared/components/markdown/field.vue b/app/assets/javascripts/vue_shared/components/markdown/field.vue index f954b8eb4f4..6df0119c3db 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/field.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/field.vue @@ -4,7 +4,7 @@ import '~/behaviors/markdown/render_gfm'; import { unescape } from 'lodash'; import { __, sprintf } from '~/locale'; import { stripHtml } from '~/lib/utils/text_utility'; -import Flash from '~/flash'; +import { deprecatedCreateFlash as Flash } from '~/flash'; import GLForm from '~/gl_form'; import MarkdownHeader from './header.vue'; import MarkdownToolbar from './toolbar.vue'; @@ -167,11 +167,11 @@ export default { return new GLForm($(this.$refs['gl-form']), { emojis: this.enableAutocomplete, members: this.enableAutocomplete && !this.glFeatures.tributeAutocomplete, - issues: this.enableAutocomplete, + issues: this.enableAutocomplete && !this.glFeatures.tributeAutocomplete, mergeRequests: this.enableAutocomplete, epics: this.enableAutocomplete, milestones: this.enableAutocomplete, - labels: this.enableAutocomplete, + labels: this.enableAutocomplete && !this.glFeatures.tributeAutocomplete, snippets: this.enableAutocomplete, }); }, @@ -250,7 +250,7 @@ export default { </gl-mentions> <slot v-else name="textarea"></slot> <a - class="zen-control zen-control-leave js-zen-leave gl-text-gray-700" + class="zen-control zen-control-leave js-zen-leave gl-text-gray-500" href="#" :aria-label="__('Leave zen mode')" > diff --git a/app/assets/javascripts/vue_shared/components/markdown/header.vue b/app/assets/javascripts/vue_shared/components/markdown/header.vue index 049f5e71849..7e6edcfbd25 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/header.vue @@ -1,6 +1,8 @@ <script> import $ from 'jquery'; -import { GlPopover, GlDeprecatedButton, GlTooltipDirective } from '@gitlab/ui'; +import { GlPopover, GlButton, GlTooltipDirective } from '@gitlab/ui'; +import { getSelectedFragment } from '~/lib/utils/common_utils'; +import { CopyAsGFM } from '../../../behaviors/markdown/copy_as_gfm'; import ToolbarButton from './toolbar_button.vue'; import Icon from '../icon.vue'; @@ -9,7 +11,7 @@ export default { ToolbarButton, Icon, GlPopover, - GlDeprecatedButton, + GlButton, }, directives: { GlTooltip: GlTooltipDirective, @@ -35,6 +37,11 @@ export default { default: false, }, }, + data() { + return { + tag: '> ', + }; + }, computed: { mdTable() { return [ @@ -81,6 +88,24 @@ export default { handleSuggestDismissed() { this.$emit('handleSuggestDismissed'); }, + handleQuote() { + const documentFragment = getSelectedFragment(); + + if (!documentFragment || !documentFragment.textContent) { + this.tag = '> '; + return; + } + this.tag = ''; + + const transformed = CopyAsGFM.transformGFMSelection(documentFragment); + const area = this.$el.parentNode.querySelector('textarea'); + + CopyAsGFM.nodeToGFM(transformed) + .then(gfm => { + CopyAsGFM.insertPastedText(area, documentFragment.textContent, CopyAsGFM.quoted(gfm)); + }) + .catch(() => {}); + }, }, }; </script> @@ -108,9 +133,10 @@ export default { <toolbar-button tag="*" :button-title="__('Add italic text')" icon="italic" /> <toolbar-button :prepend="true" - tag="> " + :tag="tag" :button-title="__('Insert a quote')" icon="quote" + @click="handleQuote" /> </div> <div class="d-inline-block ml-md-2 ml-0"> @@ -141,9 +167,14 @@ export default { ) }} </p> - <gl-deprecated-button variant="primary" size="sm" @click="handleSuggestDismissed"> + <gl-button + variant="info" + category="primary" + size="sm" + @click="handleSuggestDismissed" + > {{ __('Got it') }} - </gl-deprecated-button> + </gl-button> </gl-popover> </template> <toolbar-button tag="`" tag-block="```" :button-title="__('Insert code')" icon="code" /> diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue index 9527c5114f2..1216484b35f 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue @@ -2,7 +2,7 @@ import Vue from 'vue'; import { __ } from '~/locale'; import SuggestionDiff from './suggestion_diff.vue'; -import Flash from '~/flash'; +import { deprecatedCreateFlash as Flash } from '~/flash'; export default { props: { |