]>
Commit | Line | Data |
---|---|---|
8ee25e17 C |
1 | import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core' |
2 | import { CustomMarkupService } from './custom-markup.service' | |
3 | ||
4 | @Component({ | |
5 | selector: 'my-custom-markup-container', | |
24893b52 | 6 | templateUrl: './custom-markup-container.component.html' |
8ee25e17 C |
7 | }) |
8 | export class CustomMarkupContainerComponent implements OnChanges { | |
9 | @ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement> | |
10 | ||
11 | @Input() content: string | |
12 | ||
0ca454e3 C |
13 | displayed = false |
14 | ||
8ee25e17 C |
15 | constructor ( |
16 | private customMarkupService: CustomMarkupService | |
17 | ) { } | |
18 | ||
19 | async ngOnChanges () { | |
20 | await this.buildElement() | |
21 | } | |
22 | ||
23 | private async buildElement () { | |
0ca454e3 C |
24 | if (!this.content) return |
25 | ||
26 | const { rootElement, componentsLoaded } = await this.customMarkupService.buildElement(this.content) | |
27 | this.contentWrapper.nativeElement.appendChild(rootElement) | |
8ee25e17 | 28 | |
0ca454e3 C |
29 | await componentsLoaded |
30 | ||
31 | this.displayed = true | |
32 | } | |
8ee25e17 | 33 | } |