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'
27 if (this.helpType === 'custom') {
28 this.mainHtml = this.customHtml
32 if (this.helpType === 'markdownText') {
33 this.mainHtml = this.formatMarkdownSupport(MarkdownService.TEXT_RULES)
37 if (this.helpType === 'markdownEnhanced') {
38 this.mainHtml = this.formatMarkdownSupport(MarkdownService.ENHANCED_RULES)
43 private formatMarkdownSupport (rules: string[]) {
44 return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
45 'compatible that supports:' +
46 this.createMarkdownList(rules)
49 private createMarkdownList (rules: string[]) {
51 'emphasis': 'Emphasis',
53 'newline': 'New lines',
58 const bullets = rules.map(r => rulesToText[r])
60 .map(text => '<li>' + text + '</li>')
63 return '<ul>' + bullets + '</ul>'