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',
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<string | HTMLElement>
- @Input() markdownVideo = false
+ @Input() markdownVideo: Video
@Input() name = 'description'
previewHTML: SafeHtml | string = ''
isMaximized = false
+ disabled = false
maximizeInText = $localize`Maximize editor`
maximizeOutText = $localize`Exit maximized editor`
}
onMaximizeClick () {
+ if (this.disabled) return
+
this.isMaximized = !this.isMaximized
// Make sure textarea have the focus
}
}
+ setDisabledState (isDisabled: boolean) {
+ this.disabled = isDisabled
+ }
+
private lockBodyScroll () {
this.scrollPosition = this.viewportScroller.getScrollPosition()
document.getElementById('content').classList.add('lock-scroll')
const result = await this.customMarkdownRenderer(text)
if (result instanceof HTMLElement) {
- html = ''
-
const wrapperElement = this.previewElement.nativeElement as HTMLElement
wrapperElement.innerHTML = ''
wrapperElement.appendChild(result)
}
if (this.markdownVideo) {
- html = this.markdownService.processVideoTimestamps(html)
+ html = this.markdownService.processVideoTimestamps(this.markdownVideo.shortUUID, html)
}
return html