mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Update custom editor api
For #77131 - Use a class for `CustomDocument` instead of an interface. Extensions can now add their own data to a `CustomDocument` by sublassing - Renamed `resolveCustomDocument` to `openCustomDocument` and require that extensions return a `CustomDocument` - Exposed edits on `CustomDocument` - Made the third parameter of `registerCustomEditorProvider` a generic options bag that takes a `webviewOptions`
This commit is contained in:
@@ -63,6 +63,8 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview
|
||||
|
||||
private _activePreview: DynamicMarkdownPreview | undefined = undefined;
|
||||
|
||||
private readonly customEditorViewType = 'vscode.markdown.preview.editor';
|
||||
|
||||
public constructor(
|
||||
private readonly _contentProvider: MarkdownContentProvider,
|
||||
private readonly _logger: Logger,
|
||||
@@ -70,7 +72,7 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview
|
||||
) {
|
||||
super();
|
||||
this._register(vscode.window.registerWebviewPanelSerializer(DynamicMarkdownPreview.viewType, this));
|
||||
this._register(vscode.window.registerCustomEditorProvider('vscode.markdown.preview.editor', this));
|
||||
this._register(vscode.window.registerCustomEditorProvider(this.customEditorViewType, this));
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
@@ -148,8 +150,8 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview
|
||||
this.registerDynamicPreview(preview);
|
||||
}
|
||||
|
||||
public async resolveCustomDocument(_document: vscode.CustomDocument): Promise<void> {
|
||||
// noop
|
||||
public async openCustomDocument(uri: vscode.Uri) {
|
||||
return new vscode.CustomDocument(this.customEditorViewType, uri);
|
||||
}
|
||||
|
||||
public async resolveCustomTextEditor(
|
||||
|
||||
Reference in New Issue
Block a user