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
|
<script>
import { GlLink, GlSafeHtmlDirective } from '@gitlab/ui';
import { setAttributes } from '~/lib/utils/dom_utils';
import { BIDI_CHARS, BIDI_CHARS_CLASS_LIST, BIDI_CHAR_TOOLTIP } from '../constants';
export default {
components: {
GlLink,
},
directives: {
SafeHtml: GlSafeHtmlDirective,
},
props: {
number: {
type: Number,
required: true,
},
content: {
type: String,
required: true,
},
language: {
type: String,
required: true,
},
},
computed: {
formattedContent() {
let { content } = this;
BIDI_CHARS.forEach((bidiChar) => {
if (content.includes(bidiChar)) {
content = content.replace(bidiChar, this.wrapBidiChar(bidiChar));
}
});
return content;
},
firstLineClass() {
return { 'gl-mt-3!': this.number === 1 };
},
},
methods: {
wrapBidiChar(bidiChar) {
const span = document.createElement('span');
setAttributes(span, {
class: BIDI_CHARS_CLASS_LIST,
title: BIDI_CHAR_TOOLTIP,
'data-testid': 'bidi-wrapper',
});
span.innerText = bidiChar;
return span.outerHTML;
},
},
};
</script>
<template>
<div class="gl-display-flex">
<div class="gl-p-0! gl-absolute gl-z-index-3 gl-border-r diff-line-num line-numbers">
<gl-link
:id="`L${number}`"
class="gl-user-select-none gl-ml-5 gl-pr-3 gl-shadow-none! file-line-num diff-line-num"
:class="firstLineClass"
:to="`#L${number}`"
:data-line-number="number"
>
{{ number }}
</gl-link>
</div>
<pre
class="gl-p-0! gl-w-full gl-overflow-visible! gl-ml-11! gl-border-none! code highlight"
:class="firstLineClass"
><code><span :id="`LC${number}`" v-safe-html="formattedContent" :lang="language" class="line" data-testid="content"></span></code></pre>
</div>
</template>
|