mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
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:
26
extensions/markdown/media/loading.js
Normal file
26
extensions/markdown/media/loading.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(function () {
|
||||
const unloadedStyles = [];
|
||||
|
||||
window.onStyleLoadError = (event) => {
|
||||
const source = event.target.dataset.source;
|
||||
unloadedStyles.push(source);
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
if (!unloadedStyles.length) {
|
||||
return;
|
||||
}
|
||||
const args = [unloadedStyles];
|
||||
window.parent.postMessage({
|
||||
command: 'did-click-link',
|
||||
data: `command:_markdown.onPreviewStyleLoadError?${encodeURIComponent(JSON.stringify(args))}`
|
||||
}, 'file://');
|
||||
});
|
||||
}());
|
||||
Reference in New Issue
Block a user