2019-11-19 19:15:56 +09:00
|
|
|
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';
|
2019-11-19 19:15:56 +09:00
|
|
|
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']
|
|
|
|
})
|
2019-11-19 19:15:56 +09:00
|
|
|
export class TextComponent implements OnInit, AfterViewInit {
|
2019-10-11 11:40:35 +09:00
|
|
|
@Input()
|
2019-11-06 13:48:06 +09:00
|
|
|
message: Info<EventJson>;
|
2019-10-11 11:40:35 +09:00
|
|
|
|
2019-11-19 19:15:56 +09:00
|
|
|
constructor(
|
|
|
|
private elementRef: ElementRef,
|
|
|
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
|
|
|
|
) {}
|
2019-10-07 13:49:12 +09:00
|
|
|
|
|
|
|
ngOnInit() {}
|
2019-11-19 19:15:56 +09:00
|
|
|
|
|
|
|
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) {
|
2019-11-19 19:34:53 +09:00
|
|
|
this.nativeService.openDefaultBrowser(
|
|
|
|
(event.target as HTMLAnchorElement).text
|
|
|
|
);
|
2019-11-19 19:15:56 +09:00
|
|
|
}
|
2019-10-07 13:49:12 +09:00
|
|
|
}
|