提交 9dce4655 编写于 作者: J Johannes Rieken

move open/save api into stable api, #13807

上级 45bc150e
......@@ -1503,6 +1503,75 @@ declare module 'vscode' {
onDidSelectItem?(item: QuickPickItem | string): any;
}
/**
* Options to configure the behaviour of a file open dialog.
*/
export interface OpenDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;
/**
* A human-readable string for the open button.
*/
openLabel?: string;
/**
* Only allow to select files. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFiles?: boolean;
/**
* Only allow to select folders. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFolders?: boolean;
/**
* Allow to select many files or folders.
*/
openMany?: boolean;
/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}
/**
* Options to configure the behaviour of a file save dialog.
*/
export interface SaveDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;
/**
* A human-readable string for the save button.
*/
saveLabel?: string;
/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}
/**
* Represents an action that is shown with an information, warning, or
* error message.
......@@ -4446,6 +4515,22 @@ declare module 'vscode' {
*/
export function showQuickPick<T extends QuickPickItem>(items: T[] | Thenable<T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
/**
* Shows a file open dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
export function showOpenDialog(options: OpenDialogOptions): Thenable<Uri[] | undefined>;
/**
* Shows a file save dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
export function showSaveDialog(options: SaveDialogOptions): Thenable<Uri | undefined>;
/**
* Opens an input box to ask the user for input.
*
......
......@@ -7,93 +7,8 @@
declare module 'vscode' {
/**
* Options to configure the behaviour of a file open dialog.
*/
export interface OpenDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;
/**
* A human-readable string for the open button.
*/
openLabel?: string;
/**
* Only allow to select files. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFiles?: boolean;
/**
* Only allow to select folders. *Note* that not all operating systems support
* to select files and folders in one dialog instance.
*/
openFolders?: boolean;
/**
* Allow to select many files or folders.
*/
openMany?: boolean;
/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}
/**
* Options to configure the behaviour of a file save dialog.
*/
export interface SaveDialogOptions {
/**
* The resource the dialog shows when opened.
*/
defaultUri?: Uri;
/**
* A human-readable string for the save button.
*/
saveLabel?: string;
/**
* A set of file filters that are shown in the dialog, e.g.
* ```ts
* {
* ['Images']: ['*.png', '*.jpg']
* ['TypeScript']: ['*.ts', '*.tsx']
* }
* ```
*/
filters: { [name: string]: string[] };
}
export namespace window {
/**
* Shows a file open dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
export function showOpenDialog(options: OpenDialogOptions): Thenable<Uri[] | undefined>;
/**
* Shows a file save dialog to the user.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
export function showSaveDialog(options: SaveDialogOptions): Thenable<Uri | undefined>;
/**
* Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from.
* Returns `undefined` if no folder is open.
......
......@@ -356,6 +356,12 @@ export function createApiFactory(
showInputBox(options?: vscode.InputBoxOptions, token?: vscode.CancellationToken) {
return extHostQuickOpen.showInput(options, token);
},
showOpenDialog(options) {
return extHostDialogs.showOpenDialog(options);
},
showSaveDialog(options) {
return extHostDialogs.showSaveDialog(options);
},
createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem {
return extHostStatusBar.createStatusBarEntry(extension.id, <number>position, priority);
},
......@@ -385,12 +391,6 @@ export function createApiFactory(
sampleFunction: proposedApiFunction(extension, () => {
return extHostMessageService.showMessage(extension, Severity.Info, 'Hello Proposed Api!', {}, []);
}),
showOpenDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showOpenDialog(options);
}),
showSaveDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showSaveDialog(options);
})
};
// namespace: workspace
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册