Generalise and resuse markdown rendering function
This commit is contained in:
parent
1fbb0b9779
commit
1ad39acdbf
|
@ -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<string>) {
|
||||
return this.loadContents(() => content
|
||||
.then(marked.parse)
|
||||
.then(renderBody)
|
||||
.then<void>(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<void>(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;
|
||||
|
|
Loading…
Reference in a new issue