vscode#CustomReadonlyEditorProvider TypeScript Examples

The following examples show how to use vscode#CustomReadonlyEditorProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoundPlayerProvider.ts    From vscode-sound-player with MIT License 6 votes vote down vote up
export class SoundPlayerProvider implements CustomReadonlyEditorProvider<SoundPlayerDocument> {

    private html: Promise<string>

    constructor(context: ExtensionContext) {
        this.html = GetWebviewContent(context.asAbsolutePath('public'))
    }

    openCustomDocument(uri: Uri): SoundPlayerDocument {
        return new SoundPlayerDocument(uri)
    }

    async resolveCustomEditor(document: SoundPlayerDocument, webviewPanel: WebviewPanel): Promise<void> {
        webviewPanel.webview.options = {
            enableScripts: true
        }
        const html = await this.html
        webviewPanel.webview.html = html
        const result = await document.parseResult
        webviewPanel.webview.postMessage(result)
    }
}