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