Allow updating webview settings after creation

Fixes #51733
This commit is contained in:
Matt Bierner
2018-06-13 14:35:15 -07:00
parent 612806b804
commit 68afee908e
8 changed files with 44 additions and 13 deletions

View File

@@ -428,6 +428,7 @@ export interface MainThreadWebviewsShape extends IDisposable {
$reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void;
$setTitle(handle: WebviewPanelHandle, value: string): void;
$setHtml(handle: WebviewPanelHandle, value: string): void;
$setOptions(handle: WebviewPanelHandle, options: vscode.WebviewOptions): void;
$postMessage(handle: WebviewPanelHandle, value: any): Thenable<boolean>;
$registerSerializer(viewType: string): void;

View File

@@ -19,7 +19,7 @@ export class ExtHostWebview implements vscode.Webview {
private _options: vscode.WebviewOptions;
private _isDisposed: boolean = false;
readonly _onMessageEmitter = new Emitter<any>();
public readonly _onMessageEmitter = new Emitter<any>();
public readonly onDidReceiveMessage: Event<any> = this._onMessageEmitter.event;
constructor(
@@ -32,16 +32,16 @@ export class ExtHostWebview implements vscode.Webview {
this._options = options;
}
dispose() {
public dispose() {
this._onMessageEmitter.dispose();
}
get html(): string {
public get html(): string {
this.assertNotDisposed();
return this._html;
}
set html(value: string) {
public set html(value: string) {
this.assertNotDisposed();
if (this._html !== value) {
this._html = value;
@@ -49,11 +49,17 @@ export class ExtHostWebview implements vscode.Webview {
}
}
get options(): vscode.WebviewOptions {
public get options(): vscode.WebviewOptions {
this.assertNotDisposed();
return this._options;
}
public set options(newOptions: vscode.WebviewOptions) {
this.assertNotDisposed();
this._proxy.$setOptions(this._handle, newOptions);
this._options = newOptions;
}
public postMessage(message: any): Thenable<boolean> {
this.assertNotDisposed();
return this._proxy.$postMessage(this._handle, message);