mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Add proposed webview view API For #46585 This adds a new `WebviewView` proposed api to VS Code that lets webview be used inside views. Webview views can be contributed using a contribution point such as : ```json "views": { "explorer": [ { "type": "webview", "id": "cats.cat", "name": "Cats", "visibility": "visible" } ] }, ``` * Use proper activation event * Transparent background * Fix resize observer * Adding documentation * Move webview view to new directory under workbench * Remove resolver By moving the webviews view into their own fodler, I was able to avoid the cycle the resolver was originally introduced for * Use enum in more places * Hook up title and visible properties for webview views * Remove test view * Prefer Thenable * Add unknown view type error to collector
36 lines
1.6 KiB
TypeScript
36 lines
1.6 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
|
|
import { PreviewManager } from './preview';
|
|
import { SizeStatusBarEntry } from './sizeStatusBarEntry';
|
|
import { ZoomStatusBarEntry } from './zoomStatusBarEntry';
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
const sizeStatusBarEntry = new SizeStatusBarEntry();
|
|
context.subscriptions.push(sizeStatusBarEntry);
|
|
|
|
const binarySizeStatusBarEntry = new BinarySizeStatusBarEntry();
|
|
context.subscriptions.push(binarySizeStatusBarEntry);
|
|
|
|
const zoomStatusBarEntry = new ZoomStatusBarEntry();
|
|
context.subscriptions.push(zoomStatusBarEntry);
|
|
|
|
const previewManager = new PreviewManager(context.extensionUri, sizeStatusBarEntry, binarySizeStatusBarEntry, zoomStatusBarEntry);
|
|
|
|
context.subscriptions.push(vscode.window.registerCustomEditorProvider(PreviewManager.viewType, previewManager, {
|
|
supportsMultipleEditorsPerDocument: true,
|
|
}));
|
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('imagePreview.zoomIn', () => {
|
|
previewManager.activePreview?.zoomIn();
|
|
}));
|
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('imagePreview.zoomOut', () => {
|
|
previewManager.activePreview?.zoomOut();
|
|
}));
|
|
}
|