@codingame/monaco-vscode-dialogs-service-override 1.82.4 → 1.82.5-next.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/dialogs.d.ts +5 -0
- package/dialogs.js +58 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/override/vs/platform/dialogs/common/dialogs.js +8 -0
- package/package.json +2 -2
- package/tools.js +5 -0
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js +71 -0
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.js +129 -0
- package/vscode/src/vs/workbench/common/dialogs.js +33 -0
- package/vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js +322 -0
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.js +991 -0
- package/vscode/src/vs/workbench/services/dialogs/common/dialogService.js +68 -0
package/dialogs.d.ts
ADDED
package/dialogs.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import './vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js';
|
|
2
|
+
import { DialogService } from './vscode/src/vs/workbench/services/dialogs/common/dialogService.js';
|
|
3
|
+
import './override/vs/platform/dialogs/common/dialogs.js';
|
|
4
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
5
|
+
import { AbstractFileDialogService } from './vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js';
|
|
6
|
+
import getServiceOverride$1 from 'vscode/service-override/layout';
|
|
7
|
+
import { unsupported } from './tools.js';
|
|
8
|
+
import { IDialogService, IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
9
|
+
|
|
10
|
+
class FileDialogService extends AbstractFileDialogService {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.pickWorkspaceAndOpen = unsupported;
|
|
14
|
+
}
|
|
15
|
+
async pickFileFolderAndOpen(options) {
|
|
16
|
+
const schema = this.getFileSystemSchema(options);
|
|
17
|
+
if (options.defaultUri == null) {
|
|
18
|
+
options.defaultUri = await this.defaultFilePath(schema);
|
|
19
|
+
}
|
|
20
|
+
return super.pickFileFolderAndOpenSimplified(schema, options, false);
|
|
21
|
+
}
|
|
22
|
+
async pickFolderAndOpen(options) {
|
|
23
|
+
const schema = this.getFileSystemSchema(options);
|
|
24
|
+
if (options.defaultUri == null) {
|
|
25
|
+
options.defaultUri = await this.defaultFolderPath(schema);
|
|
26
|
+
}
|
|
27
|
+
return super.pickFolderAndOpenSimplified(schema, options);
|
|
28
|
+
}
|
|
29
|
+
async pickFileAndOpen(options) {
|
|
30
|
+
const schema = this.getFileSystemSchema(options);
|
|
31
|
+
if (options.defaultUri == null) {
|
|
32
|
+
options.defaultUri = await this.defaultFilePath(schema);
|
|
33
|
+
}
|
|
34
|
+
return super.pickFileAndOpenSimplified(schema, options, false);
|
|
35
|
+
}
|
|
36
|
+
async showSaveDialog(options) {
|
|
37
|
+
const schema = this.getFileSystemSchema(options);
|
|
38
|
+
return super.showSaveDialogSimplified(schema, options);
|
|
39
|
+
}
|
|
40
|
+
async showOpenDialog(options) {
|
|
41
|
+
const schema = this.getFileSystemSchema(options);
|
|
42
|
+
return super.showOpenDialogSimplified(schema, options);
|
|
43
|
+
}
|
|
44
|
+
async pickFileToSave(defaultUri, availableFileSystems) {
|
|
45
|
+
const schema = this.getFileSystemSchema({ defaultUri, availableFileSystems });
|
|
46
|
+
const options = this.getPickFileToSaveDialogOptions(defaultUri, availableFileSystems);
|
|
47
|
+
return super.pickFileToSaveSimplified(schema, options);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function getServiceOverride(container) {
|
|
51
|
+
return {
|
|
52
|
+
[( IDialogService.toString())]: new SyncDescriptor(DialogService, undefined, true),
|
|
53
|
+
[( IFileDialogService.toString())]: new SyncDescriptor(FileDialogService, undefined, true),
|
|
54
|
+
...getServiceOverride$1(container)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { getServiceOverride as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function __decorate(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
}
|
|
7
|
+
function __param(paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { __decorate, __param };
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '
|
|
1
|
+
export { default } from './dialogs.js';
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '
|
|
1
|
+
export { default } from './dialogs.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var ConfirmResult;
|
|
2
|
+
( (function(ConfirmResult) {
|
|
3
|
+
ConfirmResult[ConfirmResult["SAVE"] = 0] = "SAVE";
|
|
4
|
+
ConfirmResult[ConfirmResult["DONT_SAVE"] = 1] = "DONT_SAVE";
|
|
5
|
+
ConfirmResult[ConfirmResult["CANCEL"] = 2] = "CANCEL";
|
|
6
|
+
})(ConfirmResult || (ConfirmResult = {})));
|
|
7
|
+
|
|
8
|
+
export { ConfirmResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-dialogs-service-override",
|
|
3
|
-
"version": "1.82.
|
|
3
|
+
"version": "1.82.5-next.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@1.82.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@1.82.5-next.1",
|
|
22
22
|
"monaco-editor": "0.43.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/tools.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
3
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
4
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
5
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
6
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
7
|
+
import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
|
|
8
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
9
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
10
|
+
import { BrowserDialogHandler } from './dialogHandler.js';
|
|
11
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
12
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
13
|
+
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
14
|
+
|
|
15
|
+
let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
|
|
16
|
+
constructor(dialogService, logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
|
|
17
|
+
super();
|
|
18
|
+
this.dialogService = dialogService;
|
|
19
|
+
this.impl = ( new BrowserDialogHandler(
|
|
20
|
+
logService,
|
|
21
|
+
layoutService,
|
|
22
|
+
keybindingService,
|
|
23
|
+
instantiationService,
|
|
24
|
+
productService,
|
|
25
|
+
clipboardService
|
|
26
|
+
));
|
|
27
|
+
this.model = this.dialogService.model;
|
|
28
|
+
this._register(this.model.onWillShowDialog(() => {
|
|
29
|
+
if (!this.currentDialog) {
|
|
30
|
+
this.processDialogs();
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
this.processDialogs();
|
|
34
|
+
}
|
|
35
|
+
async processDialogs() {
|
|
36
|
+
while (this.model.dialogs.length) {
|
|
37
|
+
this.currentDialog = this.model.dialogs[0];
|
|
38
|
+
let result = undefined;
|
|
39
|
+
if (this.currentDialog.args.confirmArgs) {
|
|
40
|
+
const args = this.currentDialog.args.confirmArgs;
|
|
41
|
+
result = await this.impl.confirm(args.confirmation);
|
|
42
|
+
}
|
|
43
|
+
else if (this.currentDialog.args.inputArgs) {
|
|
44
|
+
const args = this.currentDialog.args.inputArgs;
|
|
45
|
+
result = await this.impl.input(args.input);
|
|
46
|
+
}
|
|
47
|
+
else if (this.currentDialog.args.promptArgs) {
|
|
48
|
+
const args = this.currentDialog.args.promptArgs;
|
|
49
|
+
result = await this.impl.prompt(args.prompt);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
await this.impl.about();
|
|
53
|
+
}
|
|
54
|
+
this.currentDialog.close(result);
|
|
55
|
+
this.currentDialog = undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
DialogHandlerContribution = ( __decorate([
|
|
60
|
+
( __param(0, IDialogService)),
|
|
61
|
+
( __param(1, ILogService)),
|
|
62
|
+
( __param(2, ILayoutService)),
|
|
63
|
+
( __param(3, IKeybindingService)),
|
|
64
|
+
( __param(4, IInstantiationService)),
|
|
65
|
+
( __param(5, IProductService)),
|
|
66
|
+
( __param(6, IClipboardService))
|
|
67
|
+
], DialogHandlerContribution));
|
|
68
|
+
const workbenchRegistry = ( Registry.as(Extensions.Workbench));
|
|
69
|
+
workbenchRegistry.registerWorkbenchContribution(DialogHandlerContribution, 1 );
|
|
70
|
+
|
|
71
|
+
export { DialogHandlerContribution };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
4
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
5
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
6
|
+
import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
7
|
+
import { Dialog } from 'monaco-editor/esm/vs/base/browser/ui/dialog/dialog.js';
|
|
8
|
+
import { DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
9
|
+
import { EventHelper } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
10
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
11
|
+
import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
|
|
12
|
+
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
13
|
+
import { fromNow } from 'vscode/vscode/vs/base/common/date';
|
|
14
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
15
|
+
import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
|
|
16
|
+
import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
|
|
17
|
+
import { AbstractDialogHandler } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
18
|
+
|
|
19
|
+
var BrowserDialogHandler_1;
|
|
20
|
+
let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHandler {
|
|
21
|
+
static { BrowserDialogHandler_1 = this; }
|
|
22
|
+
static { this.ALLOWABLE_COMMANDS = [
|
|
23
|
+
'copy',
|
|
24
|
+
'cut',
|
|
25
|
+
'editor.action.selectAll',
|
|
26
|
+
'editor.action.clipboardCopyAction',
|
|
27
|
+
'editor.action.clipboardCutAction',
|
|
28
|
+
'editor.action.clipboardPasteAction'
|
|
29
|
+
]; }
|
|
30
|
+
constructor(logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
|
|
31
|
+
super();
|
|
32
|
+
this.logService = logService;
|
|
33
|
+
this.layoutService = layoutService;
|
|
34
|
+
this.keybindingService = keybindingService;
|
|
35
|
+
this.instantiationService = instantiationService;
|
|
36
|
+
this.productService = productService;
|
|
37
|
+
this.clipboardService = clipboardService;
|
|
38
|
+
this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
39
|
+
}
|
|
40
|
+
async prompt(prompt) {
|
|
41
|
+
this.logService.trace('DialogService#prompt', prompt.message);
|
|
42
|
+
const buttons = this.getPromptButtons(prompt);
|
|
43
|
+
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);
|
|
44
|
+
return this.getPromptResult(prompt, button, checkboxChecked);
|
|
45
|
+
}
|
|
46
|
+
async confirm(confirmation) {
|
|
47
|
+
this.logService.trace('DialogService#confirm', confirmation.message);
|
|
48
|
+
const buttons = this.getConfirmationButtons(confirmation);
|
|
49
|
+
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);
|
|
50
|
+
return { confirmed: button === 0, checkboxChecked };
|
|
51
|
+
}
|
|
52
|
+
async input(input) {
|
|
53
|
+
this.logService.trace('DialogService#input', input.message);
|
|
54
|
+
const buttons = this.getInputButtons(input);
|
|
55
|
+
const { button, checkboxChecked, values } = await this.doShow(input.type ?? 'question', input.message, buttons, input.detail, buttons.length - 1, input?.checkbox, input.inputs, typeof input.custom === 'object' ? input.custom : undefined);
|
|
56
|
+
return { confirmed: button === 0, checkboxChecked, values };
|
|
57
|
+
}
|
|
58
|
+
async about() {
|
|
59
|
+
const detailString = (useAgo) => {
|
|
60
|
+
return ( localize(
|
|
61
|
+
'aboutDetail',
|
|
62
|
+
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
|
|
63
|
+
this.productService.version || 'Unknown',
|
|
64
|
+
this.productService.commit || 'Unknown',
|
|
65
|
+
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
|
|
66
|
+
navigator.userAgent
|
|
67
|
+
));
|
|
68
|
+
};
|
|
69
|
+
const detail = detailString(true);
|
|
70
|
+
const detailToCopy = detailString(false);
|
|
71
|
+
const { button } = await this.doShow(Severity.Info, this.productService.nameLong, [
|
|
72
|
+
( localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy")),
|
|
73
|
+
( localize('ok', "OK"))
|
|
74
|
+
], detail, 1);
|
|
75
|
+
if (button === 0) {
|
|
76
|
+
this.clipboardService.writeText(detailToCopy);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
|
|
80
|
+
const dialogDisposables = ( new DisposableStore());
|
|
81
|
+
const renderBody = customOptions ? (parent) => {
|
|
82
|
+
parent.classList.add(...(customOptions.classes || []));
|
|
83
|
+
customOptions.markdownDetails?.forEach(markdownDetail => {
|
|
84
|
+
const result = this.markdownRenderer.render(markdownDetail.markdown);
|
|
85
|
+
parent.appendChild(result.element);
|
|
86
|
+
result.element.classList.add(...(markdownDetail.classes || []));
|
|
87
|
+
dialogDisposables.add(result);
|
|
88
|
+
});
|
|
89
|
+
} : undefined;
|
|
90
|
+
const dialog = ( new Dialog(this.layoutService.container, message, buttons, {
|
|
91
|
+
detail,
|
|
92
|
+
cancelId,
|
|
93
|
+
type: this.getDialogType(type),
|
|
94
|
+
keyEventProcessor: (event) => {
|
|
95
|
+
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
|
|
96
|
+
if (resolved.kind === 2 && resolved.commandId) {
|
|
97
|
+
if (BrowserDialogHandler_1.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
|
|
98
|
+
EventHelper.stop(event, true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
renderBody,
|
|
103
|
+
icon: customOptions?.icon,
|
|
104
|
+
disableCloseAction: customOptions?.disableCloseAction,
|
|
105
|
+
buttonDetails: customOptions?.buttonDetails,
|
|
106
|
+
checkboxLabel: checkbox?.label,
|
|
107
|
+
checkboxChecked: checkbox?.checked,
|
|
108
|
+
inputs,
|
|
109
|
+
buttonStyles: defaultButtonStyles,
|
|
110
|
+
checkboxStyles: defaultCheckboxStyles,
|
|
111
|
+
inputBoxStyles: defaultInputBoxStyles,
|
|
112
|
+
dialogStyles: defaultDialogStyles
|
|
113
|
+
}));
|
|
114
|
+
dialogDisposables.add(dialog);
|
|
115
|
+
const result = await dialog.show();
|
|
116
|
+
dialogDisposables.dispose();
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
BrowserDialogHandler = BrowserDialogHandler_1 = ( __decorate([
|
|
121
|
+
( __param(0, ILogService)),
|
|
122
|
+
( __param(1, ILayoutService)),
|
|
123
|
+
( __param(2, IKeybindingService)),
|
|
124
|
+
( __param(3, IInstantiationService)),
|
|
125
|
+
( __param(4, IProductService)),
|
|
126
|
+
( __param(5, IClipboardService))
|
|
127
|
+
], BrowserDialogHandler));
|
|
128
|
+
|
|
129
|
+
export { BrowserDialogHandler };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
2
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
3
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
|
|
5
|
+
class DialogsModel extends Disposable {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.dialogs = [];
|
|
9
|
+
this._onWillShowDialog = this._register(( new Emitter()));
|
|
10
|
+
this.onWillShowDialog = this._onWillShowDialog.event;
|
|
11
|
+
this._onDidShowDialog = this._register(( new Emitter()));
|
|
12
|
+
this.onDidShowDialog = this._onDidShowDialog.event;
|
|
13
|
+
}
|
|
14
|
+
show(dialog) {
|
|
15
|
+
const promise = ( new DeferredPromise());
|
|
16
|
+
const item = {
|
|
17
|
+
args: dialog,
|
|
18
|
+
close: result => {
|
|
19
|
+
this.dialogs.splice(0, 1);
|
|
20
|
+
promise.complete(result);
|
|
21
|
+
this._onDidShowDialog.fire();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.dialogs.push(item);
|
|
25
|
+
this._onWillShowDialog.fire();
|
|
26
|
+
return {
|
|
27
|
+
item,
|
|
28
|
+
result: promise.p
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { DialogsModel };
|