-import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core'
+import { Component, ElementRef, HostListener, Input, OnInit, ViewChild, OnChanges } from '@angular/core'
import { MarkdownService } from '@app/videos/shared'
import { TooltipDirective } from 'ngx-bootstrap/tooltip'
templateUrl: './help.component.html'
})
-export class HelpComponent implements OnInit {
+export class HelpComponent implements OnInit, OnChanges {
@ViewChild('tooltipDirective') tooltipDirective: TooltipDirective
@Input() preHtml = ''
@Input() postHtml = ''
constructor (private elementRef: ElementRef) { }
ngOnInit () {
+ this.init()
+ }
+
+ ngOnChanges () {
+ this.init()
+ }
+
+ @HostListener('document:click', ['$event.target'])
+ public onClick (targetElement) {
+ const clickedInside = this.elementRef.nativeElement.contains(targetElement)
+
+ if (this.tooltipDirective.isOpen && !clickedInside) {
+ this.tooltipDirective.hide()
+ }
+ }
+
+ private init () {
if (this.helpType === 'custom') {
this.mainHtml = this.customHtml
return
}
}
- @HostListener('document:click', ['$event.target'])
- public onClick (targetElement) {
- const clickedInside = this.elementRef.nativeElement.contains(targetElement)
-
- if (this.tooltipDirective.isOpen && !clickedInside) {
- this.tooltipDirective.hide()
- }
- }
-
private formatMarkdownSupport (rules: string[]) {
- return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank">Markdown</a> compatible that supports:' +
+ return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
+ 'compatible that supports:' +
this.createMarkdownList(rules)
}