Documenting thoughts on direction for custom editor API

This documents the current thinking on the custom editor api. The current api proposal is not actually implemented yet
This commit is contained in:
Matt Bierner
2019-11-04 14:58:26 -08:00
parent cd4d7e6c2b
commit dcecb9eea6
8 changed files with 80 additions and 96 deletions
+2 -1
View File
@@ -22,8 +22,9 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(
PreviewManager.viewType,
{
async resolveWebviewEditor(resource: vscode.Uri, editor: vscode.WebviewEditor): Promise<void> {
async resolveWebviewEditor({ resource }, editor: vscode.WebviewPanel): Promise<vscode.WebviewEditorCapabilities> {
previewManager.resolve(resource, editor);
return {};
}
}));
+3 -3
View File
@@ -27,7 +27,7 @@ export class PreviewManager {
public resolve(
resource: vscode.Uri,
webviewEditor: vscode.WebviewEditor,
webviewEditor: vscode.WebviewPanel,
) {
const preview = new Preview(this.extensionRoot, resource, webviewEditor, this.sizeStatusBarEntry, this.zoomStatusBarEntry);
this._previews.add(preview);
@@ -73,7 +73,7 @@ class Preview extends Disposable {
constructor(
private readonly extensionRoot: vscode.Uri,
private readonly resource: vscode.Uri,
private readonly webviewEditor: vscode.WebviewEditor,
private readonly webviewEditor: vscode.WebviewPanel,
private readonly sizeStatusBarEntry: SizeStatusBarEntry,
private readonly zoomStatusBarEntry: ZoomStatusBarEntry,
) {
@@ -208,7 +208,7 @@ class Preview extends Disposable {
</html>`;
}
private getResourcePath(webviewEditor: vscode.WebviewEditor, resource: vscode.Uri, version: string) {
private getResourcePath(webviewEditor: vscode.WebviewPanel, resource: vscode.Uri, version: string) {
switch (resource.scheme) {
case 'data':
return encodeURI(resource.toString(true));