-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
contribShareMenu
proposed menus
#176316
Comments
Feedback from API sync:
|
@joyceerhl One thing I just thought of: how do we support sharing documents from other views, such as the open editors view, or potentially even sharing from custom tree views, such as the Find All References view? One option would be to create contribution points for each case. That would let extensions control where their menus show up, but would also require knowing about and adopting a lot of contribution points Another option though would be to have a generic I believe we may have considered something similar last week. Were there any concerns about this approach? |
The main issue that we discussed last week is that we don't want to show the same share actions everywhere, e.g.
This is a really good point though. Having a single contribution point would allow us to avoid a continuous adoption cost across extensions anytime we introduce a new area in the product where sharing makes sense.
@bamurtaugh had a proposal to add a If we go with this approach, here is the work that I think should happen:
@mjbvz let me know if I missed anything or if you have other suggestions. |
Two more places that would be nice to have share menus in:
It should be possible to deeplink to a line in a file from the share actions for those views. |
@jrieken and I discussed this and there are a few complications:
In order to be able to provide a consistent context from both core and extension-controlled contexts--without layer breaking--to extensions which want to generate a shareable link, we may be better off with an explicit data provider api. Here is a sketch of how I think this would work:
Currently we're most interested in sharing editor and view context, so here's a sketch of what that api could look like: declare module 'vscode' {
export namespace window {
/**
*
* @param viewId The id of the view that the provider can share data about.
* @param provider A provider that can generate {@link ShareableData} for the specified view.
*/
export function registerShareableTreeDataProvider(viewId: string, provider: ShareableTreeDataProvider): Disposable;
/**
*
* @param document A selector for editors that the provider can share data about.
* @param provider A provider that can generate {@link ShareableData} for the specified document.
*/
export function registerShareableDocumentDataProvider(document: DocumentSelector, provider: ShareableDocumentDataProvider): Disposable;
}
interface ShareableTreeDataProvider {
provideShareableData(context: TreeItem, token: CancellationToken): ProviderResult<ShareableData>;
}
interface ShareableDocumentDataProvider {
provideShareableData(context: DocumentSelector, token: CancellationToken): ProviderResult<ShareableData>;
}
interface ShareableData {
readonly uri?: Uri;
readonly ranges?: Range[];
}
} Another option is to expand the existing /**
* A data provider that provides tree data
*/
export interface TreeDataProvider<T> {
provideShareableData?(item: TreeItem, token: CancellationToken): ProviderResult<ShareableData>;
} |
Some additional limitations of the current implementation, which a central API would be able to address:
Basically what we need is API to support the ability to
I spent some time looking at prior art (copy/paste and drag/drop controllers, which support performing actions relating to data transfer on both tree items and editor context). I learned that we use stringified URIs with line numbers in the fragment, which works well enough for text editors. Unfortunately we already support copying deeplinks to notebook cells, so this approach doesn't suffice for my scenario: vscode/src/vscode-dts/vscode.d.ts Lines 10567 to 10569 in 06fc826
Here's my latest API proposal sketch: /**
*
* An {@link TreeShareableResourceDataProvider} enables sharing tree items
* which represent resources from extension-contributed tree views.
*/
export interface TreeShareableResourceDataProvider<T> {
/**
*
* @param source A tree item to provide shareable resource data for
* @returns The underlying shareable resource data represented by the tree item
*/
provideShareableResourceData(source: T, token: CancellationToken): ProviderResult<ShareableResourceData>;
}
export interface TreeViewOptions<T> {
/**
*
* {@link TreeView}s can optionally specify a {@link TreeShareableResourceDataProvider}
* to ensure that `Share` actions show up in the context menu for the {@link TreeView}.
*/
shareableResourceDataProvider?: TreeShareableResourceDataProvider<T>;
}
/**
*
* To be implemented by:
* 1. GHPRI
* 2. RemoteHub
* 3. Builtin GitHub extension
* 4. MakeCode
* 5. Live Share
*/
export interface ShareProvider {
readonly id: string;
readonly label: string;
/**
* @param resourceData Data representing a shareable resource
* @returns If applicable, a URI representing the shared resource, to be written to the clipboard
*/
provideShareResource(resourceData: ShareableResourceData, token: CancellationToken): ProviderResult<Uri>;
}
/**
*
* Modeled after TabInputText__, TabInputNotebook__, etc.
*/
export type ShareableResourceData = TextDocumentShareableData | NotebookDocumentShareableData;
export interface TextDocumentShareableData {
uri: Uri;
selection: Range;
}
export interface NotebookDocumentShareableData {
uri: Uri;
selection: NotebookRange;
} |
Feedback from API sync:
|
I'm not sure I really understand the goal of a unified API/experience here.
I definitely see this as a challenge, but it's also solvable with multi-select aware commands. I'm not sure I understand why "share" should be treated specially. This seems to assume that an individual item/line/editor/etc has 1 shareable thing, but each thing could have many shareable aspects -- how would that be handled in a unified api? Sorry if I'm just completely missing something on this. |
Maybe I am misunderstanding your question--the proposal is that each extension command which is currently implemented as a menu contribution would instead have a corresponding share provider, and we expect multiple providers to exist simultaneously. So for example there would be a GitHub permalink provider, a vscode.dev link provider, a GitLens remote file link provider and so on. A similar API exists for the rich Paste As... action, where there are multiple providers for pasting data from the clipboard as text, Markdown links, images, and so on. The benefits of this approach are:
Are you perhaps saying that we might need more information about a shareable location than just the ...and, TIL that in Electron, the Share menu is already special-cased for macOS, and a special
|
I still don't understand how this would work. For example, in GitLens you can right-click on a branch and can copy the following URLs:
How would the user choose which one they want? In this case the "resource" is the same. |
@eamodio GitLens would register 3 link providers, one for each link type. |
I see -- so the individual share provider is the "named" entry in the "Share" menu (I missed the Still seems like a lot of overhead vs a command, and then doesn't provide the granular control based on context. Currently, we can control based on the particular context what actions are most relevant. With this VS Code would have to show all options in all contexts. |
Do you have examples of share actions in GitLens that are suppressed based on context? |
Today each command placement in GitLens is controllable via settings -- so if someone wanted to turn off a set of menus from showing up in the Share menu of the line/gutter, but not in the editor context menu they can. That wouldn't be possible with this. Also, context for the same "resource" feels important, what you might expect on the Share menu on an editor tab vs editor context vs SCM, etc could be different, if not in the raw options themselves, but ordering and grouping. |
Why is "Share" special? We don't have this for "Copy" or for other actions. And it feels like a unified system is harder and less flexible than a targetable menu (like Copy As). I get the challenge of multi-select (though is multiselect sharing common?), but a top-level action is solvable by another targetable menu. It will be harder to handle because of long standing challenges with command callbacks (#25716), but also solvable. |
Moving to July. |
I'm filing this issue to track the finalization of the
contribShareMenu
API proposal since I was not able to find a tracking issue, cc @alexr00.Current state
The
contribShareMenu
API proposal tracks the following menu points:file/share
editor/context/share
This proposal has been in place for several months without changes, and was previously discussed in #146309 and #157722, but has not yet been finalized. This means it can't yet be used by most extensions, limiting its utility. An example of an extension that IMO would be a great fit for the Share submenus is Live Share (cc @jramsay):
Additional
share
submenusAs part of #175676 I'm looking at integrating link sharing more deeply into our product surface area, with the goal of making collaboration via links as seamless as possible. Therefore I'm proposing to expand this API proposal to also include
editor/title/context/share
explorer/context/share
(Note, there is also
editor/lineNumber/context
via #175945, but I have not added ashare
submenu for that context menu yet because we are introducing that context menu for the first time all up and it would be odd to only have one item in the menu which is itself a submenu.)The text was updated successfully, but these errors were encountered: