ngx-admin/docs/app/blocks/components/md-block/md-block.component.ts

39 lines
998 B
TypeScript
Raw Normal View History

2019-07-16 08:38:11 +03:00
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2021-09-24 15:56:10 +03:00
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
2019-07-16 08:38:11 +03:00
@Component({
selector: 'ngx-md-block',
template: `
2021-09-24 15:56:10 +03:00
<nb-card *ngFor="let section of content;" [ngxFragment]="section.fragment">
2019-07-16 08:38:11 +03:00
<nb-card-body>
2021-09-24 15:56:10 +03:00
<div [innerHtml]="getTemplate(section.html)"></div>
2019-07-16 08:38:11 +03:00
</nb-card-body>
</nb-card>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgxMdBLockComponent {
2021-09-24 15:56:10 +03:00
@Input() content: MdChildren[] = [];
2019-07-16 08:38:11 +03:00
2021-09-24 15:56:10 +03:00
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;
2019-07-16 08:38:11 +03:00
}