Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ShareProvider API proposal #183568

Merged
merged 2 commits into from
May 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions src/vscode-dts/vscode.proposed.shareProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,71 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// https://github.com/microsoft/vscode/issues/176316
// https://github.com/microsoft/vscode/issues/176316 @joyceerhl

declare module 'vscode' {
export interface TreeItem {
shareableItem?: ShareableItem;
}

/**
* Data about an item which can be shared.
*/
export interface ShareableItem {
/**
* A resource in the editor that can be shared.
*/
resourceUri: Uri;

/**
* If present, a selection within the `resourceUri`.
*/
selection?: Range;
}

/**
* A provider which generates share links for resources in VS Code.
*/
export interface ShareProvider {

/**
* A unique ID for the provider.
* This will be used to activate specific extensions contributing share providers if necessary.
*/
readonly id: string;

/**
* A label which will be used to present this provider's options in the UI.
*/
readonly label: string;

/**
* The order in which the provider should be listed in the UI when there are multiple providers.
*/
readonly priority: number;

/**
*
* @param item Data about an item which can be shared.
* @param token A cancellation token.
* @returns An {@link Uri} which will be copied to the user's clipboard and presented in a confirmation dialog.
*/
provideShare(item: ShareableItem, token: CancellationToken): ProviderResult<Uri>;
}

export namespace window {

/**
* Register a share provider. An extension may register multiple share providers.
* There may be multiple share providers for the same {@link ShareableItem}.
* @param selector A document selector to filter whether the provider should be shown for a {@link ShareableItem}.
* @param provider A share provider.
*/
export function registerShareProvider(selector: DocumentSelector, provider: ShareProvider): Disposable;
}

export interface TreeItem {

/**
* An optional property which, when set, inlines a `Share` option in the context menu for this tree item.
*/
shareableItem?: ShareableItem;
}
}