提交 0c8542b8 编写于 作者: J Joao Moreno

fixes #13049

上级 d17eeb1f
...@@ -23,12 +23,13 @@ import { WebviewEditor } from 'vs/workbench/parts/html/browser/webviewEditor'; ...@@ -23,12 +23,13 @@ import { WebviewEditor } from 'vs/workbench/parts/html/browser/webviewEditor';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMode } from 'vs/editor/common/modes'; import { IMode, TokenizationRegistry } from 'vs/editor/common/modes';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { addGAParameters } from 'vs/platform/telemetry/node/telemetryNodeUtils'; import { addGAParameters } from 'vs/platform/telemetry/node/telemetryNodeUtils';
import { generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
function renderBody(body: string): string { function renderBody(body: string, css: string): string {
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html> <html>
<head> <head>
...@@ -36,6 +37,7 @@ function renderBody(body: string): string { ...@@ -36,6 +37,7 @@ function renderBody(body: string): string {
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; media-src https:; script-src 'none'; style-src file: https: 'unsafe-inline'; child-src 'none'; frame-src 'none';"> <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; media-src https:; script-src 'none'; style-src file: https: 'unsafe-inline'; child-src 'none'; frame-src 'none';">
<link rel="stylesheet" type="text/css" href="${require.toUrl('./media/markdown.css')}"> <link rel="stylesheet" type="text/css" href="${require.toUrl('./media/markdown.css')}">
<style>${css}</style>
</head> </head>
<body>${body}</body> <body>${body}</body>
</html>`; </html>`;
...@@ -95,7 +97,9 @@ export class ReleaseNotesEditor extends WebviewEditor { ...@@ -95,7 +97,9 @@ export class ReleaseNotesEditor extends WebviewEditor {
return `<code>${tokenizeToString(code, modeId)}</code>`; return `<code>${tokenizeToString(code, modeId)}</code>`;
}; };
const body = renderBody(marked(text, { renderer })); const colorMap = TokenizationRegistry.getColorMap();
const css = generateTokensCSSForColorMap(colorMap);
const body = renderBody(marked(text, { renderer }), css);
this._webview = new WebView(this.content, this.partService.getContainer(Parts.EDITOR_PART), this._contextViewService, this.contextKey, this.findInputFocusContextKey); this._webview = new WebView(this.content, this.partService.getContainer(Parts.EDITOR_PART), this._contextViewService, this.contextKey, this.findInputFocusContextKey);
if (this.input && this.input instanceof ReleaseNotesInput) { if (this.input && this.input instanceof ReleaseNotesInput) {
const state = this.loadViewState(this.input.version); const state = this.loadViewState(this.input.version);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册