Small cleanup follow up on #236145

- Don't send content as json
- Reuse existing load helper
This commit is contained in:
Matt Bierner
2024-12-17 11:59:05 -08:00
parent 5e26b3d7c3
commit a47b13ebc2
3 changed files with 17 additions and 14 deletions

View File

@@ -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');