fix(docs): async md load

This commit is contained in:
evtkhvch 2021-09-24 15:56:10 +03:00
parent e77829a465
commit 0026c02fdf
7 changed files with 73 additions and 33 deletions

View file

@ -5,19 +5,34 @@
*/
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Component({
selector: 'ngx-md-block',
template: `
<nb-card *ngFor="let section of source;" [ngxFragment]="section.fragment">
<nb-card *ngFor="let section of content;" [ngxFragment]="section.fragment">
<nb-card-body>
<div [innerHtml]="section.html"></div>
<div [innerHtml]="getTemplate(section.html)"></div>
</nb-card-body>
</nb-card>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgxMdBLockComponent {
@Input() content: MdChildren[] = [];
@Input() source: string;
constructor(private readonly domSanitizer: DomSanitizer) {
}
// TODO: create NbDOMPurifyPipe
getTemplate(content: string): SafeHtml {
return this.domSanitizer.bypassSecurityTrustHtml(content);
}
}
interface MdChildren {
fragment: string;
html: string;
source: string;
title: string;
}