1 import { Component, Input, OnChanges, OnInit } from '@angular/core'
2 import { MarkdownService } from '@app/videos/shared'
6 styleUrls: [ './help.component.scss' ],
7 templateUrl: './help.component.html'
10 export class HelpComponent implements OnInit, OnChanges {
12 @Input() postHtml = ''
13 @Input() customHtml = ''
14 @Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom'
15 @Input() tooltipPlacement = 'right'
28 if (this.helpType === 'custom') {
29 this.mainHtml = this.customHtml
33 if (this.helpType === 'markdownText') {
34 this.mainHtml = this.formatMarkdownSupport(MarkdownService.TEXT_RULES)
38 if (this.helpType === 'markdownEnhanced') {
39 this.mainHtml = this.formatMarkdownSupport(MarkdownService.ENHANCED_RULES)
44 private formatMarkdownSupport (rules: string[]) {
45 return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
46 'compatible that supports:' +
47 this.createMarkdownList(rules)
50 private createMarkdownList (rules: string[]) {
52 'emphasis': 'Emphasis',
54 'newline': 'New lines',
59 const bullets = rules.map(r => rulesToText[r])
61 .map(text => '<li>' + text + '</li>')
64 return '<ul>' + bullets + '</ul>'