PeerTube/client/src/app/shared/shared-custom-markup/custom-markup-container.com...

27 lines
750 B
TypeScript
Raw Normal View History

import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core'
import { CustomMarkupService } from './custom-markup.service'
@Component({
selector: 'my-custom-markup-container',
templateUrl: './custom-markup-container.component.html'
})
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)
}
}