@codingame/monaco-vscode-dialogs-service-override 25.1.2 → 26.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js +28 -23
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.js +89 -35
- package/vscode/src/vs/workbench/common/dialogs.js +1 -2
- package/vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js +212 -83
- package/vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js +84 -51
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.js +270 -242
- package/vscode/src/vs/workbench/services/dialogs/common/dialogService.js +38 -15
|
@@ -28,11 +28,10 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
28
28
|
if (this.shouldUseSimplified(schema)) {
|
|
29
29
|
return super.pickFileFolderAndOpenSimplified(schema, options, false);
|
|
30
30
|
}
|
|
31
|
-
throw ( new Error(( localize(
|
|
31
|
+
throw ( new Error(( localize(14242, "Can't open folders, try adding a folder to the workspace instead."))));
|
|
32
32
|
}
|
|
33
33
|
addFileSchemaIfNeeded(schema, isFolder) {
|
|
34
|
-
return (schema === Schemas.untitled) ? [Schemas.file]
|
|
35
|
-
: (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
|
|
34
|
+
return (schema === Schemas.untitled) ? [Schemas.file] : (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
|
|
36
35
|
}
|
|
37
36
|
async pickFileAndOpen(options) {
|
|
38
37
|
const schema = this.getFileSystemSchema(options);
|
|
@@ -44,13 +43,14 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
44
43
|
}
|
|
45
44
|
const activeWindow = getActiveWindow();
|
|
46
45
|
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
47
|
-
return this.showUnsupportedBrowserWarning(
|
|
46
|
+
return this.showUnsupportedBrowserWarning("open");
|
|
48
47
|
}
|
|
49
48
|
let fileHandle = undefined;
|
|
50
49
|
try {
|
|
51
|
-
([fileHandle] = await activeWindow.showOpenFilePicker({
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
([fileHandle] = await activeWindow.showOpenFilePicker({
|
|
51
|
+
multiple: false
|
|
52
|
+
}));
|
|
53
|
+
} catch (error) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
@@ -58,7 +58,12 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
58
58
|
}
|
|
59
59
|
const uri = await this.fileSystemProvider.registerFileHandle(fileHandle);
|
|
60
60
|
this.addFileToRecentlyOpened(uri);
|
|
61
|
-
await this.openerService.open(uri, {
|
|
61
|
+
await this.openerService.open(uri, {
|
|
62
|
+
fromUserGesture: true,
|
|
63
|
+
editorOptions: {
|
|
64
|
+
pinned: true
|
|
65
|
+
}
|
|
66
|
+
});
|
|
62
67
|
}
|
|
63
68
|
async pickFolderAndOpen(options) {
|
|
64
69
|
const schema = this.getFileSystemSchema(options);
|
|
@@ -68,7 +73,7 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
68
73
|
if (this.shouldUseSimplified(schema)) {
|
|
69
74
|
return super.pickFolderAndOpenSimplified(schema, options);
|
|
70
75
|
}
|
|
71
|
-
throw ( new Error(( localize(
|
|
76
|
+
throw ( new Error(( localize(14242, "Can't open folders, try adding a folder to the workspace instead."))));
|
|
72
77
|
}
|
|
73
78
|
async pickWorkspaceAndOpen(options) {
|
|
74
79
|
options.availableFileSystems = this.getWorkspaceAvailableFileSystems(options);
|
|
@@ -80,26 +85,34 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
80
85
|
return super.pickWorkspaceAndOpenSimplified(schema, options);
|
|
81
86
|
}
|
|
82
87
|
throw ( new Error(( localize(
|
|
83
|
-
|
|
88
|
+
14243,
|
|
84
89
|
"Can't open workspaces, try adding a folder to the workspace instead."
|
|
85
90
|
))));
|
|
86
91
|
}
|
|
87
92
|
async pickFileToSave(defaultUri, availableFileSystems) {
|
|
88
|
-
const schema = this.getFileSystemSchema({
|
|
93
|
+
const schema = this.getFileSystemSchema({
|
|
94
|
+
defaultUri,
|
|
95
|
+
availableFileSystems
|
|
96
|
+
});
|
|
89
97
|
const options = this.getPickFileToSaveDialogOptions(defaultUri, availableFileSystems);
|
|
90
98
|
if (this.shouldUseSimplified(schema)) {
|
|
91
99
|
return super.pickFileToSaveSimplified(schema, options);
|
|
92
100
|
}
|
|
93
101
|
const activeWindow = getActiveWindow();
|
|
94
102
|
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
95
|
-
return this.showUnsupportedBrowserWarning(
|
|
103
|
+
return this.showUnsupportedBrowserWarning("save");
|
|
96
104
|
}
|
|
97
105
|
let fileHandle = undefined;
|
|
98
106
|
const startIn = Iterable.first(this.fileSystemProvider.directories);
|
|
99
107
|
try {
|
|
100
|
-
fileHandle = await activeWindow.showSaveFilePicker({
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
fileHandle = await activeWindow.showSaveFilePicker({
|
|
109
|
+
types: this.getFilePickerTypes(options.filters),
|
|
110
|
+
...{
|
|
111
|
+
suggestedName: basename(defaultUri),
|
|
112
|
+
startIn
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
} catch (error) {
|
|
103
116
|
return;
|
|
104
117
|
}
|
|
105
118
|
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
@@ -109,11 +122,13 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
109
122
|
}
|
|
110
123
|
getFilePickerTypes(filters) {
|
|
111
124
|
return filters?.filter(filter => {
|
|
112
|
-
return !((filter.extensions.length === 1) && ((filter.extensions[0] ===
|
|
113
|
-
}).map(
|
|
125
|
+
return !((filter.extensions.length === 1) && ((filter.extensions[0] === "*") || filter.extensions[0] === ""));
|
|
126
|
+
}).map(filter => {
|
|
114
127
|
const accept = {};
|
|
115
|
-
const extensions = filter.extensions.filter(
|
|
116
|
-
|
|
128
|
+
const extensions = filter.extensions.filter(
|
|
129
|
+
ext => (ext.indexOf("-") < 0) && (ext.indexOf("*") < 0) && (ext.indexOf("_") < 0)
|
|
130
|
+
);
|
|
131
|
+
accept[(getMediaOrTextMime(`fileName.${filter.extensions[0]}`) ?? "text/plain")] = ( extensions.map(ext => ext.startsWith(".") ? ext : `.${ext}`));
|
|
117
132
|
return {
|
|
118
133
|
description: filter.name,
|
|
119
134
|
accept
|
|
@@ -127,14 +142,21 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
127
142
|
}
|
|
128
143
|
const activeWindow = getActiveWindow();
|
|
129
144
|
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
130
|
-
return this.showUnsupportedBrowserWarning(
|
|
145
|
+
return this.showUnsupportedBrowserWarning("save");
|
|
131
146
|
}
|
|
132
147
|
let fileHandle = undefined;
|
|
133
148
|
const startIn = Iterable.first(this.fileSystemProvider.directories);
|
|
134
149
|
try {
|
|
135
|
-
fileHandle = await activeWindow.showSaveFilePicker({
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
fileHandle = await activeWindow.showSaveFilePicker({
|
|
151
|
+
types: this.getFilePickerTypes(options.filters),
|
|
152
|
+
...(options.defaultUri ? {
|
|
153
|
+
suggestedName: basename(options.defaultUri)
|
|
154
|
+
} : undefined),
|
|
155
|
+
...{
|
|
156
|
+
startIn
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
} catch (error) {
|
|
138
160
|
return undefined;
|
|
139
161
|
}
|
|
140
162
|
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
@@ -149,50 +171,61 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
149
171
|
}
|
|
150
172
|
const activeWindow = getActiveWindow();
|
|
151
173
|
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
152
|
-
return this.showUnsupportedBrowserWarning(
|
|
174
|
+
return this.showUnsupportedBrowserWarning("open");
|
|
153
175
|
}
|
|
154
176
|
let uri;
|
|
155
|
-
const startIn = Iterable.first(this.fileSystemProvider.directories) ??
|
|
177
|
+
const startIn = Iterable.first(this.fileSystemProvider.directories) ?? "documents";
|
|
156
178
|
try {
|
|
157
179
|
if (options.canSelectFiles) {
|
|
158
|
-
const handle = await activeWindow.showOpenFilePicker({
|
|
180
|
+
const handle = await activeWindow.showOpenFilePicker({
|
|
181
|
+
multiple: false,
|
|
182
|
+
types: this.getFilePickerTypes(options.filters),
|
|
183
|
+
...{
|
|
184
|
+
startIn
|
|
185
|
+
}
|
|
186
|
+
});
|
|
159
187
|
if (handle.length === 1 && WebFileSystemAccess.isFileSystemFileHandle(handle[0])) {
|
|
160
188
|
uri = await this.fileSystemProvider.registerFileHandle(handle[0]);
|
|
161
189
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
190
|
+
} else {
|
|
191
|
+
const handle = await activeWindow.showDirectoryPicker({
|
|
192
|
+
...{
|
|
193
|
+
startIn
|
|
194
|
+
}
|
|
195
|
+
});
|
|
165
196
|
uri = await this.fileSystemProvider.registerDirectoryHandle(handle);
|
|
166
197
|
}
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
}
|
|
198
|
+
} catch (error) {}
|
|
170
199
|
return uri ? [uri] : undefined;
|
|
171
200
|
}
|
|
172
201
|
async showUnsupportedBrowserWarning(context) {
|
|
173
|
-
if (context ===
|
|
202
|
+
if (context === "save") {
|
|
174
203
|
const activeCodeEditor = this.codeEditorService.getActiveCodeEditor();
|
|
175
204
|
if (!(activeCodeEditor instanceof EmbeddedCodeEditorWidget)) {
|
|
176
205
|
const activeTextModel = activeCodeEditor?.getModel();
|
|
177
206
|
if (activeTextModel) {
|
|
178
|
-
triggerDownload(
|
|
207
|
+
triggerDownload(
|
|
208
|
+
VSBuffer.fromString(activeTextModel.getValue()).buffer,
|
|
209
|
+
basename(activeTextModel.uri)
|
|
210
|
+
);
|
|
179
211
|
return;
|
|
180
212
|
}
|
|
181
213
|
}
|
|
182
214
|
}
|
|
183
|
-
const buttons = [
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
215
|
+
const buttons = [{
|
|
216
|
+
label: ( localize(14244, "&&Open Remote...")),
|
|
217
|
+
run: async () => {
|
|
218
|
+
await this.commandService.executeCommand("workbench.action.remote.showMenu");
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
label: ( localize(14245, "&&Learn More")),
|
|
222
|
+
run: async () => {
|
|
223
|
+
await this.openerService.open("https://aka.ms/VSCodeWebLocalFileSystemAccess");
|
|
191
224
|
}
|
|
192
|
-
];
|
|
193
|
-
if (context ===
|
|
225
|
+
}];
|
|
226
|
+
if (context === "open") {
|
|
194
227
|
buttons.push({
|
|
195
|
-
label: ( localize(
|
|
228
|
+
label: ( localize(14246, "Open &&Files...")),
|
|
196
229
|
run: async () => {
|
|
197
230
|
const files = await triggerUpload();
|
|
198
231
|
if (files) {
|
|
@@ -202,7 +235,9 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
202
235
|
return {
|
|
203
236
|
resource: fileData.resource,
|
|
204
237
|
contents: fileData.contents?.toString(),
|
|
205
|
-
options: {
|
|
238
|
+
options: {
|
|
239
|
+
pinned: true
|
|
240
|
+
}
|
|
206
241
|
};
|
|
207
242
|
})));
|
|
208
243
|
}
|
|
@@ -212,9 +247,9 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
212
247
|
}
|
|
213
248
|
await this.dialogService.prompt({
|
|
214
249
|
type: Severity.Warning,
|
|
215
|
-
message: ( localize(
|
|
250
|
+
message: ( localize(14247, "Opening Local Folders is Unsupported")),
|
|
216
251
|
detail: ( localize(
|
|
217
|
-
|
|
252
|
+
14248,
|
|
218
253
|
"Your browser doesn't support opening local folders.\nYou can either open single files or open a remote repository."
|
|
219
254
|
)),
|
|
220
255
|
buttons
|
|
@@ -225,8 +260,6 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
225
260
|
return ![Schemas.file, Schemas.vscodeUserData, Schemas.tmp].includes(scheme);
|
|
226
261
|
}
|
|
227
262
|
}
|
|
228
|
-
FileDialogService.__decorator = ( __decorate([
|
|
229
|
-
memoize
|
|
230
|
-
], FileDialogService.prototype, "fileSystemProvider", null));
|
|
263
|
+
FileDialogService.__decorator = ( __decorate([memoize], FileDialogService.prototype, "fileSystemProvider", null));
|
|
231
264
|
|
|
232
265
|
export { FileDialogService };
|