Show Warning When a markdown.styles fails to load (#27105)

Fixes #8488

**Bug**
Currently there is no indication in the markdown preview when a `markdown.styles` element fails to load

**Fix**
Show an alert then a stylesheet does not load
This commit is contained in:
Matt Bierner
2017-05-22 18:30:24 -07:00
committed by GitHub
parent edbab0e988
commit 7403245d3d
3 changed files with 34 additions and 1 deletions

View File

@@ -166,7 +166,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
private computeCustomStyleSheetIncludes(uri: vscode.Uri): string {
if (this.config.styles && Array.isArray(this.config.styles)) {
return this.config.styles.map((style) => {
return `<link rel="stylesheet" href="${this.fixHref(uri, style)}" type="text/css" media="screen">`;
return `<link rel="stylesheet" data-source="${style.replace(/"/g, '&quot;')}" onerror="onStyleLoadError(event)" href="${this.fixHref(uri, style)}" type="text/css" media="screen">`;
}).join('\n');
}
return '';
@@ -238,6 +238,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
${csp}
<meta id="vscode-markdown-preview-data" data-settings="${JSON.stringify(initialData).replace(/"/g, '&quot;')}" data-strings="${JSON.stringify(previewStrings).replace(/"/g, '&quot;')}">
<script src="${this.getMediaPath('csp.js')}" nonce="${nonce}"></script>
<script src="${this.getMediaPath('loading.js')}" nonce="${nonce}"></script>
${this.getStyles(uri, nonce)}
<base href="${document.uri.toString(true)}">
</head>