import * as vscode from "vscode" ; export abstract class AbstractWebview implements vscode . Disposable { protected readonly viewType : string = "interview.webview" ; protected panel : vscode . WebviewPanel | undefined ; public dispose ( ) { if ( this . panel ) { this . panel . dispose ( ) ; } } protected showWebviewInternal ( ) { const { title , viewColumn , preserveFocus } = this . getWebviewOption ( ) ; this . panel = vscode . window . createWebviewPanel ( this . viewType , title , { viewColumn , preserveFocus , } , { enableScripts : true , } ) ; this . panel . webview . html = this . getWebviewContent ( ) ; } protected onDidDisposeWebview ( ) { this . panel = undefined ; } protected abstract getWebviewOption ( ) ; protected abstract getWebviewContent ( ) ; } export interface IWebviewOption { title : string ; viewColumn : vscode . ViewColumn ; preserveFocus ? : boolean ; }