mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Make previewManager implement WebviewEditorProvider directly
This commit is contained in:
@@ -23,13 +23,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
const previewManager = new PreviewManager(extensionRoot, sizeStatusBarEntry, binarySizeStatusBarEntry, zoomStatusBarEntry);
|
||||
|
||||
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(
|
||||
PreviewManager.viewType,
|
||||
{
|
||||
async resolveWebviewEditor({ resource }, editor: vscode.WebviewPanel): Promise<vscode.WebviewEditorCapabilities> {
|
||||
return previewManager.resolve(resource, editor);
|
||||
}
|
||||
}));
|
||||
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(PreviewManager.viewType, previewManager));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('imagePreview.zoomIn', () => {
|
||||
previewManager.activePreview?.zoomIn();
|
||||
|
||||
@@ -13,7 +13,7 @@ import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
export class PreviewManager {
|
||||
export class PreviewManager implements vscode.WebviewEditorProvider {
|
||||
|
||||
public static readonly viewType = 'imagePreview.previewEditor';
|
||||
|
||||
@@ -27,11 +27,11 @@ export class PreviewManager {
|
||||
private readonly zoomStatusBarEntry: ZoomStatusBarEntry,
|
||||
) { }
|
||||
|
||||
public resolve(
|
||||
resource: vscode.Uri,
|
||||
public async resolveWebviewEditor(
|
||||
input: { readonly resource: vscode.Uri, },
|
||||
webviewEditor: vscode.WebviewPanel,
|
||||
): vscode.WebviewEditorCapabilities {
|
||||
const preview = new Preview(this.extensionRoot, resource, webviewEditor, this.sizeStatusBarEntry, this.binarySizeStatusBarEntry, this.zoomStatusBarEntry);
|
||||
): Promise<vscode.WebviewEditorCapabilities> {
|
||||
const preview = new Preview(this.extensionRoot, input.resource, webviewEditor, this.sizeStatusBarEntry, this.binarySizeStatusBarEntry, this.zoomStatusBarEntry);
|
||||
this._previews.add(preview);
|
||||
this.setActivePreview(preview);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user