X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fforms%2Fmarkdown-textarea.component.ts;h=cbcfdfe78aba73d9b9aac2ea8f14e79f357c383e;hb=be27ef3b4682c5639039474c39ee0d234d16f482;hp=e87aca0d4b402d9fb0c0e8ba2c35a6a97c5cea78;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts index e87aca0d4..cbcfdfe78 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.ts +++ b/client/src/app/shared/forms/markdown-textarea.component.ts @@ -21,12 +21,14 @@ import { MarkdownService } from '@app/shared/renderer' export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { @Input() content = '' - @Input() classes: string[] = [] + @Input() classes: string[] | { [klass: string]: any[] | any } = [] @Input() textareaWidth = '100%' @Input() textareaHeight = '150px' @Input() previewColumn = false @Input() truncate: number @Input() markdownType: 'text' | 'enhanced' = 'text' + @Input() markdownVideo = false + @Input() name = 'description' textareaMarginRight = '0' flexDirection = 'column' @@ -82,16 +84,18 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { return this.screenService.isInSmallView() === false } - private updatePreviews () { + private async updatePreviews () { if (this.content === null || this.content === undefined) return - this.truncatedPreviewHTML = this.markdownRender(truncate(this.content, { length: this.truncate })) - this.previewHTML = this.markdownRender(this.content) + this.truncatedPreviewHTML = await this.markdownRender(truncate(this.content, { length: this.truncate })) + this.previewHTML = await this.markdownRender(this.content) } - private markdownRender (text: string) { - if (this.markdownType === 'text') return this.markdownService.textMarkdownToHTML(text) + private async markdownRender (text: string) { + const html = this.markdownType === 'text' ? + await this.markdownService.textMarkdownToHTML(text) : + await this.markdownService.enhancedMarkdownToHTML(text) - return this.markdownService.enhancedMarkdownToHTML(text) + return this.markdownVideo ? this.markdownService.processVideoTimestamps(html) : html } }