@codingame/monaco-vscode-api 1.69.21 → 1.69.22
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/dist/dialogs.js +899 -5
- package/dist/keybindings.js +1 -1
- package/dist/layout.js +8 -898
- package/dist/missing-services.js +3 -4
- package/dist/notifications.js +6 -7
- package/dist/services2.js +1 -1
- package/dist/workspace.js +5 -5
- package/package.json +7 -7
package/dist/layout.js
CHANGED
|
@@ -1,185 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
|
|
6
|
-
import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
-
import { addDisposableListener, EventType, EventHelper, trackFocus, reset, getClientArea, $, hide, clearNode, isAncestor, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
1
|
+
import { buttonForeground, buttonSeparator, buttonBackground, buttonHoverBackground, buttonSecondaryForeground, buttonSecondaryBackground, buttonSecondaryHoverBackground, buttonBorder, progressBarBackground, resolveColorValue, editorWidgetBackground, editorWidgetForeground, widgetShadow, contrastBorder, checkboxBorder, checkboxBackground, checkboxForeground, problemsErrorIconForeground, problemsWarningIconForeground, problemsInfoIconForeground, inputBackground, inputForeground, inputBorder, textLinkForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
2
|
+
import { E as Emitter } from './workspace.js';
|
|
3
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { addDisposableListener, EventType, EventHelper, trackFocus, reset, getClientArea } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
8
5
|
import { mixin } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
9
6
|
import { Gesture, EventType as EventType$1 } from 'monaco-editor/esm/vs/base/browser/touch.js';
|
|
10
7
|
import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
|
|
8
|
+
import { CSSIcon, Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
11
9
|
import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
12
10
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
13
11
|
import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
|
|
14
|
-
import {
|
|
15
|
-
import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
|
|
16
|
-
import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
|
|
17
|
-
import { buttonForeground, buttonSeparator, buttonBackground, buttonHoverBackground, buttonSecondaryForeground, buttonSecondaryBackground, buttonSecondaryHoverBackground, buttonBorder, progressBarBackground, resolveColorValue, editorWidgetBackground, editorWidgetForeground, widgetShadow, contrastBorder, checkboxBorder, checkboxBackground, checkboxForeground, problemsErrorIconForeground, problemsWarningIconForeground, problemsInfoIconForeground, inputBackground, inputForeground, inputBorder, textLinkForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
18
|
-
import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
|
|
19
|
-
import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
20
|
-
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
21
|
-
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
22
|
-
import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
23
|
-
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
24
|
-
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
25
|
-
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
26
|
-
import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|
|
12
|
+
import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
|
|
27
13
|
import './polyfill.js';
|
|
28
14
|
import './missing-services.js';
|
|
29
15
|
import { I as IWorkbenchLayoutService } from './layoutService.js';
|
|
30
16
|
import { o as onServicesInitialized } from './tools.js';
|
|
17
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
31
18
|
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
32
19
|
import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
33
20
|
import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
34
21
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
35
|
-
const defaultOpts = {
|
|
36
|
-
inputActiveOptionBorder: ( (Color.fromHex('#007ACC00'))),
|
|
37
|
-
inputActiveOptionForeground: ( (Color.fromHex('#FFFFFF'))),
|
|
38
|
-
inputActiveOptionBackground: ( (Color.fromHex('#0E639C50')))
|
|
39
|
-
};
|
|
40
|
-
class Toggle extends Widget {
|
|
41
|
-
constructor(opts) {
|
|
42
|
-
super();
|
|
43
|
-
this._onChange = this._register(( (new Emitter())));
|
|
44
|
-
this.onChange = this._onChange.event;
|
|
45
|
-
this._onKeyDown = this._register(( (new Emitter())));
|
|
46
|
-
this.onKeyDown = this._onKeyDown.event;
|
|
47
|
-
this._opts = { ...defaultOpts, ...opts };
|
|
48
|
-
this._checked = this._opts.isChecked;
|
|
49
|
-
const classes = ['monaco-custom-toggle'];
|
|
50
|
-
if (this._opts.icon) {
|
|
51
|
-
this._icon = this._opts.icon;
|
|
52
|
-
classes.push(...CSSIcon.asClassNameArray(this._icon));
|
|
53
|
-
}
|
|
54
|
-
if (this._opts.actionClassName) {
|
|
55
|
-
classes.push(...this._opts.actionClassName.split(' '));
|
|
56
|
-
}
|
|
57
|
-
if (this._checked) {
|
|
58
|
-
classes.push('checked');
|
|
59
|
-
}
|
|
60
|
-
this.domNode = document.createElement('div');
|
|
61
|
-
this.domNode.title = this._opts.title;
|
|
62
|
-
this.domNode.classList.add(...classes);
|
|
63
|
-
if (!this._opts.notFocusable) {
|
|
64
|
-
this.domNode.tabIndex = 0;
|
|
65
|
-
}
|
|
66
|
-
this.domNode.setAttribute('role', 'checkbox');
|
|
67
|
-
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
68
|
-
this.domNode.setAttribute('aria-label', this._opts.title);
|
|
69
|
-
this.applyStyles();
|
|
70
|
-
this.onclick(this.domNode, (ev) => {
|
|
71
|
-
if (this.enabled) {
|
|
72
|
-
this.checked = !this._checked;
|
|
73
|
-
this._onChange.fire(false);
|
|
74
|
-
ev.preventDefault();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.ignoreGesture(this.domNode);
|
|
78
|
-
this.onkeydown(this.domNode, (keyboardEvent) => {
|
|
79
|
-
if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
|
|
80
|
-
this.checked = !this._checked;
|
|
81
|
-
this._onChange.fire(true);
|
|
82
|
-
keyboardEvent.preventDefault();
|
|
83
|
-
keyboardEvent.stopPropagation();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this._onKeyDown.fire(keyboardEvent);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
get enabled() {
|
|
90
|
-
return this.domNode.getAttribute('aria-disabled') !== 'true';
|
|
91
|
-
}
|
|
92
|
-
focus() {
|
|
93
|
-
this.domNode.focus();
|
|
94
|
-
}
|
|
95
|
-
get checked() {
|
|
96
|
-
return this._checked;
|
|
97
|
-
}
|
|
98
|
-
set checked(newIsChecked) {
|
|
99
|
-
this._checked = newIsChecked;
|
|
100
|
-
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
101
|
-
this.domNode.classList.toggle('checked', this._checked);
|
|
102
|
-
this.applyStyles();
|
|
103
|
-
}
|
|
104
|
-
setIcon(icon) {
|
|
105
|
-
if (this._icon) {
|
|
106
|
-
this.domNode.classList.remove(...CSSIcon.asClassNameArray(this._icon));
|
|
107
|
-
}
|
|
108
|
-
this._icon = icon;
|
|
109
|
-
if (this._icon) {
|
|
110
|
-
this.domNode.classList.add(...CSSIcon.asClassNameArray(this._icon));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
width() {
|
|
114
|
-
return 2 + 2 + 2 + 16 ;
|
|
115
|
-
}
|
|
116
|
-
style(styles) {
|
|
117
|
-
if (styles.inputActiveOptionBorder) {
|
|
118
|
-
this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
|
|
119
|
-
}
|
|
120
|
-
if (styles.inputActiveOptionForeground) {
|
|
121
|
-
this._opts.inputActiveOptionForeground = styles.inputActiveOptionForeground;
|
|
122
|
-
}
|
|
123
|
-
if (styles.inputActiveOptionBackground) {
|
|
124
|
-
this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
|
|
125
|
-
}
|
|
126
|
-
this.applyStyles();
|
|
127
|
-
}
|
|
128
|
-
applyStyles() {
|
|
129
|
-
if (this.domNode) {
|
|
130
|
-
this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? ( (this._opts.inputActiveOptionBorder.toString())) : '';
|
|
131
|
-
this.domNode.style.color = this._checked && this._opts.inputActiveOptionForeground ? ( (this._opts.inputActiveOptionForeground.toString())) : 'inherit';
|
|
132
|
-
this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? ( (this._opts.inputActiveOptionBackground.toString())) : '';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
enable() {
|
|
136
|
-
this.domNode.setAttribute('aria-disabled', String(false));
|
|
137
|
-
}
|
|
138
|
-
disable() {
|
|
139
|
-
this.domNode.setAttribute('aria-disabled', String(true));
|
|
140
|
-
}
|
|
141
|
-
setTitle(newTitle) {
|
|
142
|
-
this.domNode.title = newTitle;
|
|
143
|
-
this.domNode.setAttribute('aria-label', newTitle);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
class Checkbox extends Widget {
|
|
147
|
-
constructor(title, isChecked) {
|
|
148
|
-
super();
|
|
149
|
-
this.title = title;
|
|
150
|
-
this.isChecked = isChecked;
|
|
151
|
-
this.checkbox = ( (new Toggle(
|
|
152
|
-
{ title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox' }
|
|
153
|
-
)));
|
|
154
|
-
this.domNode = this.checkbox.domNode;
|
|
155
|
-
this.styles = {};
|
|
156
|
-
this.checkbox.onChange(() => {
|
|
157
|
-
this.applyStyles();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
get checked() {
|
|
161
|
-
return this.checkbox.checked;
|
|
162
|
-
}
|
|
163
|
-
set checked(newIsChecked) {
|
|
164
|
-
this.checkbox.checked = newIsChecked;
|
|
165
|
-
this.applyStyles();
|
|
166
|
-
}
|
|
167
|
-
focus() {
|
|
168
|
-
this.domNode.focus();
|
|
169
|
-
}
|
|
170
|
-
hasFocus() {
|
|
171
|
-
return this.domNode === document.activeElement;
|
|
172
|
-
}
|
|
173
|
-
style(styles) {
|
|
174
|
-
this.styles = styles;
|
|
175
|
-
this.applyStyles();
|
|
176
|
-
}
|
|
177
|
-
applyStyles() {
|
|
178
|
-
this.domNode.style.color = this.styles.checkboxForeground ? ( (this.styles.checkboxForeground.toString())) : '';
|
|
179
|
-
this.domNode.style.backgroundColor = this.styles.checkboxBackground ? ( (this.styles.checkboxBackground.toString())) : '';
|
|
180
|
-
this.domNode.style.borderColor = this.styles.checkboxBorder ? ( (this.styles.checkboxBorder.toString())) : '';
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
22
|
function computeStyles(theme, styleMap) {
|
|
184
23
|
const styles = Object.create(null);
|
|
185
24
|
for (const key in styleMap) {
|
|
@@ -552,735 +391,6 @@ class ButtonBar extends Disposable {
|
|
|
552
391
|
}));
|
|
553
392
|
}
|
|
554
393
|
}
|
|
555
|
-
function mnemonicButtonLabel(label, forceDisableMnemonics) {
|
|
556
|
-
if (isMacintosh || forceDisableMnemonics) {
|
|
557
|
-
return label.replace(/\(&&\w\)|&&/g, '');
|
|
558
|
-
}
|
|
559
|
-
if (isWindows) {
|
|
560
|
-
return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
|
|
561
|
-
}
|
|
562
|
-
return label.replace(/&&/g, '_');
|
|
563
|
-
}
|
|
564
|
-
var css = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Dialog: Modal Block */\n.monaco-dialog-modal-block {\n\tposition: fixed;\n\theight: 100%;\n\twidth: 100%;\n\tleft:0;\n\ttop:0;\n\tz-index: 2600;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n}\n\n.monaco-dialog-modal-block.dimmed {\n\tbackground: rgba(0, 0, 0, 0.3);\n}\n\n/** Dialog: Container */\n.monaco-dialog-box {\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n\twidth: min-content;\n\tmin-width: 500px;\n\tmax-width: 90vw;\n\tmin-height: 75px;\n\tpadding: 10px;\n\ttransform: translate3d(0px, 0px, 0px);\n}\n\n/** Dialog: Title Actions Row */\n.monaco-dialog-box .dialog-toolbar-row {\n\theight: 22px;\n\tpadding-bottom: 4px;\n}\n\n.monaco-dialog-box .dialog-toolbar-row .actions-container {\n\tjustify-content: flex-end;\n}\n\n/** Dialog: Message Row */\n.monaco-dialog-box .dialog-message-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n\talign-items: center;\n\tpadding: 0 10px;\n}\n\n.monaco-dialog-box .dialog-message-row > .dialog-icon.codicon {\n\tflex: 0 0 48px;\n\theight: 48px;\n\talign-self: baseline;\n\tfont-size: 48px;\n}\n\n/** Dialog: Message Container */\n.monaco-dialog-box .dialog-message-row .dialog-message-container {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tpadding-left: 24px;\n\tuser-select: text;\n\t-webkit-user-select: text;\n\t-ms-user-select: text;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\twhite-space: normal;\n}\n\n/** Dialog: Message */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message {\n\tline-height: 22px;\n\tfont-size: 18px;\n\tflex: 1; /* let the message always grow */\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\tmin-height: 48px; /* matches icon height */\n\tmargin-bottom: 8px;\n\tdisplay: flex;\n\talign-items: center;\n}\n\n/** Dialog: Details */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail {\n\tline-height: 22px;\n\tflex: 1; /* let the message always grow */\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n/** Dialog: Checkbox */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message {\n\tcursor: pointer;\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n/** Dialog: Input */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox {\n\tflex: 1;\n}\n\n/** Dialog: File Path */\n.monaco-dialog-box code {\n\tfont-family: var(--monaco-monospace-font);\n}\n\n/** Dialog: Buttons Row */\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\talign-items: center;\n\tpadding-right: 1px;\n\toverflow: hidden; /* buttons row should never overflow */\n}\n\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\twhite-space: nowrap;\n\tpadding: 20px 10px 10px;\n}\n\n/** Dialog: Buttons */\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons {\n\tdisplay: flex;\n\twidth: 100%;\n\tjustify-content: flex-end;\n\toverflow: hidden;\n\tmargin-left: 67px; /* for long buttons, force align with text */\n}\n\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons > .monaco-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n\toutline-offset: 2px !important;\n}\n";
|
|
565
|
-
n(css,{});
|
|
566
|
-
class Dialog extends Disposable {
|
|
567
|
-
constructor(container, message, buttons, options) {
|
|
568
|
-
super();
|
|
569
|
-
this.container = container;
|
|
570
|
-
this.message = message;
|
|
571
|
-
this.options = options;
|
|
572
|
-
this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
|
|
573
|
-
this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
|
|
574
|
-
this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
|
|
575
|
-
this.element.setAttribute('role', 'dialog');
|
|
576
|
-
this.element.tabIndex = -1;
|
|
577
|
-
hide(this.element);
|
|
578
|
-
if (Array.isArray(buttons) && buttons.length > 0) {
|
|
579
|
-
this.buttons = buttons;
|
|
580
|
-
}
|
|
581
|
-
else if (!this.options.disableDefaultAction) {
|
|
582
|
-
this.buttons = [( (localize('ok', "OK")))];
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
this.buttons = [];
|
|
586
|
-
}
|
|
587
|
-
const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
|
|
588
|
-
this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
|
|
589
|
-
const messageRowElement = this.element.appendChild($('.dialog-message-row'));
|
|
590
|
-
this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
|
|
591
|
-
this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
|
|
592
|
-
this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
|
|
593
|
-
if (this.options.detail || this.options.renderBody) {
|
|
594
|
-
const messageElement = this.messageContainer.appendChild($('.dialog-message'));
|
|
595
|
-
const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
|
|
596
|
-
messageTextElement.innerText = this.message;
|
|
597
|
-
}
|
|
598
|
-
this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
|
|
599
|
-
if (this.options.detail || !this.options.renderBody) {
|
|
600
|
-
this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
this.messageDetailElement.style.display = 'none';
|
|
604
|
-
}
|
|
605
|
-
if (this.options.renderBody) {
|
|
606
|
-
const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
|
|
607
|
-
this.options.renderBody(customBody);
|
|
608
|
-
for (const el of this.messageContainer.querySelectorAll('a')) {
|
|
609
|
-
el.tabIndex = 0;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
if (this.options.inputs) {
|
|
613
|
-
this.inputs = this.options.inputs.map(input => {
|
|
614
|
-
const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
|
|
615
|
-
const inputBox = this._register(( (new InputBox(inputRowElement, undefined, {
|
|
616
|
-
placeholder: input.placeholder,
|
|
617
|
-
type: input.type ?? 'text',
|
|
618
|
-
}))));
|
|
619
|
-
if (input.value) {
|
|
620
|
-
inputBox.value = input.value;
|
|
621
|
-
}
|
|
622
|
-
return inputBox;
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
this.inputs = [];
|
|
627
|
-
}
|
|
628
|
-
if (this.options.checkboxLabel) {
|
|
629
|
-
const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
|
|
630
|
-
const checkbox = this.checkbox = this._register(( (new Checkbox(this.options.checkboxLabel, !!this.options.checkboxChecked))));
|
|
631
|
-
checkboxRowElement.appendChild(checkbox.domNode);
|
|
632
|
-
const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
|
|
633
|
-
checkboxMessageElement.innerText = this.options.checkboxLabel;
|
|
634
|
-
this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
|
|
635
|
-
}
|
|
636
|
-
const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
|
|
637
|
-
this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
|
|
638
|
-
}
|
|
639
|
-
getIconAriaLabel() {
|
|
640
|
-
const typeLabel = ( (localize('dialogInfoMessage', 'Info')));
|
|
641
|
-
return typeLabel;
|
|
642
|
-
}
|
|
643
|
-
updateMessage(message) {
|
|
644
|
-
this.messageDetailElement.innerText = message;
|
|
645
|
-
}
|
|
646
|
-
async show() {
|
|
647
|
-
this.focusToReturn = document.activeElement;
|
|
648
|
-
return (
|
|
649
|
-
(new Promise((resolve) => {
|
|
650
|
-
clearNode(this.buttonsContainer);
|
|
651
|
-
const buttonBar = this.buttonBar = this._register(( (new ButtonBar(this.buttonsContainer))));
|
|
652
|
-
const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
|
|
653
|
-
buttonMap.forEach((entry, index) => {
|
|
654
|
-
const primary = buttonMap[index].index === 0;
|
|
655
|
-
const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary })) : this._register(buttonBar.addButton({ title: true, secondary: !primary }));
|
|
656
|
-
button.label = mnemonicButtonLabel(buttonMap[index].label, true);
|
|
657
|
-
if (button instanceof ButtonWithDescription) {
|
|
658
|
-
button.description = this.options.buttonDetails[buttonMap[index].index];
|
|
659
|
-
}
|
|
660
|
-
this._register(button.onDidClick(e => {
|
|
661
|
-
if (e) {
|
|
662
|
-
EventHelper.stop(e);
|
|
663
|
-
}
|
|
664
|
-
resolve({
|
|
665
|
-
button: buttonMap[index].index,
|
|
666
|
-
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
667
|
-
values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
|
|
668
|
-
});
|
|
669
|
-
}));
|
|
670
|
-
});
|
|
671
|
-
this._register(addDisposableListener(window, 'keydown', e => {
|
|
672
|
-
const evt = ( (new StandardKeyboardEvent(e)));
|
|
673
|
-
if (evt.equals(512 )) {
|
|
674
|
-
evt.preventDefault();
|
|
675
|
-
}
|
|
676
|
-
if (evt.equals(3 )) {
|
|
677
|
-
if (this.inputs.some(input => input.hasFocus())) {
|
|
678
|
-
EventHelper.stop(e);
|
|
679
|
-
resolve({
|
|
680
|
-
button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
|
|
681
|
-
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
|
|
682
|
-
values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
if (evt.equals(10 )) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
let eventHandled = false;
|
|
691
|
-
if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
|
|
692
|
-
const focusableElements = [];
|
|
693
|
-
let focusedIndex = -1;
|
|
694
|
-
if (this.messageContainer) {
|
|
695
|
-
const links = this.messageContainer.querySelectorAll('a');
|
|
696
|
-
for (const link of links) {
|
|
697
|
-
focusableElements.push(link);
|
|
698
|
-
if (link === document.activeElement) {
|
|
699
|
-
focusedIndex = focusableElements.length - 1;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
for (const input of this.inputs) {
|
|
704
|
-
focusableElements.push(input);
|
|
705
|
-
if (input.hasFocus()) {
|
|
706
|
-
focusedIndex = focusableElements.length - 1;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
if (this.checkbox) {
|
|
710
|
-
focusableElements.push(this.checkbox);
|
|
711
|
-
if (this.checkbox.hasFocus()) {
|
|
712
|
-
focusedIndex = focusableElements.length - 1;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
if (this.buttonBar) {
|
|
716
|
-
for (const button of this.buttonBar.buttons) {
|
|
717
|
-
focusableElements.push(button);
|
|
718
|
-
if (button.hasFocus()) {
|
|
719
|
-
focusedIndex = focusableElements.length - 1;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
if (evt.equals(2 ) || evt.equals(17 )) {
|
|
724
|
-
if (focusedIndex === -1) {
|
|
725
|
-
focusedIndex = 0;
|
|
726
|
-
}
|
|
727
|
-
const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
|
|
728
|
-
focusableElements[newFocusedIndex].focus();
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
if (focusedIndex === -1) {
|
|
732
|
-
focusedIndex = focusableElements.length;
|
|
733
|
-
}
|
|
734
|
-
let newFocusedIndex = focusedIndex - 1;
|
|
735
|
-
if (newFocusedIndex === -1) {
|
|
736
|
-
newFocusedIndex = focusableElements.length - 1;
|
|
737
|
-
}
|
|
738
|
-
focusableElements[newFocusedIndex].focus();
|
|
739
|
-
}
|
|
740
|
-
eventHandled = true;
|
|
741
|
-
}
|
|
742
|
-
if (eventHandled) {
|
|
743
|
-
EventHelper.stop(e, true);
|
|
744
|
-
}
|
|
745
|
-
else if (this.options.keyEventProcessor) {
|
|
746
|
-
this.options.keyEventProcessor(evt);
|
|
747
|
-
}
|
|
748
|
-
}, true));
|
|
749
|
-
this._register(addDisposableListener(window, 'keyup', e => {
|
|
750
|
-
EventHelper.stop(e, true);
|
|
751
|
-
const evt = ( (new StandardKeyboardEvent(e)));
|
|
752
|
-
if (!this.options.disableCloseAction && evt.equals(9 )) {
|
|
753
|
-
resolve({
|
|
754
|
-
button: this.options.cancelId || 0,
|
|
755
|
-
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
}, true));
|
|
759
|
-
this._register(addDisposableListener(this.element, 'focusout', e => {
|
|
760
|
-
if (!!e.relatedTarget && !!this.element) {
|
|
761
|
-
if (!isAncestor(e.relatedTarget, this.element)) {
|
|
762
|
-
this.focusToReturn = e.relatedTarget;
|
|
763
|
-
if (e.target) {
|
|
764
|
-
e.target.focus();
|
|
765
|
-
EventHelper.stop(e, true);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}, false));
|
|
770
|
-
const spinModifierClassName = 'codicon-modifier-spin';
|
|
771
|
-
this.iconElement.classList.remove(...Codicon.dialogError.classNamesArray, ...Codicon.dialogWarning.classNamesArray, ...Codicon.dialogInfo.classNamesArray, ...Codicon.loading.classNamesArray, spinModifierClassName);
|
|
772
|
-
if (this.options.icon) {
|
|
773
|
-
this.iconElement.classList.add(...this.options.icon.classNamesArray);
|
|
774
|
-
}
|
|
775
|
-
else {
|
|
776
|
-
switch (this.options.type) {
|
|
777
|
-
case 'error':
|
|
778
|
-
this.iconElement.classList.add(...Codicon.dialogError.classNamesArray);
|
|
779
|
-
break;
|
|
780
|
-
case 'warning':
|
|
781
|
-
this.iconElement.classList.add(...Codicon.dialogWarning.classNamesArray);
|
|
782
|
-
break;
|
|
783
|
-
case 'pending':
|
|
784
|
-
this.iconElement.classList.add(...Codicon.loading.classNamesArray, spinModifierClassName);
|
|
785
|
-
break;
|
|
786
|
-
case 'none':
|
|
787
|
-
case 'info':
|
|
788
|
-
case 'question':
|
|
789
|
-
default:
|
|
790
|
-
this.iconElement.classList.add(...Codicon.dialogInfo.classNamesArray);
|
|
791
|
-
break;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (!this.options.disableCloseAction) {
|
|
795
|
-
const actionBar = this._register(( (new ActionBar(this.toolbarContainer, {}))));
|
|
796
|
-
const action = this._register(( (new Action(
|
|
797
|
-
'dialog.close',
|
|
798
|
-
(localize('dialogClose', "Close Dialog")),
|
|
799
|
-
Codicon.dialogClose.classNames,
|
|
800
|
-
true,
|
|
801
|
-
async () => {
|
|
802
|
-
resolve({
|
|
803
|
-
button: this.options.cancelId || 0,
|
|
804
|
-
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
))));
|
|
808
|
-
actionBar.push(action, { icon: true, label: false, });
|
|
809
|
-
}
|
|
810
|
-
this.applyStyles();
|
|
811
|
-
this.element.setAttribute('aria-modal', 'true');
|
|
812
|
-
this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
|
|
813
|
-
this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
|
|
814
|
-
show(this.element);
|
|
815
|
-
if (this.inputs.length > 0) {
|
|
816
|
-
this.inputs[0].focus();
|
|
817
|
-
this.inputs[0].select();
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
buttonMap.forEach((value, index) => {
|
|
821
|
-
if (value.index === 0) {
|
|
822
|
-
buttonBar.buttons[index].focus();
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
}))
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
applyStyles() {
|
|
830
|
-
if (this.styles) {
|
|
831
|
-
const style = this.styles;
|
|
832
|
-
const fgColor = style.dialogForeground;
|
|
833
|
-
const bgColor = style.dialogBackground;
|
|
834
|
-
const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
|
|
835
|
-
const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
|
|
836
|
-
const linkFgColor = style.textLinkForeground;
|
|
837
|
-
this.shadowElement.style.boxShadow = shadowColor;
|
|
838
|
-
this.element.style.color = fgColor?.toString() ?? '';
|
|
839
|
-
this.element.style.backgroundColor = bgColor?.toString() ?? '';
|
|
840
|
-
this.element.style.border = border;
|
|
841
|
-
this.buttonBar?.buttons.forEach(button => button.style(style));
|
|
842
|
-
this.checkbox?.style(style);
|
|
843
|
-
if (fgColor && bgColor) {
|
|
844
|
-
const messageDetailColor = ( (fgColor.transparent(.9)));
|
|
845
|
-
this.messageDetailElement.style.color = ( (messageDetailColor.makeOpaque(bgColor).toString()));
|
|
846
|
-
}
|
|
847
|
-
if (linkFgColor) {
|
|
848
|
-
for (const el of this.messageContainer.getElementsByTagName('a')) {
|
|
849
|
-
el.style.color = ( (linkFgColor.toString()));
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
let color;
|
|
853
|
-
switch (this.options.type) {
|
|
854
|
-
case 'error':
|
|
855
|
-
color = style.errorIconForeground;
|
|
856
|
-
break;
|
|
857
|
-
case 'warning':
|
|
858
|
-
color = style.warningIconForeground;
|
|
859
|
-
break;
|
|
860
|
-
default:
|
|
861
|
-
color = style.infoIconForeground;
|
|
862
|
-
break;
|
|
863
|
-
}
|
|
864
|
-
if (color) {
|
|
865
|
-
this.iconElement.style.color = ( (color.toString()));
|
|
866
|
-
}
|
|
867
|
-
for (const input of this.inputs) {
|
|
868
|
-
input.style(style);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
style(style) {
|
|
873
|
-
this.styles = style;
|
|
874
|
-
this.applyStyles();
|
|
875
|
-
}
|
|
876
|
-
dispose() {
|
|
877
|
-
super.dispose();
|
|
878
|
-
if (this.modalElement) {
|
|
879
|
-
this.modalElement.remove();
|
|
880
|
-
this.modalElement = undefined;
|
|
881
|
-
}
|
|
882
|
-
if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
|
|
883
|
-
this.focusToReturn.focus();
|
|
884
|
-
this.focusToReturn = undefined;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
rearrangeButtons(buttons, cancelId) {
|
|
888
|
-
const buttonMap = [];
|
|
889
|
-
if (buttons.length === 0) {
|
|
890
|
-
return buttonMap;
|
|
891
|
-
}
|
|
892
|
-
buttons.forEach((button, index) => {
|
|
893
|
-
buttonMap.push({ label: button, index });
|
|
894
|
-
});
|
|
895
|
-
if (isMacintosh || isLinux) {
|
|
896
|
-
if (cancelId !== undefined && cancelId < buttons.length) {
|
|
897
|
-
const cancelButton = buttonMap.splice(cancelId, 1)[0];
|
|
898
|
-
buttonMap.reverse();
|
|
899
|
-
buttonMap.splice(buttonMap.length - 1, 0, cancelButton);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return buttonMap;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
const minute = 60;
|
|
906
|
-
const hour = minute * 60;
|
|
907
|
-
const day = hour * 24;
|
|
908
|
-
const week = day * 7;
|
|
909
|
-
const month = day * 30;
|
|
910
|
-
const year = day * 365;
|
|
911
|
-
function fromNow(date, appendAgoLabel, useFullTimeWords) {
|
|
912
|
-
if (typeof date !== 'number') {
|
|
913
|
-
date = date.getTime();
|
|
914
|
-
}
|
|
915
|
-
const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
|
|
916
|
-
if (seconds < -30) {
|
|
917
|
-
return (
|
|
918
|
-
(localize(
|
|
919
|
-
'date.fromNow.in',
|
|
920
|
-
'in {0}',
|
|
921
|
-
fromNow(( (new Date())).getTime() + seconds * 1000, false)
|
|
922
|
-
))
|
|
923
|
-
);
|
|
924
|
-
}
|
|
925
|
-
if (seconds < 30) {
|
|
926
|
-
return (
|
|
927
|
-
(localize('date.fromNow.now', 'now'))
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
let value;
|
|
931
|
-
if (seconds < minute) {
|
|
932
|
-
value = seconds;
|
|
933
|
-
if (appendAgoLabel) {
|
|
934
|
-
if (value === 1) {
|
|
935
|
-
return useFullTimeWords
|
|
936
|
-
? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
|
|
937
|
-
: ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
|
|
938
|
-
}
|
|
939
|
-
else {
|
|
940
|
-
return useFullTimeWords
|
|
941
|
-
? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
|
|
942
|
-
: ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
else {
|
|
946
|
-
if (value === 1) {
|
|
947
|
-
return useFullTimeWords
|
|
948
|
-
? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
|
|
949
|
-
: ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
|
|
950
|
-
}
|
|
951
|
-
else {
|
|
952
|
-
return useFullTimeWords
|
|
953
|
-
? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
|
|
954
|
-
: ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
if (seconds < hour) {
|
|
959
|
-
value = Math.floor(seconds / minute);
|
|
960
|
-
if (appendAgoLabel) {
|
|
961
|
-
if (value === 1) {
|
|
962
|
-
return useFullTimeWords
|
|
963
|
-
? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
|
|
964
|
-
: ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
|
|
965
|
-
}
|
|
966
|
-
else {
|
|
967
|
-
return useFullTimeWords
|
|
968
|
-
? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
|
|
969
|
-
: ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
else {
|
|
973
|
-
if (value === 1) {
|
|
974
|
-
return useFullTimeWords
|
|
975
|
-
? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
|
|
976
|
-
: ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
|
|
977
|
-
}
|
|
978
|
-
else {
|
|
979
|
-
return useFullTimeWords
|
|
980
|
-
? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
|
|
981
|
-
: ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
if (seconds < day) {
|
|
986
|
-
value = Math.floor(seconds / hour);
|
|
987
|
-
if (appendAgoLabel) {
|
|
988
|
-
if (value === 1) {
|
|
989
|
-
return useFullTimeWords
|
|
990
|
-
? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
|
|
991
|
-
: ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
return useFullTimeWords
|
|
995
|
-
? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
|
|
996
|
-
: ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
if (value === 1) {
|
|
1001
|
-
return useFullTimeWords
|
|
1002
|
-
? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
|
|
1003
|
-
: ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
|
|
1004
|
-
}
|
|
1005
|
-
else {
|
|
1006
|
-
return useFullTimeWords
|
|
1007
|
-
? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
|
|
1008
|
-
: ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
if (seconds < week) {
|
|
1013
|
-
value = Math.floor(seconds / day);
|
|
1014
|
-
if (appendAgoLabel) {
|
|
1015
|
-
return value === 1
|
|
1016
|
-
? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
|
|
1017
|
-
: ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
return value === 1
|
|
1021
|
-
? ( (localize('date.fromNow.days.singular', '{0} day', value)))
|
|
1022
|
-
: ( (localize('date.fromNow.days.plural', '{0} days', value)));
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
if (seconds < month) {
|
|
1026
|
-
value = Math.floor(seconds / week);
|
|
1027
|
-
if (appendAgoLabel) {
|
|
1028
|
-
if (value === 1) {
|
|
1029
|
-
return useFullTimeWords
|
|
1030
|
-
? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
|
|
1031
|
-
: ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
|
|
1032
|
-
}
|
|
1033
|
-
else {
|
|
1034
|
-
return useFullTimeWords
|
|
1035
|
-
? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
|
|
1036
|
-
: ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
if (value === 1) {
|
|
1041
|
-
return useFullTimeWords
|
|
1042
|
-
? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
|
|
1043
|
-
: ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
|
|
1044
|
-
}
|
|
1045
|
-
else {
|
|
1046
|
-
return useFullTimeWords
|
|
1047
|
-
? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
|
|
1048
|
-
: ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
if (seconds < year) {
|
|
1053
|
-
value = Math.floor(seconds / month);
|
|
1054
|
-
if (appendAgoLabel) {
|
|
1055
|
-
if (value === 1) {
|
|
1056
|
-
return useFullTimeWords
|
|
1057
|
-
? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
|
|
1058
|
-
: ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
|
|
1059
|
-
}
|
|
1060
|
-
else {
|
|
1061
|
-
return useFullTimeWords
|
|
1062
|
-
? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
|
|
1063
|
-
: ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
else {
|
|
1067
|
-
if (value === 1) {
|
|
1068
|
-
return useFullTimeWords
|
|
1069
|
-
? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
|
|
1070
|
-
: ( (localize('date.fromNow.months.singular', '{0} mo', value)));
|
|
1071
|
-
}
|
|
1072
|
-
else {
|
|
1073
|
-
return useFullTimeWords
|
|
1074
|
-
? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
|
|
1075
|
-
: ( (localize('date.fromNow.months.plural', '{0} mos', value)));
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
value = Math.floor(seconds / year);
|
|
1080
|
-
if (appendAgoLabel) {
|
|
1081
|
-
if (value === 1) {
|
|
1082
|
-
return useFullTimeWords
|
|
1083
|
-
? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
|
|
1084
|
-
: ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
|
|
1085
|
-
}
|
|
1086
|
-
else {
|
|
1087
|
-
return useFullTimeWords
|
|
1088
|
-
? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
|
|
1089
|
-
: ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
else {
|
|
1093
|
-
if (value === 1) {
|
|
1094
|
-
return useFullTimeWords
|
|
1095
|
-
? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
|
|
1096
|
-
: ( (localize('date.fromNow.years.singular', '{0} yr', value)));
|
|
1097
|
-
}
|
|
1098
|
-
else {
|
|
1099
|
-
return useFullTimeWords
|
|
1100
|
-
? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
|
|
1101
|
-
: ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
let BrowserDialogHandler = class BrowserDialogHandler {
|
|
1106
|
-
constructor(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
|
|
1107
|
-
this.logService = logService;
|
|
1108
|
-
this.layoutService = layoutService;
|
|
1109
|
-
this.themeService = themeService;
|
|
1110
|
-
this.keybindingService = keybindingService;
|
|
1111
|
-
this.instantiationService = instantiationService;
|
|
1112
|
-
this.productService = productService;
|
|
1113
|
-
this.clipboardService = clipboardService;
|
|
1114
|
-
this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
1115
|
-
}
|
|
1116
|
-
async confirm(confirmation) {
|
|
1117
|
-
this.logService.trace('DialogService#confirm', confirmation.message);
|
|
1118
|
-
const buttons = [];
|
|
1119
|
-
if (confirmation.primaryButton) {
|
|
1120
|
-
buttons.push(confirmation.primaryButton);
|
|
1121
|
-
}
|
|
1122
|
-
else {
|
|
1123
|
-
buttons.push(( (localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"))));
|
|
1124
|
-
}
|
|
1125
|
-
if (confirmation.secondaryButton) {
|
|
1126
|
-
buttons.push(confirmation.secondaryButton);
|
|
1127
|
-
}
|
|
1128
|
-
else if (typeof confirmation.secondaryButton === 'undefined') {
|
|
1129
|
-
buttons.push(( (localize('cancelButton', "Cancel"))));
|
|
1130
|
-
}
|
|
1131
|
-
const result = await this.doShow(confirmation.type, confirmation.message, buttons, confirmation.detail, 1, confirmation.checkbox);
|
|
1132
|
-
return { confirmed: result.button === 0, checkboxChecked: result.checkboxChecked };
|
|
1133
|
-
}
|
|
1134
|
-
getDialogType(severity) {
|
|
1135
|
-
return (severity === Severity.Info) ? 'question' : (severity === Severity.Error) ? 'error' : (severity === Severity.Warning) ? 'warning' : 'none';
|
|
1136
|
-
}
|
|
1137
|
-
async show(severity, message, buttons, options) {
|
|
1138
|
-
this.logService.trace('DialogService#show', message);
|
|
1139
|
-
const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, undefined, typeof options?.custom === 'object' ? options.custom : undefined);
|
|
1140
|
-
return {
|
|
1141
|
-
choice: result.button,
|
|
1142
|
-
checkboxChecked: result.checkboxChecked
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
|
-
async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
|
|
1146
|
-
const dialogDisposables = ( (new DisposableStore()));
|
|
1147
|
-
const renderBody = customOptions ? (parent) => {
|
|
1148
|
-
parent.classList.add(...(customOptions.classes || []));
|
|
1149
|
-
customOptions.markdownDetails?.forEach(markdownDetail => {
|
|
1150
|
-
const result = this.markdownRenderer.render(markdownDetail.markdown);
|
|
1151
|
-
parent.appendChild(result.element);
|
|
1152
|
-
result.element.classList.add(...(markdownDetail.classes || []));
|
|
1153
|
-
dialogDisposables.add(result);
|
|
1154
|
-
});
|
|
1155
|
-
} : undefined;
|
|
1156
|
-
const dialog = ( (new Dialog(this.layoutService.container, message, buttons, {
|
|
1157
|
-
detail,
|
|
1158
|
-
cancelId,
|
|
1159
|
-
type,
|
|
1160
|
-
keyEventProcessor: (event) => {
|
|
1161
|
-
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
|
|
1162
|
-
if (resolved?.commandId) {
|
|
1163
|
-
if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
|
|
1164
|
-
EventHelper.stop(event, true);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
renderBody,
|
|
1169
|
-
icon: customOptions?.icon,
|
|
1170
|
-
disableCloseAction: customOptions?.disableCloseAction,
|
|
1171
|
-
buttonDetails: customOptions?.buttonDetails,
|
|
1172
|
-
checkboxLabel: checkbox?.label,
|
|
1173
|
-
checkboxChecked: checkbox?.checked,
|
|
1174
|
-
inputs
|
|
1175
|
-
})));
|
|
1176
|
-
dialogDisposables.add(dialog);
|
|
1177
|
-
dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
|
|
1178
|
-
const result = await dialog.show();
|
|
1179
|
-
dialogDisposables.dispose();
|
|
1180
|
-
return result;
|
|
1181
|
-
}
|
|
1182
|
-
async input(severity, message, buttons, inputs, options) {
|
|
1183
|
-
this.logService.trace('DialogService#input', message);
|
|
1184
|
-
const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, inputs);
|
|
1185
|
-
return {
|
|
1186
|
-
choice: result.button,
|
|
1187
|
-
checkboxChecked: result.checkboxChecked,
|
|
1188
|
-
values: result.values
|
|
1189
|
-
};
|
|
1190
|
-
}
|
|
1191
|
-
async about() {
|
|
1192
|
-
const detailString = (useAgo) => {
|
|
1193
|
-
return (
|
|
1194
|
-
(localize(
|
|
1195
|
-
'aboutDetail',
|
|
1196
|
-
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
|
|
1197
|
-
this.productService.version || 'Unknown',
|
|
1198
|
-
this.productService.commit || 'Unknown',
|
|
1199
|
-
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
|
|
1200
|
-
navigator.userAgent
|
|
1201
|
-
))
|
|
1202
|
-
);
|
|
1203
|
-
};
|
|
1204
|
-
const detail = detailString(true);
|
|
1205
|
-
const detailToCopy = detailString(false);
|
|
1206
|
-
const { choice } = await this.show(Severity.Info, this.productService.nameLong, [( (localize('copy', "Copy"))), ( (localize('ok', "OK")))], { detail, cancelId: 1 });
|
|
1207
|
-
if (choice === 0) {
|
|
1208
|
-
this.clipboardService.writeText(detailToCopy);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
|
-
BrowserDialogHandler.ALLOWABLE_COMMANDS = [
|
|
1213
|
-
'copy',
|
|
1214
|
-
'cut',
|
|
1215
|
-
'editor.action.selectAll',
|
|
1216
|
-
'editor.action.clipboardCopyAction',
|
|
1217
|
-
'editor.action.clipboardCutAction',
|
|
1218
|
-
'editor.action.clipboardPasteAction'
|
|
1219
|
-
];
|
|
1220
|
-
BrowserDialogHandler = ( (__decorate([
|
|
1221
|
-
( (__param(0, ILogService))),
|
|
1222
|
-
( (__param(1, ILayoutService))),
|
|
1223
|
-
( (__param(2, IThemeService))),
|
|
1224
|
-
( (__param(3, IKeybindingService))),
|
|
1225
|
-
( (__param(4, IInstantiationService))),
|
|
1226
|
-
( (__param(5, IProductService))),
|
|
1227
|
-
( (__param(6, IClipboardService)))
|
|
1228
|
-
], BrowserDialogHandler)));
|
|
1229
|
-
let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
|
|
1230
|
-
constructor(dialogService, logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
|
|
1231
|
-
super();
|
|
1232
|
-
this.dialogService = dialogService;
|
|
1233
|
-
this.impl = ( (new BrowserDialogHandler(
|
|
1234
|
-
logService,
|
|
1235
|
-
layoutService,
|
|
1236
|
-
themeService,
|
|
1237
|
-
keybindingService,
|
|
1238
|
-
instantiationService,
|
|
1239
|
-
productService,
|
|
1240
|
-
clipboardService
|
|
1241
|
-
)));
|
|
1242
|
-
this.model = this.dialogService.model;
|
|
1243
|
-
this._register(this.model.onWillShowDialog(() => {
|
|
1244
|
-
if (!this.currentDialog) {
|
|
1245
|
-
this.processDialogs();
|
|
1246
|
-
}
|
|
1247
|
-
}));
|
|
1248
|
-
this.processDialogs();
|
|
1249
|
-
}
|
|
1250
|
-
async processDialogs() {
|
|
1251
|
-
while (this.model.dialogs.length) {
|
|
1252
|
-
this.currentDialog = this.model.dialogs[0];
|
|
1253
|
-
let result = undefined;
|
|
1254
|
-
if (this.currentDialog.args.confirmArgs) {
|
|
1255
|
-
const args = this.currentDialog.args.confirmArgs;
|
|
1256
|
-
result = await this.impl.confirm(args.confirmation);
|
|
1257
|
-
}
|
|
1258
|
-
else if (this.currentDialog.args.inputArgs) {
|
|
1259
|
-
const args = this.currentDialog.args.inputArgs;
|
|
1260
|
-
result = await this.impl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
|
|
1261
|
-
}
|
|
1262
|
-
else if (this.currentDialog.args.showArgs) {
|
|
1263
|
-
const args = this.currentDialog.args.showArgs;
|
|
1264
|
-
result = await this.impl.show(args.severity, args.message, args.buttons, args.options);
|
|
1265
|
-
}
|
|
1266
|
-
else {
|
|
1267
|
-
await this.impl.about();
|
|
1268
|
-
}
|
|
1269
|
-
this.currentDialog.close(result);
|
|
1270
|
-
this.currentDialog = undefined;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
DialogHandlerContribution = ( (__decorate([
|
|
1275
|
-
( (__param(0, IDialogService))),
|
|
1276
|
-
( (__param(1, ILogService))),
|
|
1277
|
-
( (__param(2, ILayoutService))),
|
|
1278
|
-
( (__param(3, IThemeService))),
|
|
1279
|
-
( (__param(4, IKeybindingService))),
|
|
1280
|
-
( (__param(5, IInstantiationService))),
|
|
1281
|
-
( (__param(6, IProductService))),
|
|
1282
|
-
( (__param(7, IClipboardService)))
|
|
1283
|
-
], DialogHandlerContribution)));
|
|
1284
394
|
class LayoutService {
|
|
1285
395
|
constructor(container) {
|
|
1286
396
|
this.container = container;
|
|
@@ -1316,4 +426,4 @@ function getServiceOverride(container = document.body) {
|
|
|
1316
426
|
[( IWorkbenchLayoutService.toString())]: new SyncDescriptor(LayoutService, [container])
|
|
1317
427
|
};
|
|
1318
428
|
}
|
|
1319
|
-
export { ButtonBar as B,
|
|
429
|
+
export { ButtonBar as B, attachButtonStyler as a, attachProgressBarStyler as b, attachDialogStyler as c, ButtonWithDescription as d, getServiceOverride as g, n };
|