未验证 提交 1ad39acd 编写于 作者: X XVincentX

Generalise and resuse markdown rendering function

上级 1fbb0b97
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册