diff --git a/webview-view-sample/src/extension.ts b/webview-view-sample/src/extension.ts index d5adc152..8e48f793 100644 --- a/webview-view-sample/src/extension.ts +++ b/webview-view-sample/src/extension.ts @@ -55,24 +55,21 @@ class ColorsViewProvider implements vscode.WebviewViewProvider { } public addColor() { - // TODO: add reveal + // TODO: add call to reveal + if (this._view) { this._view.webview.postMessage({ type: 'addColor' }); } } private _getHtmlForWebview(webview: vscode.Webview) { - // Local path to main script run in the webview - const scriptPathOnDisk = vscode.Uri.joinPath(this._extensionUri, 'media', 'main.js'); - - // And the uri we use to load this script in the webview - const scriptUri = webview.asWebviewUri(scriptPathOnDisk); + // Get the local path to main script run in the webview, then convert it to a uri we can use in the webview. + const scriptUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'media', 'main.js')); + // Do the same for the stylesheet. const styleUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'media', 'main.css')); - const catImagePath = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'media', 'cat.jpg')); - - // Use a nonce to only allow specific scripts to be run + // Use a nonce to only allow a specific script to be run. const nonce = getNonce(); return ` @@ -83,13 +80,12 @@ class ColorsViewProvider implements vscode.WebviewViewProvider { - + - + Cat Colors