66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import * as vscode from "vscode";
|
|
import { getNonce } from "./getNonce";
|
|
|
|
export class ViewCommandPalletteWebviewViewProvider implements vscode.WebviewViewProvider {
|
|
_webviewView?: vscode.WebviewView;
|
|
|
|
constructor(private readonly _extensionContext: vscode.ExtensionContext) {
|
|
}
|
|
|
|
public revive(webviewView: vscode.WebviewView) {
|
|
this._webviewView = webviewView;
|
|
}
|
|
|
|
public resolveWebviewView(webviewView: vscode.WebviewView) {
|
|
this._webviewView = webviewView;
|
|
webviewView.webview.options = {
|
|
// Allow scripts in the webview
|
|
enableScripts: true,
|
|
|
|
localResourceRoots: [this._extensionContext.extensionUri],
|
|
};
|
|
|
|
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
|
|
}
|
|
|
|
private _getHtmlForWebview(webview: vscode.Webview) {
|
|
|
|
const imageA = webview.asWebviewUri(
|
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "Screenshot 2025-04-11 125031.png")
|
|
);
|
|
const imageB = webview.asWebviewUri(
|
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "Screenshot 2025-04-11 125350.png")
|
|
);
|
|
|
|
// Use a nonce to only allow a specific script to be run.
|
|
const nonce = getNonce();
|
|
|
|
return `<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<!--
|
|
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="img-src https: data:;
|
|
style-src 'unsafe-inline' ${webview.cspSource};
|
|
script-src 'nonce-${nonce}';">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
</head>
|
|
<body>
|
|
<h1>Infineon Technologies Americas Corp.</h1>
|
|
<ul>
|
|
<li>View</li>
|
|
<li>Command Pallette... Ctrl+Shift+P</li>
|
|
<li>Type Mesa or Leominster</li>
|
|
<li>Select item</li>
|
|
</ul>
|
|
<img src="${imageA}" alt="Screenshot 2025-04-11 125031.png" width="75%" height="75%">
|
|
<img src="${imageB}" alt="Screenshot 2025-04-11 125350" width="75%" height="75%">
|
|
</body>
|
|
</html>`;
|
|
}
|
|
}
|