1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.WidgetDecoration = void 0;
|
19 |
|
20 |
|
21 |
|
22 | var WidgetDecoration;
|
23 | (function (WidgetDecoration) {
|
24 | |
25 |
|
26 |
|
27 | let Styles;
|
28 | (function (Styles) {
|
29 | Styles.CAPTION_HIGHLIGHT_CLASS = 'theia-caption-highlight';
|
30 | Styles.CAPTION_PREFIX_CLASS = 'theia-caption-prefix';
|
31 | Styles.CAPTION_SUFFIX_CLASS = 'theia-caption-suffix';
|
32 | Styles.ICON_WRAPPER_CLASS = 'theia-icon-wrapper';
|
33 | Styles.DECORATOR_SIZE_CLASS = 'theia-decorator-size';
|
34 | Styles.DECORATOR_SIDEBAR_SIZE_CLASS = 'theia-decorator-sidebar-size';
|
35 | Styles.TOP_RIGHT_CLASS = 'theia-top-right';
|
36 | Styles.BOTTOM_RIGHT_CLASS = 'theia-bottom-right';
|
37 | Styles.BOTTOM_RIGHT_SIDEBAR_CLASS = 'theia-bottom-right-sidebar';
|
38 | Styles.BOTTOM_LEFT_CLASS = 'theia-bottom-left';
|
39 | Styles.TOP_LEFT_CLASS = 'theia-top-left';
|
40 | })(Styles = WidgetDecoration.Styles || (WidgetDecoration.Styles = {}));
|
41 | let TailDecoration;
|
42 | (function (TailDecoration) {
|
43 | function isDotDecoration(decoration) {
|
44 | return decoration.icon === 'circle';
|
45 | }
|
46 | TailDecoration.isDotDecoration = isDotDecoration;
|
47 | })(TailDecoration = WidgetDecoration.TailDecoration || (WidgetDecoration.TailDecoration = {}));
|
48 | |
49 |
|
50 |
|
51 | let IconOverlayPosition;
|
52 | (function (IconOverlayPosition) {
|
53 | |
54 |
|
55 |
|
56 | IconOverlayPosition[IconOverlayPosition["TOP_RIGHT"] = 0] = "TOP_RIGHT";
|
57 | |
58 |
|
59 |
|
60 | IconOverlayPosition[IconOverlayPosition["BOTTOM_RIGHT"] = 1] = "BOTTOM_RIGHT";
|
61 | |
62 |
|
63 |
|
64 | IconOverlayPosition[IconOverlayPosition["BOTTOM_LEFT"] = 2] = "BOTTOM_LEFT";
|
65 | |
66 |
|
67 |
|
68 | IconOverlayPosition[IconOverlayPosition["TOP_LEFT"] = 3] = "TOP_LEFT";
|
69 | })(IconOverlayPosition = WidgetDecoration.IconOverlayPosition || (WidgetDecoration.IconOverlayPosition = {}));
|
70 | (function (IconOverlayPosition) {
|
71 | |
72 |
|
73 |
|
74 | function getStyle(position, inSideBar) {
|
75 | switch (position) {
|
76 | case IconOverlayPosition.TOP_RIGHT:
|
77 | return WidgetDecoration.Styles.TOP_RIGHT_CLASS;
|
78 | case IconOverlayPosition.BOTTOM_RIGHT:
|
79 | return inSideBar ? WidgetDecoration.Styles.BOTTOM_RIGHT_SIDEBAR_CLASS : WidgetDecoration.Styles.BOTTOM_RIGHT_CLASS;
|
80 | case IconOverlayPosition.BOTTOM_LEFT:
|
81 | return WidgetDecoration.Styles.BOTTOM_LEFT_CLASS;
|
82 | case IconOverlayPosition.TOP_LEFT:
|
83 | return WidgetDecoration.Styles.TOP_LEFT_CLASS;
|
84 | }
|
85 | }
|
86 | IconOverlayPosition.getStyle = getStyle;
|
87 | })(IconOverlayPosition = WidgetDecoration.IconOverlayPosition || (WidgetDecoration.IconOverlayPosition = {}));
|
88 | let CaptionHighlight;
|
89 | (function (CaptionHighlight) {
|
90 | let Range;
|
91 | (function (Range) {
|
92 | |
93 |
|
94 |
|
95 | function contains(arg, range) {
|
96 | return arg >= range.offset && arg <= (range.offset + range.length);
|
97 | }
|
98 | Range.contains = contains;
|
99 | })(Range = CaptionHighlight.Range || (CaptionHighlight.Range = {}));
|
100 | |
101 |
|
102 |
|
103 | function split(caption, highlight) {
|
104 | const result = [];
|
105 | const ranges = highlight.ranges.slice();
|
106 | const containerOf = (index) => ranges.findIndex(range => Range.contains(index, range));
|
107 | let data = '';
|
108 | for (let i = 0; i < caption.length; i++) {
|
109 | const containerIndex = containerOf(i);
|
110 | if (containerIndex === -1) {
|
111 | data += caption[i];
|
112 | }
|
113 | else {
|
114 | if (data.length > 0) {
|
115 | result.push({ data });
|
116 | }
|
117 | const { length } = ranges.splice(containerIndex, 1).shift();
|
118 | result.push({ data: caption.substring(i, i + length), highlight: true });
|
119 | data = '';
|
120 | i = i + length - 1;
|
121 | }
|
122 | }
|
123 | if (data.length > 0) {
|
124 | result.push({ data });
|
125 | }
|
126 | if (ranges.length !== 0) {
|
127 | throw new Error('Error occurred when splitting the caption. There was a mismatch between the caption and the corresponding highlighting ranges.');
|
128 | }
|
129 | return result;
|
130 | }
|
131 | CaptionHighlight.split = split;
|
132 | })(CaptionHighlight = WidgetDecoration.CaptionHighlight || (WidgetDecoration.CaptionHighlight = {}));
|
133 | let Data;
|
134 | (function (Data) {
|
135 | |
136 |
|
137 |
|
138 | Data.comparePriority = (left, right) => (left.priority || 0) - (right.priority || 0);
|
139 | })(Data = WidgetDecoration.Data || (WidgetDecoration.Data = {}));
|
140 | })(WidgetDecoration = exports.WidgetDecoration || (exports.WidgetDecoration = {}));
|
141 |
|
\ | No newline at end of file |