From 789ba349318e7ff012590491e76087a1204cccd4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 14:52:27 +0100 Subject: Support mailto links for custom markup --- .../custom-markup-container.component.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'client/src/app/shared/shared-custom-markup') diff --git a/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts b/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts index 4e802b14d..b2ee2d8f2 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts @@ -6,9 +6,9 @@ import { CustomMarkupService } from './custom-markup.service' templateUrl: './custom-markup-container.component.html' }) export class CustomMarkupContainerComponent implements OnChanges { - @ViewChild('contentWrapper') contentWrapper: ElementRef + @ViewChild('contentWrapper', { static: true }) contentWrapper: ElementRef - @Input() content: string + @Input() content: string | HTMLDivElement displayed = false @@ -17,17 +17,23 @@ export class CustomMarkupContainerComponent implements OnChanges { ) { } async ngOnChanges () { - await this.buildElement() + await this.rebuild() } - private async buildElement () { - if (!this.content) return + private async rebuild () { + if (this.content instanceof HTMLDivElement) { + return this.loadElement(this.content) + } const { rootElement, componentsLoaded } = await this.customMarkupService.buildElement(this.content) - this.contentWrapper.nativeElement.appendChild(rootElement) - await componentsLoaded + return this.loadElement(rootElement) + } + + private loadElement (el: HTMLDivElement) { + this.contentWrapper.nativeElement.appendChild(el) + this.displayed = true } } -- cgit v1.2.3