mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -19,7 +19,7 @@ const settings = getSettings();
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
// Set VS Code state
|
||||
let state = getData('data-state');
|
||||
let state = getData<{ line: number }>('data-state');
|
||||
vscode.setState(state);
|
||||
|
||||
const messaging = createPosterForVsCode(vscode);
|
||||
@@ -131,8 +131,8 @@ document.addEventListener('click', event => {
|
||||
if (node.getAttribute('href').startsWith('#')) {
|
||||
break;
|
||||
}
|
||||
if (node.href.startsWith('file://') || node.href.startsWith('vscode-resource:')) {
|
||||
const [path, fragment] = node.href.replace(/^(file:\/\/|vscode-resource:)/i, '').split('#');
|
||||
if (node.href.startsWith('file://') || node.href.startsWith('vscode-resource:') || node.href.startsWith(settings.webviewResourceRoot)) {
|
||||
const [path, fragment] = node.href.replace(/^(file:\/\/|vscode-resource:)/i, '').replace(new RegExp(`^${escapeRegExp(settings.webviewResourceRoot)}`)).split('#');
|
||||
messaging.postMessage('clickLink', { path, fragment });
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -157,4 +157,8 @@ if (settings.scrollEditorWithPreview) {
|
||||
}
|
||||
}
|
||||
}, 50));
|
||||
}
|
||||
|
||||
function escapeRegExp(text: string) {
|
||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
}
|
||||
@@ -4,18 +4,19 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface PreviewSettings {
|
||||
source: string;
|
||||
line: number;
|
||||
lineCount: number;
|
||||
scrollPreviewWithEditor?: boolean;
|
||||
scrollEditorWithPreview: boolean;
|
||||
disableSecurityWarnings: boolean;
|
||||
doubleClickToSwitchToEditor: boolean;
|
||||
readonly source: string;
|
||||
readonly line: number;
|
||||
readonly lineCount: number;
|
||||
readonly scrollPreviewWithEditor?: boolean;
|
||||
readonly scrollEditorWithPreview: boolean;
|
||||
readonly disableSecurityWarnings: boolean;
|
||||
readonly doubleClickToSwitchToEditor: boolean;
|
||||
readonly webviewResourceRoot: string;
|
||||
}
|
||||
|
||||
let cachedSettings: PreviewSettings | undefined = undefined;
|
||||
|
||||
export function getData(key: string): PreviewSettings {
|
||||
export function getData<T = {}>(key: string): T {
|
||||
const element = document.getElementById('vscode-markdown-preview-data');
|
||||
if (element) {
|
||||
const data = element.getAttribute(key);
|
||||
|
||||
Reference in New Issue
Block a user