1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<!-- eslint-disable vue/multi-word-component-names -->
<script>
import { GlButton, GlLoadingIcon, GlSprintf, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { updateText } from '~/lib/utils/text_markdown';
import EditorModeSwitcher from './editor_mode_switcher.vue';
export default {
components: {
GlButton,
GlLoadingIcon,
GlSprintf,
GlIcon,
EditorModeSwitcher,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
markdownDocsPath: {
type: String,
required: true,
},
canAttachFile: {
type: Boolean,
required: false,
default: true,
},
showCommentToolBar: {
type: Boolean,
required: false,
default: true,
},
showContentEditorSwitcher: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
showEditorModeSwitcher() {
return this.showContentEditorSwitcher;
},
},
methods: {
insertIntoTextarea(...lines) {
const text = lines.join('\n');
const textArea = this.$el.closest('.md-area')?.querySelector('textarea');
if (textArea && !textArea.value) {
updateText({
textArea,
tag: text,
cursorOffset: 0,
wrap: false,
});
}
},
},
};
</script>
<template>
<div
v-if="showCommentToolBar"
class="comment-toolbar gl-display-flex gl-flex-direction-row gl-px-2 gl-rounded-bottom-left-base gl-rounded-bottom-right-base"
:class="
showContentEditorSwitcher
? 'gl-justify-content-space-between gl-align-items-center gl-border-t gl-border-gray-100'
: 'gl-justify-content-end gl-my-2'
"
>
<editor-mode-switcher
v-if="showEditorModeSwitcher"
size="small"
value="markdown"
@switch="$emit('enableContentEditor')"
/>
<div class="gl-display-flex">
<div v-if="canAttachFile" class="uploading-container gl-font-sm gl-line-height-32 gl-mr-3">
<span class="uploading-progress-container hide">
<gl-icon name="paperclip" />
<span class="attaching-file-message"></span>
<!-- eslint-disable-next-line @gitlab/vue-require-i18n-strings -->
<span class="uploading-progress">0%</span>
<gl-loading-icon size="sm" inline />
</span>
<span class="uploading-error-container hide">
<span class="uploading-error-icon">
<gl-icon name="paperclip" />
</span>
<span class="uploading-error-message"></span>
<gl-sprintf
:message="
__(
'%{retryButtonStart}Try again%{retryButtonEnd} or %{newFileButtonStart}attach a new file%{newFileButtonEnd}.',
)
"
>
<template #retryButton="{ content }">
<gl-button
variant="link"
category="primary"
class="retry-uploading-link gl-vertical-align-baseline gl-font-sm!"
>
{{ content }}
</gl-button>
</template>
<template #newFileButton="{ content }">
<gl-button
variant="link"
category="primary"
class="markdown-selector attach-new-file gl-vertical-align-baseline gl-font-sm!"
>
{{ content }}
</gl-button>
</template>
</gl-sprintf>
</span>
<gl-button
variant="link"
category="primary"
class="button-cancel-uploading-files gl-vertical-align-baseline hide gl-font-sm!"
>
{{ __('Cancel') }}
</gl-button>
</div>
<gl-button
v-if="markdownDocsPath"
v-gl-tooltip
icon="markdown-mark"
:href="markdownDocsPath"
target="_blank"
category="tertiary"
size="small"
:title="__('Markdown is supported')"
:aria-label="__('Markdown is supported')"
class="gl-px-3!"
/>
</div>
</div>
</template>
|