Provider for readonly custom editors that use a custom document model.

Custom editors use {@linkcode CustomDocument} as their document model instead of a {@linkcode TextDocument}.

You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple text based documents, use {@linkcode CustomTextEditorProvider} instead.

Parameters:

T

Type of the custom document returned by this provider.

Fields

resolveCustomEditor(document:T, webviewPanel:WebviewPanel, token:CancellationToken):EitherType<Thenable<Void>, Void>

Resolve a custom editor for a given resource.

This is called whenever the user opens a new editor for this CustomEditorProvider.

@linkcode WebviewPanel} for additional details.

Parameters:

document

Document for the resource being resolved.

webviewPanel

The webview panel used to display the editor UI for this resource. During resolve, the provider must fill in the initial html for the content webview panel and hook up all the event listeners on it that it is interested in. The provider can also hold onto the WebviewPanel to use later for example in a command. See {

token

A cancellation token that indicates the result is no longer needed.

Returns:

Optional thenable indicating that the custom editor has been resolved.

openCustomDocument(uri:Uri, openContext:CustomDocumentOpenContext, token:CancellationToken):EitherType<Thenable<T>, T>

Create a new document for a given resource.

openCustomDocument is called when the first time an editor for a given resource is opened. The opened document is then passed to resolveCustomEditor so that the editor can be shown to the user.

Already opened CustomDocument are re-used if the user opened additional editors. When all editors for a given resource are closed, the CustomDocument is disposed of. Opening an editor at this point will trigger another call to openCustomDocument.

Parameters:

uri

Uri of the document to open.

openContext

Additional information about the opening custom document.

token

A cancellation token that indicates the result is no longer needed.

Returns:

The custom document.