From 1ad39acdbf22e1e293cd051dca6bda48d619a246 Mon Sep 17 00:00:00 2001 From: XVincentX Date: Wed, 14 Sep 2016 09:45:37 +0200 Subject: [PATCH] Generalise and resuse markdown rendering function --- .../electron-browser/extensionEditor.ts | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts index 1cddb3d2668..6b332603f86 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts @@ -269,8 +269,8 @@ export class ExtensionEditor extends BaseEditor { } } - private openReadme(extension: IExtension) { - return this.loadContents(() => this.extensionReadme.get() + private openMarkdown(extension: IExtension, content: TPromise) { + return this.loadContents(() => content .then(marked.parse) .then(renderBody) .then(body => { @@ -292,6 +292,14 @@ export class ExtensionEditor extends BaseEditor { })); } + private openReadme(extension: IExtension) { + return this.openMarkdown(extension, this.extensionReadme.get()); + } + + private openChangelog(extension : IExtension) { + return this.openMarkdown(extension, this.extensionChangelog.get()); + } + private openContributions(extension: IExtension) { return this.loadContents(() => this.extensionManifest.get() .then(manifest => { @@ -317,30 +325,6 @@ export class ExtensionEditor extends BaseEditor { })); } - private openChangelog(extension : IExtension) { - return this.loadContents(() => this.extensionChangelog.get() - .then(marked.parse) - .then(renderBody) - .then(body => { - const webview = new WebView( - this.content, - document.querySelector('.monaco-editor-background') - ); - - webview.style(this.themeService.getColorTheme()); - webview.contents = [body]; - - const linkListener = webview.onDidClickLink(link => shell.openExternal(link.toString(true))); - const themeListener = this.themeService.onDidColorThemeChange(themeId => webview.style(themeId)); - this.contentDisposables.push(webview, linkListener, themeListener); - }) - .then(null, () => { - const p = append(this.content, $('p')); - p.textContent = localize('noChangelog', "No CHANGELOG available."); - })); - - } - private static renderSettings(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): void { const contributes = manifest.contributes; const configuration = contributes && contributes.configuration; -- GitLab