@codingame/monaco-vscode-api 1.76.1 → 1.76.3-next.0
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/README.md +2 -1
- package/dist/api.js +3 -860
- package/dist/{extHost.js → api2.js} +16555 -13467
- package/dist/async.js +107 -2
- package/dist/audioCue.js +105 -103
- package/dist/button.js +1 -1
- package/dist/cancellation.js +3 -0
- package/dist/configuration.js +7 -344
- package/dist/configuration2.js +339 -0
- package/dist/configurationRegistry.js +441 -0
- package/dist/contextkeys.js +211 -0
- package/dist/debug.d.ts +22 -0
- package/dist/debug.js +15842 -0
- package/dist/dialogs.js +855 -9
- package/dist/extensionResourceLoader.js +96 -0
- package/dist/extensions.d.ts +491 -0
- package/dist/extensions.js +70 -0
- package/dist/{tools.js → extensionsRegistry.js} +2 -30
- package/dist/files.js +1407 -334
- package/dist/iconv.js +43 -0
- package/dist/injection.js +1 -1
- package/dist/jschardet.js +7 -0
- package/dist/keybindings.d.ts +1 -485
- package/dist/keybindings.js +666 -679
- package/dist/labels.js +14 -0
- package/dist/languageConfiguration.d.ts +1 -2
- package/dist/languageConfiguration.js +9 -16
- package/dist/languageService.js +112 -8
- package/dist/languages.d.ts +1 -473
- package/dist/languages.js +2 -12
- package/dist/layout.js +4 -3
- package/dist/layoutService.js +1 -1
- package/dist/missing-services.js +4710 -74
- package/dist/modelEditor.d.ts +324 -2
- package/dist/modelEditor.js +15 -228
- package/dist/monaco.js +7 -72
- package/dist/notifications.js +75 -232
- package/dist/polyfill.js +10715 -2459
- package/dist/resources.js +197 -0
- package/dist/services.d.ts +924 -3
- package/dist/services.js +1 -2
- package/dist/services2.js +2436 -18
- package/dist/snippets.d.ts +1 -473
- package/dist/snippets.js +8 -867
- package/dist/snippetsService.js +868 -0
- package/dist/textFileEditorModel.js +2985 -0
- package/dist/textmate.d.ts +3 -475
- package/dist/textmate.js +19 -29
- package/dist/theme.d.ts +1 -3
- package/dist/theme.js +24 -70
- package/dist/tokenClassification.d.ts +1 -475
- package/dist/tokenClassification.js +11 -37
- package/dist/tokenClassificationRegistry.js +8 -4
- package/dist/variableResolver.js +1711 -0
- package/dist/workbenchThemeService.js +1 -1
- package/dist/workspaceContext.js +1 -3
- package/package.json +27 -12
- package/dist/contextkey.js +0 -419
- package/dist/dialog.web.contribution.js +0 -945
package/dist/dialogs.js
CHANGED
|
@@ -1,16 +1,862 @@
|
|
|
1
|
-
import './polyfill.js';
|
|
2
|
-
import './missing-services.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { n, o as onServicesInitialized } from './polyfill.js';
|
|
2
|
+
import { bM as AbstractDialogHandler } from './missing-services.js';
|
|
3
|
+
import { _ as __decorate, a as __param, e as IProductService, o as IWorkbenchEnvironmentService, E as Emitter } from './services2.js';
|
|
4
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
5
|
+
import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
|
|
6
|
+
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
7
|
+
import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
|
|
8
|
+
import { B as ButtonBar, a as ButtonWithDescription } from './button.js';
|
|
9
|
+
import { m as mnemonicButtonLabel } from './labels.js';
|
|
10
|
+
import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
11
|
+
import { EventHelper, $, hide, addDisposableListener, EventType, clearNode, isAncestor, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
12
|
+
import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
|
|
13
|
+
import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
|
|
14
|
+
import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
15
|
+
import { isMacintosh, isLinux, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
16
|
+
import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
|
|
17
|
+
import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
|
|
8
18
|
import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
19
|
+
import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
|
|
9
20
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
21
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
22
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
23
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
24
|
+
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
12
25
|
import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|
|
26
|
+
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
27
|
+
import { g as getServiceOverride$1 } from './layout.js';
|
|
13
28
|
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
29
|
+
var css$1 = ".monaco-custom-toggle{border:1px solid transparent;border-radius:3px;box-sizing:border-box;cursor:pointer;float:left;height:20px;margin-left:2px;overflow:hidden;padding:1px;user-select:none;-webkit-user-select:none;width:20px}.monaco-custom-toggle:hover{background-color:var(--vscode-inputOption-hoverBackground)}.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle:hover{border:1px dashed var(--vscode-focusBorder)}.hc-black .monaco-custom-toggle,.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle,.hc-light .monaco-custom-toggle:hover{background:none}.monaco-custom-toggle.monaco-checkbox{background-size:16px!important;border:1px solid transparent;border-radius:3px;height:18px;margin-left:0;margin-right:9px;opacity:1;padding:0;width:18px}.monaco-custom-toggle.monaco-checkbox:not(.checked):before{visibility:hidden}";
|
|
30
|
+
n(css$1,{});
|
|
31
|
+
const unthemedToggleStyles = {
|
|
32
|
+
inputActiveOptionBorder: '#007ACC00',
|
|
33
|
+
inputActiveOptionForeground: '#FFFFFF',
|
|
34
|
+
inputActiveOptionBackground: '#0E639C50'
|
|
35
|
+
};
|
|
36
|
+
class Toggle extends Widget {
|
|
37
|
+
constructor(opts) {
|
|
38
|
+
super();
|
|
39
|
+
this._onChange = this._register(( (new Emitter())));
|
|
40
|
+
this.onChange = this._onChange.event;
|
|
41
|
+
this._onKeyDown = this._register(( (new Emitter())));
|
|
42
|
+
this.onKeyDown = this._onKeyDown.event;
|
|
43
|
+
this._opts = opts;
|
|
44
|
+
this._checked = this._opts.isChecked;
|
|
45
|
+
const classes = ['monaco-custom-toggle'];
|
|
46
|
+
if (this._opts.icon) {
|
|
47
|
+
this._icon = this._opts.icon;
|
|
48
|
+
classes.push(...ThemeIcon.asClassNameArray(this._icon));
|
|
49
|
+
}
|
|
50
|
+
if (this._opts.actionClassName) {
|
|
51
|
+
classes.push(...this._opts.actionClassName.split(' '));
|
|
52
|
+
}
|
|
53
|
+
if (this._checked) {
|
|
54
|
+
classes.push('checked');
|
|
55
|
+
}
|
|
56
|
+
this.domNode = document.createElement('div');
|
|
57
|
+
this.domNode.title = this._opts.title;
|
|
58
|
+
this.domNode.classList.add(...classes);
|
|
59
|
+
if (!this._opts.notFocusable) {
|
|
60
|
+
this.domNode.tabIndex = 0;
|
|
61
|
+
}
|
|
62
|
+
this.domNode.setAttribute('role', 'checkbox');
|
|
63
|
+
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
64
|
+
this.domNode.setAttribute('aria-label', this._opts.title);
|
|
65
|
+
this.applyStyles();
|
|
66
|
+
this.onclick(this.domNode, (ev) => {
|
|
67
|
+
if (this.enabled) {
|
|
68
|
+
this.checked = !this._checked;
|
|
69
|
+
this._onChange.fire(false);
|
|
70
|
+
ev.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this._register(this.ignoreGesture(this.domNode));
|
|
74
|
+
this.onkeydown(this.domNode, (keyboardEvent) => {
|
|
75
|
+
if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
|
|
76
|
+
this.checked = !this._checked;
|
|
77
|
+
this._onChange.fire(true);
|
|
78
|
+
keyboardEvent.preventDefault();
|
|
79
|
+
keyboardEvent.stopPropagation();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this._onKeyDown.fire(keyboardEvent);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
get enabled() {
|
|
86
|
+
return this.domNode.getAttribute('aria-disabled') !== 'true';
|
|
87
|
+
}
|
|
88
|
+
focus() {
|
|
89
|
+
this.domNode.focus();
|
|
90
|
+
}
|
|
91
|
+
get checked() {
|
|
92
|
+
return this._checked;
|
|
93
|
+
}
|
|
94
|
+
set checked(newIsChecked) {
|
|
95
|
+
this._checked = newIsChecked;
|
|
96
|
+
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
97
|
+
this.domNode.classList.toggle('checked', this._checked);
|
|
98
|
+
this.applyStyles();
|
|
99
|
+
}
|
|
100
|
+
setIcon(icon) {
|
|
101
|
+
if (this._icon) {
|
|
102
|
+
this.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));
|
|
103
|
+
}
|
|
104
|
+
this._icon = icon;
|
|
105
|
+
if (this._icon) {
|
|
106
|
+
this.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
width() {
|
|
110
|
+
return 2 + 2 + 2 + 16 ;
|
|
111
|
+
}
|
|
112
|
+
applyStyles() {
|
|
113
|
+
if (this.domNode) {
|
|
114
|
+
this.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';
|
|
115
|
+
this.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';
|
|
116
|
+
this.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
enable() {
|
|
120
|
+
this.domNode.setAttribute('aria-disabled', String(false));
|
|
121
|
+
}
|
|
122
|
+
disable() {
|
|
123
|
+
this.domNode.setAttribute('aria-disabled', String(true));
|
|
124
|
+
}
|
|
125
|
+
setTitle(newTitle) {
|
|
126
|
+
this.domNode.title = newTitle;
|
|
127
|
+
this.domNode.setAttribute('aria-label', newTitle);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
class Checkbox extends Widget {
|
|
131
|
+
constructor(title, isChecked, styles) {
|
|
132
|
+
super();
|
|
133
|
+
this.title = title;
|
|
134
|
+
this.isChecked = isChecked;
|
|
135
|
+
this.checkbox = ( (new Toggle(
|
|
136
|
+
{ title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox', ...unthemedToggleStyles }
|
|
137
|
+
)));
|
|
138
|
+
this.domNode = this.checkbox.domNode;
|
|
139
|
+
this.styles = styles;
|
|
140
|
+
this.applyStyles();
|
|
141
|
+
this._register(this.checkbox.onChange(() => this.applyStyles()));
|
|
142
|
+
}
|
|
143
|
+
get checked() {
|
|
144
|
+
return this.checkbox.checked;
|
|
145
|
+
}
|
|
146
|
+
set checked(newIsChecked) {
|
|
147
|
+
this.checkbox.checked = newIsChecked;
|
|
148
|
+
this.applyStyles();
|
|
149
|
+
}
|
|
150
|
+
focus() {
|
|
151
|
+
this.domNode.focus();
|
|
152
|
+
}
|
|
153
|
+
hasFocus() {
|
|
154
|
+
return this.domNode === document.activeElement;
|
|
155
|
+
}
|
|
156
|
+
applyStyles() {
|
|
157
|
+
this.domNode.style.color = this.styles.checkboxForeground || '';
|
|
158
|
+
this.domNode.style.backgroundColor = this.styles.checkboxBackground || '';
|
|
159
|
+
this.domNode.style.borderColor = this.styles.checkboxBorder || '';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const minute = 60;
|
|
163
|
+
const hour = minute * 60;
|
|
164
|
+
const day = hour * 24;
|
|
165
|
+
const week = day * 7;
|
|
166
|
+
const month = day * 30;
|
|
167
|
+
const year = day * 365;
|
|
168
|
+
function fromNow(date, appendAgoLabel, useFullTimeWords, disallowNow) {
|
|
169
|
+
if (typeof date !== 'number') {
|
|
170
|
+
date = date.getTime();
|
|
171
|
+
}
|
|
172
|
+
const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
|
|
173
|
+
if (seconds < -30) {
|
|
174
|
+
return (
|
|
175
|
+
(localize(
|
|
176
|
+
'date.fromNow.in',
|
|
177
|
+
'in {0}',
|
|
178
|
+
fromNow(( (new Date())).getTime() + seconds * 1000, false)
|
|
179
|
+
))
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
if (!disallowNow && seconds < 30) {
|
|
183
|
+
return (
|
|
184
|
+
(localize('date.fromNow.now', 'now'))
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
let value;
|
|
188
|
+
if (seconds < minute) {
|
|
189
|
+
value = seconds;
|
|
190
|
+
if (appendAgoLabel) {
|
|
191
|
+
if (value === 1) {
|
|
192
|
+
return useFullTimeWords
|
|
193
|
+
? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
|
|
194
|
+
: ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return useFullTimeWords
|
|
198
|
+
? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
|
|
199
|
+
: ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
if (value === 1) {
|
|
204
|
+
return useFullTimeWords
|
|
205
|
+
? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
|
|
206
|
+
: ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
return useFullTimeWords
|
|
210
|
+
? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
|
|
211
|
+
: ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (seconds < hour) {
|
|
216
|
+
value = Math.floor(seconds / minute);
|
|
217
|
+
if (appendAgoLabel) {
|
|
218
|
+
if (value === 1) {
|
|
219
|
+
return useFullTimeWords
|
|
220
|
+
? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
|
|
221
|
+
: ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
return useFullTimeWords
|
|
225
|
+
? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
|
|
226
|
+
: ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
if (value === 1) {
|
|
231
|
+
return useFullTimeWords
|
|
232
|
+
? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
|
|
233
|
+
: ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return useFullTimeWords
|
|
237
|
+
? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
|
|
238
|
+
: ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (seconds < day) {
|
|
243
|
+
value = Math.floor(seconds / hour);
|
|
244
|
+
if (appendAgoLabel) {
|
|
245
|
+
if (value === 1) {
|
|
246
|
+
return useFullTimeWords
|
|
247
|
+
? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
|
|
248
|
+
: ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
return useFullTimeWords
|
|
252
|
+
? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
|
|
253
|
+
: ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
if (value === 1) {
|
|
258
|
+
return useFullTimeWords
|
|
259
|
+
? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
|
|
260
|
+
: ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
return useFullTimeWords
|
|
264
|
+
? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
|
|
265
|
+
: ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (seconds < week) {
|
|
270
|
+
value = Math.floor(seconds / day);
|
|
271
|
+
if (appendAgoLabel) {
|
|
272
|
+
return value === 1
|
|
273
|
+
? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
|
|
274
|
+
: ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
return value === 1
|
|
278
|
+
? ( (localize('date.fromNow.days.singular', '{0} day', value)))
|
|
279
|
+
: ( (localize('date.fromNow.days.plural', '{0} days', value)));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (seconds < month) {
|
|
283
|
+
value = Math.floor(seconds / week);
|
|
284
|
+
if (appendAgoLabel) {
|
|
285
|
+
if (value === 1) {
|
|
286
|
+
return useFullTimeWords
|
|
287
|
+
? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
|
|
288
|
+
: ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return useFullTimeWords
|
|
292
|
+
? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
|
|
293
|
+
: ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
if (value === 1) {
|
|
298
|
+
return useFullTimeWords
|
|
299
|
+
? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
|
|
300
|
+
: ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return useFullTimeWords
|
|
304
|
+
? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
|
|
305
|
+
: ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (seconds < year) {
|
|
310
|
+
value = Math.floor(seconds / month);
|
|
311
|
+
if (appendAgoLabel) {
|
|
312
|
+
if (value === 1) {
|
|
313
|
+
return useFullTimeWords
|
|
314
|
+
? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
|
|
315
|
+
: ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
return useFullTimeWords
|
|
319
|
+
? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
|
|
320
|
+
: ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
if (value === 1) {
|
|
325
|
+
return useFullTimeWords
|
|
326
|
+
? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
|
|
327
|
+
: ( (localize('date.fromNow.months.singular', '{0} mo', value)));
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
return useFullTimeWords
|
|
331
|
+
? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
|
|
332
|
+
: ( (localize('date.fromNow.months.plural', '{0} mos', value)));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
value = Math.floor(seconds / year);
|
|
337
|
+
if (appendAgoLabel) {
|
|
338
|
+
if (value === 1) {
|
|
339
|
+
return useFullTimeWords
|
|
340
|
+
? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
|
|
341
|
+
: ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return useFullTimeWords
|
|
345
|
+
? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
|
|
346
|
+
: ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
if (value === 1) {
|
|
351
|
+
return useFullTimeWords
|
|
352
|
+
? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
|
|
353
|
+
: ( (localize('date.fromNow.years.singular', '{0} yr', value)));
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
return useFullTimeWords
|
|
357
|
+
? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
|
|
358
|
+
: ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
var css = ".monaco-dialog-modal-block{align-items:center;display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:2600}.monaco-dialog-modal-block.dimmed{background:rgba(0,0,0,.3)}.monaco-dialog-box{display:flex;flex-direction:column-reverse;max-width:90vw;min-height:75px;min-width:500px;padding:10px;transform:translateZ(0);width:min-content}.monaco-dialog-box .dialog-toolbar-row{height:22px;padding-bottom:4px}.monaco-dialog-box .dialog-toolbar-row .actions-container{justify-content:flex-end}.monaco-dialog-box .dialog-message-row{align-items:center;display:flex;flex-grow:1;padding:0 10px}.monaco-dialog-box .dialog-message-row>.dialog-icon.codicon{align-self:baseline;flex:0 0 48px;font-size:48px;height:48px}.monaco-dialog-box .dialog-message-row .dialog-message-container{word-wrap:break-word;display:flex;flex-direction:column;overflow:hidden;padding-left:24px;text-overflow:ellipsis;user-select:text;-webkit-user-select:text;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message{word-wrap:break-word;align-items:center;display:flex;flex:1;font-size:18px;line-height:22px;margin-bottom:8px;min-height:48px;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail{flex:1;line-height:22px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus{outline-style:solid;outline-width:1px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message{cursor:pointer;user-select:none;-webkit-user-select:none}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox{flex:1}.monaco-dialog-box code{font-family:var(--monaco-monospace-font)}.monaco-dialog-box>.dialog-buttons-row{align-items:center;display:flex;overflow:hidden;padding-right:1px;padding:20px 10px 10px;white-space:nowrap}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons{display:flex;justify-content:flex-end;margin-left:67px;overflow:hidden;width:100%}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons>.monaco-button{margin:4px 5px;outline-offset:2px!important;overflow:hidden;padding:5px 10px;text-overflow:ellipsis;width:fit-content}";
|
|
363
|
+
n(css,{});
|
|
364
|
+
class Dialog extends Disposable {
|
|
365
|
+
constructor(container, message, buttons, options) {
|
|
366
|
+
super();
|
|
367
|
+
this.container = container;
|
|
368
|
+
this.message = message;
|
|
369
|
+
this.options = options;
|
|
370
|
+
this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
|
|
371
|
+
this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
|
|
372
|
+
this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
|
|
373
|
+
this.element.setAttribute('role', 'dialog');
|
|
374
|
+
this.element.tabIndex = -1;
|
|
375
|
+
hide(this.element);
|
|
376
|
+
this.buttonStyles = options.buttonStyles;
|
|
377
|
+
if (Array.isArray(buttons) && buttons.length > 0) {
|
|
378
|
+
this.buttons = buttons;
|
|
379
|
+
}
|
|
380
|
+
else if (!this.options.disableDefaultAction) {
|
|
381
|
+
this.buttons = [( (localize('ok', "OK")))];
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
this.buttons = [];
|
|
385
|
+
}
|
|
386
|
+
const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
|
|
387
|
+
this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
|
|
388
|
+
const messageRowElement = this.element.appendChild($('.dialog-message-row'));
|
|
389
|
+
this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
|
|
390
|
+
this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
|
|
391
|
+
this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
|
|
392
|
+
if (this.options.detail || this.options.renderBody) {
|
|
393
|
+
const messageElement = this.messageContainer.appendChild($('.dialog-message'));
|
|
394
|
+
const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
|
|
395
|
+
messageTextElement.innerText = this.message;
|
|
396
|
+
}
|
|
397
|
+
this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
|
|
398
|
+
if (this.options.detail || !this.options.renderBody) {
|
|
399
|
+
this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
this.messageDetailElement.style.display = 'none';
|
|
403
|
+
}
|
|
404
|
+
if (this.options.renderBody) {
|
|
405
|
+
const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
|
|
406
|
+
this.options.renderBody(customBody);
|
|
407
|
+
for (const el of this.messageContainer.querySelectorAll('a')) {
|
|
408
|
+
el.tabIndex = 0;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (this.options.inputs) {
|
|
412
|
+
this.inputs = ( (this.options.inputs.map(input => {
|
|
413
|
+
const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
|
|
414
|
+
const inputBox = this._register(( (new InputBox(inputRowElement, undefined, {
|
|
415
|
+
placeholder: input.placeholder,
|
|
416
|
+
type: input.type ?? 'text',
|
|
417
|
+
inputBoxStyles: options.inputBoxStyles
|
|
418
|
+
}))));
|
|
419
|
+
if (input.value) {
|
|
420
|
+
inputBox.value = input.value;
|
|
421
|
+
}
|
|
422
|
+
return inputBox;
|
|
423
|
+
})));
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
this.inputs = [];
|
|
427
|
+
}
|
|
428
|
+
if (this.options.checkboxLabel) {
|
|
429
|
+
const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
|
|
430
|
+
const checkbox = this.checkbox = this._register(( (new Checkbox(
|
|
431
|
+
this.options.checkboxLabel,
|
|
432
|
+
!!this.options.checkboxChecked,
|
|
433
|
+
options.checkboxStyles
|
|
434
|
+
))));
|
|
435
|
+
checkboxRowElement.appendChild(checkbox.domNode);
|
|
436
|
+
const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
|
|
437
|
+
checkboxMessageElement.innerText = this.options.checkboxLabel;
|
|
438
|
+
this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
|
|
439
|
+
}
|
|
440
|
+
const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
|
|
441
|
+
this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
|
|
442
|
+
this.applyStyles();
|
|
443
|
+
}
|
|
444
|
+
getIconAriaLabel() {
|
|
445
|
+
const typeLabel = ( (localize('dialogInfoMessage', 'Info')));
|
|
446
|
+
return typeLabel;
|
|
447
|
+
}
|
|
448
|
+
updateMessage(message) {
|
|
449
|
+
this.messageDetailElement.innerText = message;
|
|
450
|
+
}
|
|
451
|
+
async show() {
|
|
452
|
+
this.focusToReturn = document.activeElement;
|
|
453
|
+
return (
|
|
454
|
+
(new Promise((resolve) => {
|
|
455
|
+
clearNode(this.buttonsContainer);
|
|
456
|
+
const buttonBar = this.buttonBar = this._register(( (new ButtonBar(this.buttonsContainer))));
|
|
457
|
+
const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
|
|
458
|
+
buttonMap.forEach((entry, index) => {
|
|
459
|
+
const primary = buttonMap[index].index === 0;
|
|
460
|
+
const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary, ...this.buttonStyles })) : this._register(buttonBar.addButton({ title: true, secondary: !primary, ...this.buttonStyles }));
|
|
461
|
+
button.label = mnemonicButtonLabel(buttonMap[index].label, true);
|
|
462
|
+
if (button instanceof ButtonWithDescription) {
|
|
463
|
+
button.description = this.options.buttonDetails[buttonMap[index].index];
|
|
464
|
+
}
|
|
465
|
+
this._register(button.onDidClick(e => {
|
|
466
|
+
if (e) {
|
|
467
|
+
EventHelper.stop(e);
|
|
468
|
+
}
|
|
469
|
+
resolve({
|
|
470
|
+
button: buttonMap[index].index,
|
|
471
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
472
|
+
values: this.inputs.length > 0 ? ( (this.inputs.map(input => input.value))) : undefined
|
|
473
|
+
});
|
|
474
|
+
}));
|
|
475
|
+
});
|
|
476
|
+
this._register(addDisposableListener(window, 'keydown', e => {
|
|
477
|
+
const evt = ( (new StandardKeyboardEvent(e)));
|
|
478
|
+
if (evt.equals(512 )) {
|
|
479
|
+
evt.preventDefault();
|
|
480
|
+
}
|
|
481
|
+
if (evt.equals(3 )) {
|
|
482
|
+
if (this.inputs.some(input => input.hasFocus())) {
|
|
483
|
+
EventHelper.stop(e);
|
|
484
|
+
resolve({
|
|
485
|
+
button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
|
|
486
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
487
|
+
values: this.inputs.length > 0 ? ( (this.inputs.map(input => input.value))) : undefined
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (evt.equals(10 )) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
let eventHandled = false;
|
|
496
|
+
if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
|
|
497
|
+
const focusableElements = [];
|
|
498
|
+
let focusedIndex = -1;
|
|
499
|
+
if (this.messageContainer) {
|
|
500
|
+
const links = this.messageContainer.querySelectorAll('a');
|
|
501
|
+
for (const link of links) {
|
|
502
|
+
focusableElements.push(link);
|
|
503
|
+
if (link === document.activeElement) {
|
|
504
|
+
focusedIndex = focusableElements.length - 1;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
for (const input of this.inputs) {
|
|
509
|
+
focusableElements.push(input);
|
|
510
|
+
if (input.hasFocus()) {
|
|
511
|
+
focusedIndex = focusableElements.length - 1;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (this.checkbox) {
|
|
515
|
+
focusableElements.push(this.checkbox);
|
|
516
|
+
if (this.checkbox.hasFocus()) {
|
|
517
|
+
focusedIndex = focusableElements.length - 1;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (this.buttonBar) {
|
|
521
|
+
for (const button of this.buttonBar.buttons) {
|
|
522
|
+
focusableElements.push(button);
|
|
523
|
+
if (button.hasFocus()) {
|
|
524
|
+
focusedIndex = focusableElements.length - 1;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (evt.equals(2 ) || evt.equals(17 )) {
|
|
529
|
+
if (focusedIndex === -1) {
|
|
530
|
+
focusedIndex = 0;
|
|
531
|
+
}
|
|
532
|
+
const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
|
|
533
|
+
focusableElements[newFocusedIndex].focus();
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
if (focusedIndex === -1) {
|
|
537
|
+
focusedIndex = focusableElements.length;
|
|
538
|
+
}
|
|
539
|
+
let newFocusedIndex = focusedIndex - 1;
|
|
540
|
+
if (newFocusedIndex === -1) {
|
|
541
|
+
newFocusedIndex = focusableElements.length - 1;
|
|
542
|
+
}
|
|
543
|
+
focusableElements[newFocusedIndex].focus();
|
|
544
|
+
}
|
|
545
|
+
eventHandled = true;
|
|
546
|
+
}
|
|
547
|
+
if (eventHandled) {
|
|
548
|
+
EventHelper.stop(e, true);
|
|
549
|
+
}
|
|
550
|
+
else if (this.options.keyEventProcessor) {
|
|
551
|
+
this.options.keyEventProcessor(evt);
|
|
552
|
+
}
|
|
553
|
+
}, true));
|
|
554
|
+
this._register(addDisposableListener(window, 'keyup', e => {
|
|
555
|
+
EventHelper.stop(e, true);
|
|
556
|
+
const evt = ( (new StandardKeyboardEvent(e)));
|
|
557
|
+
if (!this.options.disableCloseAction && evt.equals(9 )) {
|
|
558
|
+
resolve({
|
|
559
|
+
button: this.options.cancelId || 0,
|
|
560
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}, true));
|
|
564
|
+
this._register(addDisposableListener(this.element, 'focusout', e => {
|
|
565
|
+
if (!!e.relatedTarget && !!this.element) {
|
|
566
|
+
if (!isAncestor(e.relatedTarget, this.element)) {
|
|
567
|
+
this.focusToReturn = e.relatedTarget;
|
|
568
|
+
if (e.target) {
|
|
569
|
+
e.target.focus();
|
|
570
|
+
EventHelper.stop(e, true);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}, false));
|
|
575
|
+
const spinModifierClassName = 'codicon-modifier-spin';
|
|
576
|
+
this.iconElement.classList.remove(...ThemeIcon.asClassNameArray(Codicon.dialogError), ...ThemeIcon.asClassNameArray(Codicon.dialogWarning), ...ThemeIcon.asClassNameArray(Codicon.dialogInfo), ...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
|
|
577
|
+
if (this.options.icon) {
|
|
578
|
+
this.iconElement.classList.add(...ThemeIcon.asClassNameArray(this.options.icon));
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
switch (this.options.type) {
|
|
582
|
+
case 'error':
|
|
583
|
+
this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogError));
|
|
584
|
+
break;
|
|
585
|
+
case 'warning':
|
|
586
|
+
this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogWarning));
|
|
587
|
+
break;
|
|
588
|
+
case 'pending':
|
|
589
|
+
this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
|
|
590
|
+
break;
|
|
591
|
+
case 'none':
|
|
592
|
+
case 'info':
|
|
593
|
+
case 'question':
|
|
594
|
+
default:
|
|
595
|
+
this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogInfo));
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (!this.options.disableCloseAction) {
|
|
600
|
+
const actionBar = this._register(( (new ActionBar(this.toolbarContainer, {}))));
|
|
601
|
+
const action = this._register(( (new Action(
|
|
602
|
+
'dialog.close',
|
|
603
|
+
(localize('dialogClose', "Close Dialog")),
|
|
604
|
+
ThemeIcon.asClassName(Codicon.dialogClose),
|
|
605
|
+
true,
|
|
606
|
+
async () => {
|
|
607
|
+
resolve({
|
|
608
|
+
button: this.options.cancelId || 0,
|
|
609
|
+
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
))));
|
|
613
|
+
actionBar.push(action, { icon: true, label: false });
|
|
614
|
+
}
|
|
615
|
+
this.applyStyles();
|
|
616
|
+
this.element.setAttribute('aria-modal', 'true');
|
|
617
|
+
this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
|
|
618
|
+
this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
|
|
619
|
+
show(this.element);
|
|
620
|
+
if (this.inputs.length > 0) {
|
|
621
|
+
this.inputs[0].focus();
|
|
622
|
+
this.inputs[0].select();
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
buttonMap.forEach((value, index) => {
|
|
626
|
+
if (value.index === 0) {
|
|
627
|
+
buttonBar.buttons[index].focus();
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}))
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
applyStyles() {
|
|
635
|
+
const style = this.options.dialogStyles;
|
|
636
|
+
const fgColor = style.dialogForeground;
|
|
637
|
+
const bgColor = style.dialogBackground;
|
|
638
|
+
const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
|
|
639
|
+
const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
|
|
640
|
+
const linkFgColor = style.textLinkForeground;
|
|
641
|
+
this.shadowElement.style.boxShadow = shadowColor;
|
|
642
|
+
this.element.style.color = fgColor ?? '';
|
|
643
|
+
this.element.style.backgroundColor = bgColor ?? '';
|
|
644
|
+
this.element.style.border = border;
|
|
645
|
+
if (linkFgColor) {
|
|
646
|
+
for (const el of this.messageContainer.getElementsByTagName('a')) {
|
|
647
|
+
el.style.color = linkFgColor;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
let color;
|
|
651
|
+
switch (this.options.type) {
|
|
652
|
+
case 'error':
|
|
653
|
+
color = style.errorIconForeground;
|
|
654
|
+
break;
|
|
655
|
+
case 'warning':
|
|
656
|
+
color = style.warningIconForeground;
|
|
657
|
+
break;
|
|
658
|
+
default:
|
|
659
|
+
color = style.infoIconForeground;
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
if (color) {
|
|
663
|
+
this.iconElement.style.color = color;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
dispose() {
|
|
667
|
+
super.dispose();
|
|
668
|
+
if (this.modalElement) {
|
|
669
|
+
this.modalElement.remove();
|
|
670
|
+
this.modalElement = undefined;
|
|
671
|
+
}
|
|
672
|
+
if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
|
|
673
|
+
this.focusToReturn.focus();
|
|
674
|
+
this.focusToReturn = undefined;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
rearrangeButtons(buttons, cancelId) {
|
|
678
|
+
const buttonMap = ( (buttons.map((label, index) => ({ label, index }))));
|
|
679
|
+
if (buttons.length < 2) {
|
|
680
|
+
return buttonMap;
|
|
681
|
+
}
|
|
682
|
+
if (isMacintosh || isLinux) {
|
|
683
|
+
if (typeof cancelId === 'number' && buttonMap[cancelId]) {
|
|
684
|
+
const cancelButton = buttonMap.splice(cancelId, 1)[0];
|
|
685
|
+
buttonMap.splice(1, 0, cancelButton);
|
|
686
|
+
}
|
|
687
|
+
buttonMap.reverse();
|
|
688
|
+
}
|
|
689
|
+
else if (isWindows) {
|
|
690
|
+
if (typeof cancelId === 'number' && buttonMap[cancelId]) {
|
|
691
|
+
const cancelButton = buttonMap.splice(cancelId, 1)[0];
|
|
692
|
+
buttonMap.push(cancelButton);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return buttonMap;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHandler {
|
|
699
|
+
constructor(logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
|
|
700
|
+
super();
|
|
701
|
+
this.logService = logService;
|
|
702
|
+
this.layoutService = layoutService;
|
|
703
|
+
this.keybindingService = keybindingService;
|
|
704
|
+
this.instantiationService = instantiationService;
|
|
705
|
+
this.productService = productService;
|
|
706
|
+
this.clipboardService = clipboardService;
|
|
707
|
+
this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
708
|
+
}
|
|
709
|
+
async prompt(prompt) {
|
|
710
|
+
this.logService.trace('DialogService#prompt', prompt.message);
|
|
711
|
+
const buttons = this.getPromptButtons(prompt);
|
|
712
|
+
const { button, checkboxChecked } = await this.doShow(prompt.type, prompt.message, buttons, prompt.detail, prompt.cancelButton ? buttons.length - 1 : -1 , prompt.checkbox, undefined, typeof prompt?.custom === 'object' ? prompt.custom : undefined);
|
|
713
|
+
return this.getPromptResult(prompt, button, checkboxChecked);
|
|
714
|
+
}
|
|
715
|
+
async confirm(confirmation) {
|
|
716
|
+
this.logService.trace('DialogService#confirm', confirmation.message);
|
|
717
|
+
const buttons = this.getConfirmationButtons(confirmation);
|
|
718
|
+
const { button, checkboxChecked } = await this.doShow(confirmation.type ?? 'question', confirmation.message, buttons, confirmation.detail, buttons.length - 1, confirmation.checkbox, undefined, typeof confirmation?.custom === 'object' ? confirmation.custom : undefined);
|
|
719
|
+
return { confirmed: button === 0, checkboxChecked };
|
|
720
|
+
}
|
|
721
|
+
async input(input) {
|
|
722
|
+
this.logService.trace('DialogService#input', input.message);
|
|
723
|
+
const buttons = this.getInputButtons(input);
|
|
724
|
+
const { button, checkboxChecked, values } = await this.doShow(input.type ?? 'question', input.message, buttons, input.detail, buttons.length - 1, input?.checkbox, input.inputs);
|
|
725
|
+
return { confirmed: button === 0, checkboxChecked, values };
|
|
726
|
+
}
|
|
727
|
+
async about() {
|
|
728
|
+
const detailString = (useAgo) => {
|
|
729
|
+
return (
|
|
730
|
+
(localize(
|
|
731
|
+
'aboutDetail',
|
|
732
|
+
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
|
|
733
|
+
this.productService.version || 'Unknown',
|
|
734
|
+
this.productService.commit || 'Unknown',
|
|
735
|
+
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
|
|
736
|
+
navigator.userAgent
|
|
737
|
+
))
|
|
738
|
+
);
|
|
739
|
+
};
|
|
740
|
+
const detail = detailString(true);
|
|
741
|
+
const detailToCopy = detailString(false);
|
|
742
|
+
const { button } = await this.doShow(Severity.Info, this.productService.nameLong, [
|
|
743
|
+
( (localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"))),
|
|
744
|
+
( (localize('ok', "OK")))
|
|
745
|
+
], detail, 1);
|
|
746
|
+
if (button === 0) {
|
|
747
|
+
this.clipboardService.writeText(detailToCopy);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
|
|
751
|
+
const dialogDisposables = ( (new DisposableStore()));
|
|
752
|
+
const renderBody = customOptions ? (parent) => {
|
|
753
|
+
parent.classList.add(...(customOptions.classes || []));
|
|
754
|
+
customOptions.markdownDetails?.forEach(markdownDetail => {
|
|
755
|
+
const result = this.markdownRenderer.render(markdownDetail.markdown);
|
|
756
|
+
parent.appendChild(result.element);
|
|
757
|
+
result.element.classList.add(...(markdownDetail.classes || []));
|
|
758
|
+
dialogDisposables.add(result);
|
|
759
|
+
});
|
|
760
|
+
} : undefined;
|
|
761
|
+
const dialog = ( (new Dialog(this.layoutService.container, message, buttons, {
|
|
762
|
+
detail,
|
|
763
|
+
cancelId,
|
|
764
|
+
type: this.getDialogType(type),
|
|
765
|
+
keyEventProcessor: (event) => {
|
|
766
|
+
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
|
|
767
|
+
if (resolved?.commandId) {
|
|
768
|
+
if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
|
|
769
|
+
EventHelper.stop(event, true);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
renderBody,
|
|
774
|
+
icon: customOptions?.icon,
|
|
775
|
+
disableCloseAction: customOptions?.disableCloseAction,
|
|
776
|
+
buttonDetails: customOptions?.buttonDetails,
|
|
777
|
+
checkboxLabel: checkbox?.label,
|
|
778
|
+
checkboxChecked: checkbox?.checked,
|
|
779
|
+
inputs,
|
|
780
|
+
buttonStyles: defaultButtonStyles,
|
|
781
|
+
checkboxStyles: defaultCheckboxStyles,
|
|
782
|
+
inputBoxStyles: defaultInputBoxStyles,
|
|
783
|
+
dialogStyles: defaultDialogStyles
|
|
784
|
+
})));
|
|
785
|
+
dialogDisposables.add(dialog);
|
|
786
|
+
const result = await dialog.show();
|
|
787
|
+
dialogDisposables.dispose();
|
|
788
|
+
return result;
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
BrowserDialogHandler.ALLOWABLE_COMMANDS = [
|
|
792
|
+
'copy',
|
|
793
|
+
'cut',
|
|
794
|
+
'editor.action.selectAll',
|
|
795
|
+
'editor.action.clipboardCopyAction',
|
|
796
|
+
'editor.action.clipboardCutAction',
|
|
797
|
+
'editor.action.clipboardPasteAction'
|
|
798
|
+
];
|
|
799
|
+
BrowserDialogHandler = ( (__decorate([
|
|
800
|
+
( (__param(0, ILogService))),
|
|
801
|
+
( (__param(1, ILayoutService))),
|
|
802
|
+
( (__param(2, IKeybindingService))),
|
|
803
|
+
( (__param(3, IInstantiationService))),
|
|
804
|
+
( (__param(4, IProductService))),
|
|
805
|
+
( (__param(5, IClipboardService)))
|
|
806
|
+
], BrowserDialogHandler)));
|
|
807
|
+
let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
|
|
808
|
+
constructor(dialogService, logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
|
|
809
|
+
super();
|
|
810
|
+
this.dialogService = dialogService;
|
|
811
|
+
this.impl = ( (new BrowserDialogHandler(
|
|
812
|
+
logService,
|
|
813
|
+
layoutService,
|
|
814
|
+
keybindingService,
|
|
815
|
+
instantiationService,
|
|
816
|
+
productService,
|
|
817
|
+
clipboardService
|
|
818
|
+
)));
|
|
819
|
+
this.model = this.dialogService.model;
|
|
820
|
+
this._register(this.model.onWillShowDialog(() => {
|
|
821
|
+
if (!this.currentDialog) {
|
|
822
|
+
this.processDialogs();
|
|
823
|
+
}
|
|
824
|
+
}));
|
|
825
|
+
this.processDialogs();
|
|
826
|
+
}
|
|
827
|
+
async processDialogs() {
|
|
828
|
+
while (this.model.dialogs.length) {
|
|
829
|
+
this.currentDialog = this.model.dialogs[0];
|
|
830
|
+
let result = undefined;
|
|
831
|
+
if (this.currentDialog.args.confirmArgs) {
|
|
832
|
+
const args = this.currentDialog.args.confirmArgs;
|
|
833
|
+
result = await this.impl.confirm(args.confirmation);
|
|
834
|
+
}
|
|
835
|
+
else if (this.currentDialog.args.inputArgs) {
|
|
836
|
+
const args = this.currentDialog.args.inputArgs;
|
|
837
|
+
result = await this.impl.input(args.input);
|
|
838
|
+
}
|
|
839
|
+
else if (this.currentDialog.args.promptArgs) {
|
|
840
|
+
const args = this.currentDialog.args.promptArgs;
|
|
841
|
+
result = await this.impl.prompt(args.prompt);
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
await this.impl.about();
|
|
845
|
+
}
|
|
846
|
+
this.currentDialog.close(result);
|
|
847
|
+
this.currentDialog = undefined;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
DialogHandlerContribution = ( (__decorate([
|
|
852
|
+
( (__param(0, IDialogService))),
|
|
853
|
+
( (__param(1, ILogService))),
|
|
854
|
+
( (__param(2, ILayoutService))),
|
|
855
|
+
( (__param(3, IKeybindingService))),
|
|
856
|
+
( (__param(4, IInstantiationService))),
|
|
857
|
+
( (__param(5, IProductService))),
|
|
858
|
+
( (__param(6, IClipboardService)))
|
|
859
|
+
], DialogHandlerContribution)));
|
|
14
860
|
class DialogsModel extends Disposable {
|
|
15
861
|
constructor() {
|
|
16
862
|
super(...arguments);
|