mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
@@ -15,18 +15,26 @@ export interface PreviewSettings {
|
||||
|
||||
let cachedSettings: PreviewSettings | undefined = undefined;
|
||||
|
||||
export function getData(key: string): PreviewSettings {
|
||||
const element = document.getElementById('vscode-markdown-preview-data');
|
||||
if (element) {
|
||||
const data = element.getAttribute(key);
|
||||
if (data) {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Could not load data for ${key}`);
|
||||
}
|
||||
|
||||
export function getSettings(): PreviewSettings {
|
||||
if (cachedSettings) {
|
||||
return cachedSettings;
|
||||
}
|
||||
|
||||
const element = document.getElementById('vscode-markdown-preview-data');
|
||||
if (element) {
|
||||
const data = element.getAttribute('data-settings');
|
||||
if (data) {
|
||||
cachedSettings = JSON.parse(data);
|
||||
return cachedSettings!;
|
||||
}
|
||||
cachedSettings = getData('data-settings');
|
||||
if (cachedSettings) {
|
||||
return cachedSettings;
|
||||
}
|
||||
|
||||
throw new Error('Could not load settings');
|
||||
|
||||
Reference in New Issue
Block a user