mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Update webviews to use vscode styles
This commit is contained in:
@ -167,6 +167,14 @@ class CatCodingPanel {
|
||||
// And the uri we use to load this script in the webview
|
||||
const scriptUri = webview.asWebviewUri(scriptPathOnDisk);
|
||||
|
||||
// Local path to css styles
|
||||
const styleResetPath = vscode.Uri.joinPath(this._extensionUri, 'media', 'reset.css');
|
||||
const stylesPathMainPath = vscode.Uri.joinPath(this._extensionUri, 'media', 'vscode.css');
|
||||
|
||||
// Uri to load styles into webview
|
||||
const stylesResetUri = webview.asWebviewUri(styleResetPath);
|
||||
const stylesMainUri = webview.asWebviewUri(stylesPathMainPath);
|
||||
|
||||
// Use a nonce to only allow specific scripts to be run
|
||||
const nonce = getNonce();
|
||||
|
||||
@ -179,9 +187,13 @@ class CatCodingPanel {
|
||||
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} https:; script-src 'nonce-${nonce}';">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; img-src ${webview.cspSource} https:; script-src 'nonce-${nonce}';">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href="${stylesResetUri}" rel="stylesheet">
|
||||
<link href="${stylesMainUri}" rel="stylesheet">
|
||||
|
||||
<title>Cat Coding</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user