A sample VS Code extension demonstrating Webview integration.
- Open Webview: Creates and displays a Webview panel with custom HTML, CSS, and JavaScript.
- Bi-directional Communication:
- Sends messages from the extension to the Webview.
- Receives messages from the Webview and displays them as VS Code notifications.
- Resource Loading: Demonstrates how to load local CSS and JS files into a Webview using
asWebviewUri.
Hello World: Opens the Webview panel.Send Message to Webview: Sends a message from the extension to the active Webview.
- Press
F5to start debugging and open a new Extension Development Host window. - Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P). - Run
Hello Worldto open the Webview. - Run
Send Message to Webviewto see the text update in the Webview. - Interact with buttons in the Webview to see notifications in VS Code.
Webview の統合方法を実演するサンプルの VS Code 拡張機能です。
- Webview の表示: カスタムの HTML、CSS、および JavaScript を使用した Webview パネルを作成・表示します。
- 双方向通信:
- 拡張機能から Webview へメッセージを送信します。
- Webview からメッセージを受信し、VS Code の通知として表示します。
- リソースの読み込み:
asWebviewUriを使用して、ローカルの CSS および JS ファイルを Webview に読み込む方法を示します。
Hello World: Webview パネルを開きます。Send Message to Webview: 拡張機能からアクティブな Webview へメッセージを送信します。
F5キーを押してデバッグを開始し、新しい「拡張機能開発ホスト」ウィンドウを開きます。- コマンドパレットを開きます(
Ctrl+Shift+P/Cmd+Shift+P)。 Hello Worldを実行して Webview を開きます。Send Message to Webviewを実行して、Webview 内のテキストが更新されることを確認します。- Webview 内のボタンを操作して、VS Code 側で通知が表示されることを確認します。