Skip to content

Commit 2eb4682

Browse files
committed
[UXP-114] Fix issue when markdown is disabled
1 parent b056eff commit 2eb4682

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { of as observableOf } from 'rxjs';
2+
3+
export const MathServiceMock = jasmine.createSpyObj('MathService', {
4+
ready: jasmine.createSpy('ready').and.returnValue(observableOf(true)),
5+
render: jasmine.createSpy('render'),
6+
});

src/app/shared/utils/markdown.directive.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,21 @@ export class MarkdownDirective implements OnInit, OnDestroy {
4646

4747
async render(value: string, forcePreview = false): Promise<SafeHtml> {
4848
if (isEmpty(value) || (!environment.markdown.enabled && !forcePreview)) {
49-
return value;
50-
}
51-
const MarkdownIt = await this.markdownIt;
52-
const md = new MarkdownIt({
53-
html: true,
54-
linkify: true,
55-
});
49+
this.el.innerHTML = value;
50+
return;
51+
} else {
52+
const MarkdownIt = await this.markdownIt;
53+
const md = new MarkdownIt({
54+
html: true,
55+
linkify: true,
56+
});
5657

57-
const html = this.sanitizer.sanitize(SecurityContext.HTML, md.render(value));
58-
this.el.innerHTML = html;
58+
const html = this.sanitizer.sanitize(SecurityContext.HTML, md.render(value));
59+
this.el.innerHTML = html;
5960

60-
if (environment.markdown.mathjax) {
61-
this.renderMathjax();
61+
if (environment.markdown.mathjax) {
62+
this.renderMathjax();
63+
}
6264
}
6365
}
6466

0 commit comments

Comments
 (0)