X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-forms%2Fmarkdown-textarea.component.ts;h=e3371f22c7592b594f58f9e7551758020fe8a12d;hb=0e45e336f62a411b3c423be46d16252355c754d7;hp=a233a42050cb348daa5137742a3bfacb349565bf;hpb=4d7ce9218a3f695bf3d013cbdce1c5c6a5221927;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts index a233a4205..e3371f22c 100644 --- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts +++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts @@ -6,6 +6,7 @@ import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@an import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { SafeHtml } from '@angular/platform-browser' import { MarkdownService, ScreenService } from '@app/core' +import { Video } from '@shared/models' @Component({ selector: 'my-markdown-textarea', @@ -23,17 +24,14 @@ import { MarkdownService, ScreenService } from '@app/core' export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { @Input() content = '' - @Input() classes: string[] | { [klass: string]: any[] | any } = [] - - @Input() textareaMaxWidth = '100%' - @Input() textareaHeight = '150px' + @Input() formError: string @Input() truncate: number @Input() markdownType: 'text' | 'enhanced' = 'text' @Input() customMarkdownRenderer?: (text: string) => Promise - @Input() markdownVideo = false + @Input() markdownVideo: Video @Input() name = 'description' @@ -44,6 +42,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { previewHTML: SafeHtml | string = '' isMaximized = false + disabled = false maximizeInText = $localize`Maximize editor` maximizeOutText = $localize`Exit maximized editor` @@ -91,6 +90,8 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { } onMaximizeClick () { + if (this.disabled) return + this.isMaximized = !this.isMaximized // Make sure textarea have the focus @@ -107,6 +108,10 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { } } + setDisabledState (isDisabled: boolean) { + this.disabled = isDisabled + } + private lockBodyScroll () { this.scrollPosition = this.viewportScroller.getScrollPosition() document.getElementById('content').classList.add('lock-scroll') @@ -131,8 +136,6 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { const result = await this.customMarkdownRenderer(text) if (result instanceof HTMLElement) { - html = '' - const wrapperElement = this.previewElement.nativeElement as HTMLElement wrapperElement.innerHTML = '' wrapperElement.appendChild(result) @@ -141,13 +144,13 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { html = result } else if (this.markdownType === 'text') { - html = await this.markdownService.textMarkdownToHTML(text) + html = await this.markdownService.textMarkdownToHTML({ markdown: text }) } else { - html = await this.markdownService.enhancedMarkdownToHTML(text) + html = await this.markdownService.enhancedMarkdownToHTML({ markdown: text }) } if (this.markdownVideo) { - html = this.markdownService.processVideoTimestamps(html) + html = this.markdownService.processVideoTimestamps(this.markdownVideo.shortUUID, html) } return html