From d4cf59d14726c1b959f4d520244720ecaf820b44 Mon Sep 17 00:00:00 2001 From: Kamil Kosek Date: Fri, 23 Jun 2017 01:08:38 +0200 Subject: [PATCH 1/3] Remove JavaScript/CSS restriction from HTML Content View --- src/features/CustomViews.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/CustomViews.ts b/src/features/CustomViews.ts index 35f5b3a0a7..00f0b3a654 100644 --- a/src/features/CustomViews.ts +++ b/src/features/CustomViews.ts @@ -179,7 +179,7 @@ class HtmlContentView extends CustomView { getContent(): string { // Return an HTML page which disables JavaScript in content by default - return `${this.htmlContent}`; + return `${this.htmlContent}`; } } From 3a5c396221bcb4712d9806f776f76965b37dbc38 Mon Sep 17 00:00:00 2001 From: Kamil Kosek Date: Fri, 23 Jun 2017 01:09:36 +0200 Subject: [PATCH 2/3] Implement InvokeRegisteredEditorCommand --- src/features/ExtensionCommands.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/features/ExtensionCommands.ts b/src/features/ExtensionCommands.ts index 9eb2bff24a..91e8e1ea21 100644 --- a/src/features/ExtensionCommands.ts +++ b/src/features/ExtensionCommands.ts @@ -168,10 +168,14 @@ export interface StatusBarMessageDetails { message: string; timeout?: number; } +interface InvokeRegisteredEditorCommandParameter{ + commandName : string +} export class ExtensionCommandsFeature implements IFeature { private command: vscode.Disposable; + private command2: vscode.Disposable; private languageClient: LanguageClient; private extensionCommands: ExtensionCommand[] = []; @@ -191,6 +195,21 @@ export class ExtensionCommandsFeature implements IFeature { this.showExtensionCommands(this.languageClient); }); + this.command2 = vscode.commands.registerCommand('PowerShell.InvokeRegisteredEditorCommand',(param : InvokeRegisteredEditorCommandParameter) => { + if(this.extensionCommands.length == 0){ + return; + } + + let commandToExecute = this.extensionCommands.find(x => x.name === param.commandName); + + if(commandToExecute){ + this.languageClient.sendRequest( + InvokeExtensionCommandRequest.type, + { name: commandToExecute.name, + context: this.getEditorContext() }); + } + }); + } public setLanguageClient(languageclient: LanguageClient) { @@ -248,6 +267,7 @@ export class ExtensionCommandsFeature implements IFeature { public dispose() { this.command.dispose(); + this.command2.dispose(); } private addExtensionCommand(command: ExtensionCommandAddedNotificationBody) { From 5adbcf479eb182a5549f1a1f63494d563df42bf0 Mon Sep 17 00:00:00 2001 From: Kamil Kosek Date: Fri, 23 Jun 2017 16:01:55 +0200 Subject: [PATCH 3/3] Revert "Remove JavaScript/CSS restriction from HTML Content View" This reverts commit d4cf59d14726c1b959f4d520244720ecaf820b44. --- src/features/CustomViews.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/CustomViews.ts b/src/features/CustomViews.ts index 00f0b3a654..35f5b3a0a7 100644 --- a/src/features/CustomViews.ts +++ b/src/features/CustomViews.ts @@ -179,7 +179,7 @@ class HtmlContentView extends CustomView { getContent(): string { // Return an HTML page which disables JavaScript in content by default - return `${this.htmlContent}`; + return `${this.htmlContent}`; } }