Merge from vscode dbe62be3266ffb6772a7f3db0bf61d63f4aa7f65 (#9337)

This commit is contained in:
Anthony Dresser
2020-02-26 00:23:48 -08:00
committed by GitHub
parent d2892ff78b
commit 067fcc8dfb
42 changed files with 384 additions and 409 deletions

View File

@@ -22,10 +22,10 @@
"onCommand:imagePreview.zoomOut"
],
"contributes": {
"webviewEditors": [
"customEditors": [
{
"viewType": "imagePreview.previewEditor",
"displayName": "%webviewEditors.displayName%",
"displayName": "%customEditors.displayName%",
"priority": "builtin",
"selector": [
{

View File

@@ -1,7 +1,7 @@
{
"displayName": "Image Preview",
"description": "Provides VS Code's built-in image preview",
"webviewEditors.displayName": "Image Preview",
"customEditors.displayName": "Image Preview",
"command.zoomIn": "Zoom in",
"command.zoomOut": "Zoom out"
}

View File

@@ -23,7 +23,7 @@ export function activate(context: vscode.ExtensionContext) {
const previewManager = new PreviewManager(extensionRoot, sizeStatusBarEntry, binarySizeStatusBarEntry, zoomStatusBarEntry);
context.subscriptions.push(vscode.window.registerWebviewCustomEditorProvider(PreviewManager.viewType, previewManager));
context.subscriptions.push(vscode.window.registerCustomEditorProvider(PreviewManager.viewType, previewManager));
context.subscriptions.push(vscode.commands.registerCommand('imagePreview.zoomIn', () => {
previewManager.activePreview?.zoomIn();

View File

@@ -13,7 +13,7 @@ import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
const localize = nls.loadMessageBundle();
export class PreviewManager implements vscode.WebviewCustomEditorProvider {
export class PreviewManager implements vscode.CustomEditorProvider {
public static readonly viewType = 'imagePreview.previewEditor';
@@ -27,12 +27,12 @@ export class PreviewManager implements vscode.WebviewCustomEditorProvider {
private readonly zoomStatusBarEntry: ZoomStatusBarEntry,
) { }
public async provideWebviewCustomEditorDocument(resource: vscode.Uri) {
return vscode.window.createWebviewEditorCustomDocument(PreviewManager.viewType, resource, undefined, {});
public async resolveCustomDocument(_document: vscode.CustomDocument): Promise<vscode.CustomEditorCapabilities> {
return {};
}
public async resolveWebviewCustomEditor(
document: vscode.WebviewEditorCustomDocument,
public async resolveCustomEditor(
document: vscode.CustomDocument,
webviewEditor: vscode.WebviewPanel,
): Promise<void> {
const preview = new Preview(this.extensionRoot, document.uri, webviewEditor, this.sizeStatusBarEntry, this.binarySizeStatusBarEntry, this.zoomStatusBarEntry);