2021-05-31 11:33:49 +02:00
|
|
|
import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core'
|
|
|
|
import { CustomMarkupService } from './custom-markup.service'
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-custom-markup-container',
|
2021-06-29 15:17:01 +02:00
|
|
|
templateUrl: './custom-markup-container.component.html'
|
2021-05-31 11:33:49 +02:00
|
|
|
})
|
|
|
|
export class CustomMarkupContainerComponent implements OnChanges {
|
|
|
|
@ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement>
|
|
|
|
|
|
|
|
@Input() content: string
|
|
|
|
|
|
|
|
constructor (
|
|
|
|
private customMarkupService: CustomMarkupService
|
|
|
|
) { }
|
|
|
|
|
|
|
|
async ngOnChanges () {
|
|
|
|
await this.buildElement()
|
|
|
|
}
|
|
|
|
|
|
|
|
private async buildElement () {
|
|
|
|
const element = await this.customMarkupService.buildElement(this.content)
|
|
|
|
this.contentWrapper.nativeElement.appendChild(element)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|