Add acquireVsCodeApi to get handle to vscode api inside webview

Fixes #48540
This commit is contained in:
Matt Bierner
2018-04-25 22:27:51 -07:00
parent 6d7bb1a174
commit 82d97b4c3c
8 changed files with 155 additions and 118 deletions

View File

@@ -2,10 +2,13 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { postCommand } from './messaging';
import { MessagePoster } from './messaging';
export class StyleLoadingMonitor {
private unloadedStyles: string[] = [];
private finishedLoading: boolean = false;
private poster?: MessagePoster;
constructor() {
const onStyleLoadError = (event: any) => {
@@ -25,7 +28,17 @@ export class StyleLoadingMonitor {
if (!this.unloadedStyles.length) {
return;
}
postCommand('_markdown.onPreviewStyleLoadError', [this.unloadedStyles]);
this.finishedLoading = true;
if (this.poster) {
this.poster.postCommand('_markdown.onPreviewStyleLoadError', [this.unloadedStyles]);
}
});
}
public setPoster(poster: MessagePoster): void {
this.poster = poster;
if (this.finishedLoading) {
poster.postCommand('_markdown.onPreviewStyleLoadError', [this.unloadedStyles]);
}
}
}