mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Cleanup
This commit is contained in:
@ -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 `<!DOCTYPE html>
|
||||
@ -83,13 +80,12 @@ class ColorsViewProvider implements vscode.WebviewViewProvider {
|
||||
<!--
|
||||
Use a content security policy to only allow loading images from https or from our extension directory,
|
||||
and only allow scripts that have a specific nonce.
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
||||
-->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src ${webview.cspSource}; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href="${styleUri}" rel="stylesheet" />
|
||||
<link href="${styleUri}" rel="stylesheet">
|
||||
|
||||
<title>Cat Colors</title>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user