mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 33a65245075e4d18908652865a79cf5489c30f40 (#9279)
* Merge from vscode 33a65245075e4d18908652865a79cf5489c30f40 * remove github
This commit is contained in:
184
src/vs/vscode.proposed.d.ts
vendored
184
src/vs/vscode.proposed.d.ts
vendored
@@ -1187,65 +1187,77 @@ declare module 'vscode' {
|
||||
|
||||
//#region Custom editors: https://github.com/microsoft/vscode/issues/77131
|
||||
|
||||
// TODO:
|
||||
// - Naming!
|
||||
// - Think about where a rename would live.
|
||||
// - Think about handling go to line?
|
||||
// - Should we expose edits?
|
||||
// - More properties from `TextDocument`?
|
||||
|
||||
/**
|
||||
* Defines the editing functionality of a webview editor. This allows the webview editor to hook into standard
|
||||
* Defines the capabilities of a custom webview editor.
|
||||
*/
|
||||
interface WebviewCustomEditorCapabilities {
|
||||
/**
|
||||
* Defines the editing capability of a custom webview document.
|
||||
*
|
||||
* When not provided, the document is considered readonly.
|
||||
*/
|
||||
readonly editing?: WebviewCustomEditorEditingCapability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the editing capability of a custom webview editor. This allows the webview editor to hook into standard
|
||||
* editor events such as `undo` or `save`.
|
||||
*
|
||||
* @param EditType Type of edits.
|
||||
*/
|
||||
interface WebviewCustomEditorEditingDelegate<EditType> {
|
||||
interface WebviewCustomEditorEditingCapability<EditType = unknown> {
|
||||
/**
|
||||
* Save a resource.
|
||||
*
|
||||
* @param resource Resource being saved.
|
||||
* Save the resource.
|
||||
*
|
||||
* @return Thenable signaling that the save has completed.
|
||||
*/
|
||||
save(resource: Uri): Thenable<void>;
|
||||
save(): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Save an existing resource at a new path.
|
||||
* Save the existing resource at a new path.
|
||||
*
|
||||
* @param resource Resource being saved.
|
||||
* @param targetResource Location to save to.
|
||||
*
|
||||
* @return Thenable signaling that the save has completed.
|
||||
*/
|
||||
saveAs(resource: Uri, targetResource: Uri): Thenable<void>;
|
||||
saveAs(targetResource: Uri): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Event triggered by extensions to signal to VS Code that an edit has occurred.
|
||||
*/
|
||||
// TODO@matt
|
||||
// eslint-disable-next-line vscode-dts-event-naming
|
||||
readonly onEdit: Event<{ readonly resource: Uri, readonly edit: EditType }>;
|
||||
readonly onDidEdit: Event<EditType>;
|
||||
|
||||
/**
|
||||
* Apply a set of edits.
|
||||
*
|
||||
* Note that is not invoked when `onEdit` is called as `onEdit` implies also updating the view to reflect the edit.
|
||||
* Note that is not invoked when `onDidEdit` is called because `onDidEdit` implies also updating the view to reflect the edit.
|
||||
*
|
||||
* @param resource Resource being edited.
|
||||
* @param edit Array of edits. Sorted from oldest to most recent.
|
||||
*
|
||||
* @return Thenable signaling that the change has completed.
|
||||
*/
|
||||
applyEdits(resource: Uri, edits: readonly EditType[]): Thenable<void>;
|
||||
applyEdits(edits: readonly EditType[]): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Undo a set of edits.
|
||||
*
|
||||
* This is triggered when a user undoes an edit or when revert is called on a file.
|
||||
*
|
||||
* @param resource Resource being edited.
|
||||
* @param edit Array of edits. Sorted from most recent to oldest.
|
||||
*
|
||||
* @return Thenable signaling that the change has completed.
|
||||
*/
|
||||
undoEdits(resource: Uri, edits: readonly EditType[]): Thenable<void>;
|
||||
undoEdits(edits: readonly EditType[]): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Back up `resource` in its current state.
|
||||
* Back up the resource in its current state.
|
||||
*
|
||||
* Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
|
||||
* its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
|
||||
@@ -1257,57 +1269,159 @@ declare module 'vscode' {
|
||||
* made in quick succession, `backup` is only triggered after the last one. `backup` is not invoked when
|
||||
* `auto save` is enabled (since auto save already persists resource ).
|
||||
*
|
||||
* @param resource The resource to back up.
|
||||
* @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
|
||||
* extension to decided how to respond to cancellation. If for example your extension is backing up a large file
|
||||
* in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
|
||||
* than cancelling it to ensure that VS Code has some valid backup.
|
||||
*/
|
||||
backup?(resource: Uri, cancellation: CancellationToken): Thenable<boolean>;
|
||||
backup(cancellation: CancellationToken): Thenable<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom document for a custom webview editor.
|
||||
*
|
||||
* Custom documents are only used within a given `WebviewCustomEditorProvider`. The lifecycle of a
|
||||
* `WebviewEditorCustomDocument` is managed by VS Code. When more more references remain to a given `WebviewEditorCustomDocument`
|
||||
* then it is disposed of.
|
||||
*
|
||||
* @param UserDataType Type of custom object that extensions can store on the document.
|
||||
*/
|
||||
interface WebviewEditorCustomDocument<UserDataType = unknown> {
|
||||
/**
|
||||
* The associated viewType for this document.
|
||||
*/
|
||||
readonly viewType: string;
|
||||
|
||||
/**
|
||||
* The associated uri for this document.
|
||||
*/
|
||||
readonly uri: Uri;
|
||||
|
||||
/**
|
||||
* Event fired when there are no more references to the `WebviewEditorCustomDocument`.
|
||||
*/
|
||||
readonly onDidDispose: Event<void>;
|
||||
|
||||
/**
|
||||
* Custom data that an extension can store on the document.
|
||||
*/
|
||||
readonly userData: UserDataType;
|
||||
|
||||
// TODO: Should we expose edits here?
|
||||
// This could be helpful for tracking the life cycle of edits
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for webview editors that use a custom data model.
|
||||
*
|
||||
* Custom webview editors use [`WebviewEditorCustomDocument`](#WebviewEditorCustomDocument) as their data model.
|
||||
* This gives extensions full control over actions such as edit, save, and backup.
|
||||
*
|
||||
* You should use custom text based editors when dealing with binary files or more complex scenarios. For simple text
|
||||
* based documents, use [`WebviewTextEditorProvider`](#WebviewTextEditorProvider) instead.
|
||||
*/
|
||||
export interface WebviewCustomEditorProvider {
|
||||
/**
|
||||
* Create the model for a given
|
||||
*
|
||||
* @param document Resource being resolved.
|
||||
*/
|
||||
provideWebviewCustomEditorDocument(resource: Uri): Thenable<WebviewEditorCustomDocument>;
|
||||
|
||||
/**
|
||||
* Resolve a webview editor for a given resource.
|
||||
*
|
||||
* To resolve a webview editor, a provider must fill in its initial html content and hook up all
|
||||
* the event listeners it is interested it. The provider should also take ownership of the passed in `WebviewPanel`.
|
||||
*
|
||||
* @param resource Resource being resolved.
|
||||
* @param document Document for resource being resolved.
|
||||
* @param webview Webview being resolved. The provider should take ownership of this webview.
|
||||
*
|
||||
* @return Thenable indicating that the webview editor has been resolved.
|
||||
*/
|
||||
resolveWebviewEditor(
|
||||
resource: Uri,
|
||||
webview: WebviewPanel,
|
||||
): Thenable<void>;
|
||||
resolveWebviewCustomEditor(document: WebviewEditorCustomDocument, webview: WebviewPanel): Thenable<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for text based webview editors.
|
||||
*
|
||||
* Text based webview editors use a [`TextDocument`](#TextDocument) as their data model. This considerably simplifies
|
||||
* implementing a webview editor as it allows VS Code to handle many common operations such as
|
||||
* undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
|
||||
*
|
||||
* You should use text based webview editors when dealing with text based file formats, such as `xml` or `json`.
|
||||
* For binary files or more specialized use cases, see [WebviewCustomEditorProvider](#WebviewCustomEditorProvider).
|
||||
*/
|
||||
export interface WebviewTextEditorProvider {
|
||||
/**
|
||||
* Controls the editing functionality of a webview editor. This allows the webview editor to hook into standard
|
||||
* editor events such as `undo` or `save`.
|
||||
* Resolve a webview editor for a given resource.
|
||||
*
|
||||
* WebviewEditors that do not have `editingCapability` are considered to be readonly. Users can still interact
|
||||
* with readonly editors, but these editors will not integrate with VS Code's standard editor functionality.
|
||||
* To resolve a webview editor, the provider must fill in its initial html content and hook up all
|
||||
* the event listeners it is interested it. The provider should also take ownership of the passed in `WebviewPanel`.
|
||||
*
|
||||
* @param document Resource being resolved.
|
||||
* @param webview Webview being resolved. The provider should take ownership of this webview.
|
||||
*
|
||||
* @return Thenable indicating that the webview editor has been resolved.
|
||||
*/
|
||||
readonly editingDelegate?: WebviewCustomEditorEditingDelegate<unknown>;
|
||||
resolveWebviewTextEditor(document: TextDocument, webview: WebviewPanel): Thenable<void>;
|
||||
}
|
||||
|
||||
namespace window {
|
||||
/**
|
||||
* Register a new provider for webview editors of a given type.
|
||||
* Register a new provider for text based webview editors.
|
||||
*
|
||||
* @param viewType Type of the webview editor provider.
|
||||
* @param provider Resolves webview editors.
|
||||
* @param options Content settings for a webview panels the provider is given.
|
||||
* @param viewType Type of the webview editor provider. This should match the `viewType` from the
|
||||
* `package.json` contributions
|
||||
* @param provider Provider that resolves webview editors.
|
||||
* @param webviewOptions Content settings for the webview panels that provider is given.
|
||||
*
|
||||
* @return Disposable that unregisters the `WebviewTextEditorProvider`.
|
||||
*/
|
||||
export function registerWebviewTextEditorProvider(
|
||||
viewType: string,
|
||||
provider: WebviewTextEditorProvider,
|
||||
webviewOptions?: WebviewPanelOptions,
|
||||
): Disposable;
|
||||
|
||||
/**
|
||||
* Register a new provider for custom webview editors.
|
||||
*
|
||||
* @param viewType Type of the webview editor provider. This should match the `viewType` from the
|
||||
* `package.json` contributions.
|
||||
* @param provider Provider that resolves webview editors.
|
||||
* @param webviewOptions Content settings for the webview panels that provider is given.
|
||||
*
|
||||
* @return Disposable that unregisters the `WebviewCustomEditorProvider`.
|
||||
*/
|
||||
export function registerWebviewCustomEditorProvider(
|
||||
viewType: string,
|
||||
provider: WebviewCustomEditorProvider,
|
||||
options?: WebviewPanelOptions,
|
||||
webviewOptions?: WebviewPanelOptions,
|
||||
): Disposable;
|
||||
|
||||
/**
|
||||
* Create a new `WebviewEditorCustomDocument`.
|
||||
*
|
||||
* Note that this method only creates a custom document object. To have it be registered with VS Code, you
|
||||
* must return the document from `WebviewCustomEditorProvider.provideWebviewCustomEditorDocument`.
|
||||
*
|
||||
* @param viewType Type of the webview editor provider. This should match the `viewType` from the
|
||||
* `package.json` contributions.
|
||||
* @param uri The document's resource.
|
||||
* @param userData Custom data attached to the document.
|
||||
* @param capabilities Controls the editing functionality of a webview editor. This allows the webview
|
||||
* editor to hook into standard editor events such as `undo` or `save`.
|
||||
*
|
||||
* WebviewEditors that do not have `editingCapability` are considered to be readonly. Users can still interact
|
||||
* with readonly editors, but these editors will not integrate with VS Code's standard editor functionality.
|
||||
*/
|
||||
export function createWebviewEditorCustomDocument<UserDataType>(
|
||||
viewType: string,
|
||||
uri: Uri,
|
||||
userData: UserDataType,
|
||||
capabilities: WebviewCustomEditorCapabilities
|
||||
): WebviewEditorCustomDocument<UserDataType>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
Reference in New Issue
Block a user