mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
parent
2ecea7fa70
commit
389938998f
|
@ -15,6 +15,10 @@ import { DynamicMarkdownPreview, IManagedMarkdownPreview, StaticMarkdownPreview
|
||||||
import { MarkdownPreviewConfigurationManager } from './previewConfig';
|
import { MarkdownPreviewConfigurationManager } from './previewConfig';
|
||||||
import { scrollEditorToLine, StartingScrollFragment } from './scrolling';
|
import { scrollEditorToLine, StartingScrollFragment } from './scrolling';
|
||||||
import { TopmostLineMonitor } from './topmostLineMonitor';
|
import { TopmostLineMonitor } from './topmostLineMonitor';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
|
|
||||||
export interface DynamicPreviewSettings {
|
export interface DynamicPreviewSettings {
|
||||||
readonly resourceColumn: vscode.ViewColumn;
|
readonly resourceColumn: vscode.ViewColumn;
|
||||||
|
@ -153,23 +157,59 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview
|
||||||
webview: vscode.WebviewPanel,
|
webview: vscode.WebviewPanel,
|
||||||
state: any
|
state: any
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const resource = vscode.Uri.parse(state.resource);
|
try {
|
||||||
const locked = state.locked;
|
const resource = vscode.Uri.parse(state.resource);
|
||||||
const line = state.line;
|
const locked = state.locked;
|
||||||
const resourceColumn = state.resourceColumn;
|
const line = state.line;
|
||||||
|
const resourceColumn = state.resourceColumn;
|
||||||
|
|
||||||
const preview = await DynamicMarkdownPreview.revive(
|
const preview = DynamicMarkdownPreview.revive(
|
||||||
{ resource, locked, line, resourceColumn },
|
{ resource, locked, line, resourceColumn },
|
||||||
webview,
|
webview,
|
||||||
this._contentProvider,
|
this._contentProvider,
|
||||||
this._previewConfigurations,
|
this._previewConfigurations,
|
||||||
this._workspace,
|
this._workspace,
|
||||||
this._logger,
|
this._logger,
|
||||||
this._topmostLineMonitor,
|
this._topmostLineMonitor,
|
||||||
this._contributions,
|
this._contributions,
|
||||||
this._tocProvider);
|
this._tocProvider);
|
||||||
|
|
||||||
this.registerDynamicPreview(preview);
|
this.registerDynamicPreview(preview);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
|
webview.webview.html = /* html */`<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
|
||||||
|
<!-- Disable pinch zooming -->
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<title>Markdown Preview</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<meta http-equiv="Content-Security-Policy" content="default-src 'none';">
|
||||||
|
</head>
|
||||||
|
<body class="error-container">
|
||||||
|
<p>${localize('preview.restoreError', "An unexpected error occurred while restoring the Markdown preview.")}</p>
|
||||||
|
</body>
|
||||||
|
</html>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resolveCustomTextEditor(
|
public async resolveCustomTextEditor(
|
||||||
|
|
Loading…
Reference in a new issue