Links handling in commands (#15118)

* format

* update external options type

* add command flag for command

* Allow commands in Notebooks

Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Aditya Bist
2021-04-14 13:06:45 -07:00
committed by GitHub
parent 842a33e318
commit e151668c81
20 changed files with 69 additions and 35 deletions

View File

@@ -78,7 +78,7 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
private onDidClickLink(handle: extHostProtocol.WebviewHandle, link: string): void {
const webview = this.getWebview(handle);
if (this.isSupportedLink(webview, URI.parse(link))) {
this._openerService.open(link, { fromUserGesture: true });
this._openerService.open(link, { fromUserGesture: true, allowContributedOpeners: true, allowCommands: true });
}
}

View File

@@ -371,7 +371,7 @@ export class NotificationTemplateRenderer extends Disposable {
private renderMessage(notification: INotificationViewItem): boolean {
clearNode(this.template.message);
this.template.message.appendChild(NotificationMessageRenderer.render(notification.message, {
callback: link => this.openerService.open(URI.parse(link)),
callback: link => this.openerService.open(URI.parse(link), { allowCommands: true }),
toDispose: this.inputDisposables
}));

View File

@@ -581,7 +581,7 @@ export abstract class ViewPane extends Pane implements IView {
button.label = node.label;
button.onDidClick(_ => {
this.telemetryService.publicLog2<{ viewId: string, uri: string }, WelcomeActionClassification>('views.welcomeAction', { viewId: this.id, uri: node.href });
this.openerService.open(node.href);
this.openerService.open(node.href, { allowCommands: true });
}, null, disposables);
disposables.add(button);
disposables.add(attachButtonStyler(button, this.themeService));

View File

@@ -127,7 +127,7 @@ export class CommentNodeRenderer implements IListRenderer<ITreeNode<CommentNode>
inline: true,
actionHandler: {
callback: (content) => {
this.openerService.open(content).catch(onUnexpectedError);
this.openerService.open(content, { allowCommands: node.element.comment.body.isTrusted }).catch(onUnexpectedError);
},
disposeables: disposables
}

View File

@@ -625,11 +625,12 @@ export class ExtensionEditor extends EditorPane {
return;
}
// Only allow links with specific schemes
if (matchesScheme(link, Schemas.http) || matchesScheme(link, Schemas.https) || matchesScheme(link, Schemas.mailto)
|| (matchesScheme(link, Schemas.command) && URI.parse(link).path === ShowCurrentReleaseNotesActionId)
) {
if (matchesScheme(link, Schemas.http) || matchesScheme(link, Schemas.https) || matchesScheme(link, Schemas.mailto)) {
this.openerService.open(link);
}
if (matchesScheme(link, Schemas.command) && URI.parse(link).path === ShowCurrentReleaseNotesActionId) {
this.openerService.open(link, { allowCommands: true }); // TODO@sandy081 use commands service
}
}, null, this.contentDisposables));
return webview;

View File

@@ -430,7 +430,7 @@ class MarkerWidget extends Disposable {
this._register(onOpen(e => {
dom.EventHelper.stop(e, true);
this._openerService.open(codeUri);
this._openerService.open(codeUri, { allowCommands: true });
}));
const code = new HighlightedLabel(dom.append(this._codeLink, dom.$('.marker-code')), false);

View File

@@ -424,7 +424,7 @@ var requirejs = (function() {
if (matchesScheme(link, Schemas.http) || matchesScheme(link, Schemas.https) || matchesScheme(link, Schemas.mailto)
|| matchesScheme(link, Schemas.command)) {
this.openerService.open(link, { fromUserGesture: true });
this.openerService.open(link, { fromUserGesture: true, allowContributedOpeners: true, allowCommands: true });
}
}));

View File

@@ -755,7 +755,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
};
this._onDidClickSettingLink.fire(e);
} else {
this._openerService.open(content).catch(onUnexpectedError);
this._openerService.open(content, { allowCommands: true }).catch(onUnexpectedError);
}
},
disposeables

View File

@@ -365,7 +365,7 @@ class HelpItem extends HelpItemBase {
}
protected async takeAction(extensionDescription: IExtensionDescription, url: string): Promise<void> {
await this.openerService.open(URI.parse(url));
await this.openerService.open(URI.parse(url), { allowCommands: true });
}
}

View File

@@ -189,7 +189,7 @@ export class WalkThroughPart extends EditorPane {
this.notificationService.info(localize('walkThrough.gitNotFound', "It looks like Git is not installed on your system."));
return;
}
this.openerService.open(this.addFrom(uri));
this.openerService.open(this.addFrom(uri), { allowCommands: true });
}
private addFrom(uri: URI) {