@codingame/monaco-vscode-view-banner-service-override 37.6.1 → 38.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-view-banner-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "38.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - view-banner service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "38.0.1"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -23,6 +23,8 @@ export declare class BannerPart extends Part implements IBannerService {
|
|
|
23
23
|
height: number;
|
|
24
24
|
} | undefined>;
|
|
25
25
|
private item;
|
|
26
|
+
private readonly items;
|
|
27
|
+
private readonly itemDisposables;
|
|
26
28
|
private visible;
|
|
27
29
|
private actionBar;
|
|
28
30
|
private messageActionsContainer;
|
|
@@ -39,5 +41,6 @@ export declare class BannerPart extends Part implements IBannerService {
|
|
|
39
41
|
focusPreviousAction(): void;
|
|
40
42
|
hide(id: string): void;
|
|
41
43
|
show(item: IBannerItem): void;
|
|
44
|
+
private renderActiveItem;
|
|
42
45
|
toJSON(): object;
|
|
43
46
|
}
|
|
@@ -3,7 +3,7 @@ import { registerCss } from '@codingame/monaco-vscode-api/css';
|
|
|
3
3
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
4
4
|
import * as bannerpart from './media/bannerpart.css';
|
|
5
5
|
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
6
|
-
import { addDisposableListener, EventType,
|
|
6
|
+
import { addDisposableListener, EventType, isHTMLElement, $, getActiveElement, clearNode, append } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
7
7
|
import { asCSSUrl } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/cssValue';
|
|
8
8
|
import { ActionBar } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
9
9
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
@@ -27,6 +27,7 @@ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platf
|
|
|
27
27
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
28
28
|
import { widgetClose } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/iconRegistry';
|
|
29
29
|
import { BannerFocused } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
30
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
30
31
|
|
|
31
32
|
registerCss(bannerpart, 0);
|
|
32
33
|
let BannerPart = class BannerPart extends Part {
|
|
@@ -57,6 +58,8 @@ let BannerPart = class BannerPart extends Part {
|
|
|
57
58
|
this.minimumWidth = 0;
|
|
58
59
|
this.maximumWidth = Number.POSITIVE_INFINITY;
|
|
59
60
|
this._onDidChangeSize = this._register(( new Emitter()));
|
|
61
|
+
this.items = ( new Map());
|
|
62
|
+
this.itemDisposables = this._register(( new DisposableStore()));
|
|
60
63
|
this.visible = false;
|
|
61
64
|
this.focusedActionIndex = -1;
|
|
62
65
|
}
|
|
@@ -73,12 +76,10 @@ let BannerPart = class BannerPart extends Part {
|
|
|
73
76
|
return this.element;
|
|
74
77
|
}
|
|
75
78
|
close(item) {
|
|
76
|
-
this.
|
|
77
|
-
clearNode(this.element);
|
|
79
|
+
this.hide(item.id);
|
|
78
80
|
if (typeof item.onClose === "function") {
|
|
79
81
|
item.onClose();
|
|
80
82
|
}
|
|
81
|
-
this.item = undefined;
|
|
82
83
|
}
|
|
83
84
|
focusActionLink() {
|
|
84
85
|
const length = this.item?.actions?.length ?? 0;
|
|
@@ -107,7 +108,7 @@ let BannerPart = class BannerPart extends Part {
|
|
|
107
108
|
element.textContent = message;
|
|
108
109
|
return element;
|
|
109
110
|
}
|
|
110
|
-
return this.markdownRendererService.render(message).element;
|
|
111
|
+
return this.itemDisposables.add(this.markdownRendererService.render(message)).element;
|
|
111
112
|
}
|
|
112
113
|
setVisibility(visible) {
|
|
113
114
|
if (visible !== this.visible) {
|
|
@@ -132,20 +133,42 @@ let BannerPart = class BannerPart extends Part {
|
|
|
132
133
|
this.focusActionLink();
|
|
133
134
|
}
|
|
134
135
|
hide(id) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
this.setVisibility(false);
|
|
136
|
+
this.items.delete(id);
|
|
137
|
+
this.renderActiveItem();
|
|
139
138
|
}
|
|
140
139
|
show(item) {
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
this.items.delete(item.id);
|
|
141
|
+
this.items.set(item.id, item);
|
|
142
|
+
this.renderActiveItem();
|
|
143
|
+
}
|
|
144
|
+
renderActiveItem() {
|
|
145
|
+
let item;
|
|
146
|
+
for (const candidate of ( this.items.values())) {
|
|
147
|
+
if (!item || (candidate.priority ?? 0) >= (item.priority ?? 0)) {
|
|
148
|
+
item = candidate;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (item === this.item) {
|
|
143
152
|
return;
|
|
144
153
|
}
|
|
154
|
+
const hadFocus = this.element.contains(getActiveElement(this.element.ownerDocument));
|
|
155
|
+
this.itemDisposables.clear();
|
|
145
156
|
clearNode(this.element);
|
|
157
|
+
this.item = item;
|
|
158
|
+
this.actionBar = undefined;
|
|
159
|
+
this.messageActionsContainer = undefined;
|
|
160
|
+
this.focusedActionIndex = -1;
|
|
161
|
+
if (!item) {
|
|
162
|
+
this.element.removeAttribute("aria-label");
|
|
163
|
+
this.setVisibility(false);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this.element.classList.toggle("neutral", !!item.neutral);
|
|
146
167
|
const ariaLabel = this.getAriaLabel(item);
|
|
147
168
|
if (ariaLabel) {
|
|
148
169
|
this.element.setAttribute("aria-label", ariaLabel);
|
|
170
|
+
} else {
|
|
171
|
+
this.element.removeAttribute("aria-label");
|
|
149
172
|
}
|
|
150
173
|
const iconContainer = append(this.element, $("div.icon-container"));
|
|
151
174
|
iconContainer.setAttribute("aria-hidden", "true");
|
|
@@ -163,7 +186,7 @@ let BannerPart = class BannerPart extends Part {
|
|
|
163
186
|
this.messageActionsContainer = append(this.element, $("div.message-actions-container"));
|
|
164
187
|
if (item.actions) {
|
|
165
188
|
for (const action of item.actions) {
|
|
166
|
-
this.
|
|
189
|
+
this.itemDisposables.add(
|
|
167
190
|
this.instantiationService.createInstance(Link, this.messageActionsContainer, {
|
|
168
191
|
...action,
|
|
169
192
|
tabIndex: -1
|
|
@@ -172,14 +195,15 @@ let BannerPart = class BannerPart extends Part {
|
|
|
172
195
|
}
|
|
173
196
|
}
|
|
174
197
|
const actionBarContainer = append(this.element, $("div.action-container"));
|
|
175
|
-
this.actionBar = this.
|
|
176
|
-
const label = item.closeLabel ?? ( localize(
|
|
177
|
-
const
|
|
198
|
+
this.actionBar = this.itemDisposables.add(( new ActionBar(actionBarContainer)));
|
|
199
|
+
const label = item.closeLabel ?? ( localize(7005, "Close Banner"));
|
|
200
|
+
const activeItem = item;
|
|
201
|
+
const closeAction = this.itemDisposables.add(( new Action(
|
|
178
202
|
"banner.close",
|
|
179
203
|
label,
|
|
180
204
|
ThemeIcon.asClassName(widgetClose),
|
|
181
205
|
true,
|
|
182
|
-
() => this.close(
|
|
206
|
+
() => this.close(activeItem)
|
|
183
207
|
)));
|
|
184
208
|
this.actionBar.push(closeAction, {
|
|
185
209
|
icon: true,
|
|
@@ -187,7 +211,9 @@ let BannerPart = class BannerPart extends Part {
|
|
|
187
211
|
});
|
|
188
212
|
this.actionBar.setFocusable(false);
|
|
189
213
|
this.setVisibility(true);
|
|
190
|
-
|
|
214
|
+
if (hadFocus) {
|
|
215
|
+
this.focus();
|
|
216
|
+
}
|
|
191
217
|
}
|
|
192
218
|
toJSON() {
|
|
193
219
|
return {
|
|
@@ -233,7 +259,7 @@ class FocusBannerAction extends Action2 {
|
|
|
233
259
|
this.ID = "workbench.action.focusBanner";
|
|
234
260
|
}
|
|
235
261
|
static {
|
|
236
|
-
this.LABEL = ( localize2(
|
|
262
|
+
this.LABEL = ( localize2(7006, "Focus Banner"));
|
|
237
263
|
}
|
|
238
264
|
constructor() {
|
|
239
265
|
super({
|
|
@@ -78,3 +78,15 @@
|
|
|
78
78
|
.monaco-workbench .part.banner .action-container .codicon {
|
|
79
79
|
color: var(--vscode-banner-foreground);
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
.monaco-workbench .part.banner.neutral {
|
|
83
|
+
background-color: var(--vscode-sideBar-background);
|
|
84
|
+
color: var(--vscode-foreground);
|
|
85
|
+
border-bottom: var(--vscode-strokeThickness) solid var(--vscode-contrastBorder);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.monaco-workbench .part.banner.neutral .message-actions-container a,
|
|
89
|
+
.monaco-workbench .part.banner.neutral .action-container .codicon,
|
|
90
|
+
.monaco-workbench .part.banner.neutral .icon-container .codicon {
|
|
91
|
+
color: var(--vscode-foreground);
|
|
92
|
+
}
|