47 lines
1.2 KiB
TypeScript
Raw Normal View History

import {
Component,
OnInit,
Input,
ElementRef,
AfterViewInit,
Inject
} from '@angular/core';
2019-11-06 13:48:06 +09:00
import { Info, EventJson } from '@ucap-webmessenger/protocol-event';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
2019-10-07 13:49:12 +09:00
@Component({
selector: 'ucap-chat-message-box-text',
templateUrl: './text.component.html',
styleUrls: ['./text.component.scss']
})
export class TextComponent implements OnInit, AfterViewInit {
@Input()
2019-11-06 13:48:06 +09:00
message: Info<EventJson>;
constructor(
private elementRef: ElementRef,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
) {}
2019-10-07 13:49:12 +09:00
ngOnInit() {}
ngAfterViewInit(): void {
if (
!!this.elementRef.nativeElement &&
!!this.elementRef.nativeElement.querySelector('a')
) {
const elements = this.elementRef.nativeElement.querySelectorAll('a');
elements.forEach(element => {
element.addEventListener('click', this.onClickEvent.bind(this));
});
}
}
onClickEvent(event: MouseEvent) {
console.log('component', (event.target as HTMLAnchorElement).text);
// this.nativeService.openDefaultBrowser(
// (event.target as HTMLAnchorElement).text
// );
}
2019-10-07 13:49:12 +09:00
}