mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
This should help improve scroll sync and also reduce the number of times we go out to the network if images are in the preview
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
export interface PreviewSettings {
|
|
readonly source: string;
|
|
readonly line?: number;
|
|
readonly fragment?: string
|
|
readonly lineCount: number;
|
|
readonly scrollPreviewWithEditor?: boolean;
|
|
readonly scrollEditorWithPreview: boolean;
|
|
readonly disableSecurityWarnings: boolean;
|
|
readonly doubleClickToSwitchToEditor: boolean;
|
|
readonly webviewResourceRoot: string;
|
|
}
|
|
|
|
export function getData<T = {}>(key: string): T {
|
|
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 class SettingsManager {
|
|
private _settings: PreviewSettings = getData('data-settings');
|
|
|
|
public get settings(): PreviewSettings {
|
|
return this._settings;
|
|
}
|
|
|
|
public updateSettings(newSettings: PreviewSettings) {
|
|
this._settings = newSettings;
|
|
}
|
|
}
|