blob: 0441f8ef8d26d3c40ceece9812fe588d8f60e112 (
plain)
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
|
import { VueNodeViewRenderer } from '@tiptap/vue-2';
import { SCOPED_LABEL_DELIMITER } from '~/sidebar/components/labels/labels_select_widget/constants';
import LabelWrapper from '../components/wrappers/reference_label.vue';
import Reference from './reference';
export default Reference.extend({
name: 'reference_label',
addAttributes() {
return {
...this.parent(),
text: {
default: null,
parseHTML: (element) => {
const text = element.querySelector('.gl-label-text').textContent;
const scopedText = element.querySelector('.gl-label-text-scoped')?.textContent;
if (!scopedText) return text;
return `${text}${SCOPED_LABEL_DELIMITER}${scopedText}`;
},
},
color: {
default: null,
parseHTML: (element) => element.querySelector('.gl-label-text').style.backgroundColor,
},
};
},
parseHTML() {
return [{ tag: 'span.gl-label' }];
},
addNodeView() {
return new VueNodeViewRenderer(LabelWrapper);
},
});
|