mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Small cleanup follow up on #236145
- Don't send content as json - Reuse existing load helper
This commit is contained in:
@@ -16,18 +16,22 @@ export interface PreviewSettings {
|
||||
readonly webviewResourceRoot: string;
|
||||
}
|
||||
|
||||
export function getData<T = {}>(key: string): T {
|
||||
export function getRawData(key: string): string {
|
||||
const element = document.getElementById('vscode-markdown-preview-data');
|
||||
if (element) {
|
||||
const data = element.getAttribute(key);
|
||||
if (data) {
|
||||
return JSON.parse(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Could not load data for ${key}`);
|
||||
}
|
||||
|
||||
export function getData<T = {}>(key: string): T {
|
||||
return JSON.parse(getRawData(key));
|
||||
}
|
||||
|
||||
export class SettingsManager {
|
||||
private _settings: PreviewSettings = getData('data-settings');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user