aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/forms/markdown-textarea.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/forms/markdown-textarea.component.ts')
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.ts37
1 files changed, 25 insertions, 12 deletions
diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts
index cbcfdfe78..dde7b4d98 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/forms/markdown-textarea.component.ts
@@ -1,5 +1,5 @@
1import { debounceTime, distinctUntilChanged } from 'rxjs/operators' 1import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
2import { Component, forwardRef, Input, OnInit } from '@angular/core' 2import { Component, forwardRef, Input, OnInit, ViewChild, ElementRef } from '@angular/core'
3import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 3import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
4import { Subject } from 'rxjs' 4import { Subject } from 'rxjs'
5import truncate from 'lodash-es/truncate' 5import truncate from 'lodash-es/truncate'
@@ -22,18 +22,18 @@ import { MarkdownService } from '@app/shared/renderer'
22export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { 22export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
23 @Input() content = '' 23 @Input() content = ''
24 @Input() classes: string[] | { [klass: string]: any[] | any } = [] 24 @Input() classes: string[] | { [klass: string]: any[] | any } = []
25 @Input() textareaWidth = '100%' 25 @Input() textareaMaxWidth = '100%'
26 @Input() textareaHeight = '150px' 26 @Input() textareaHeight = '150px'
27 @Input() previewColumn = false
28 @Input() truncate: number 27 @Input() truncate: number
29 @Input() markdownType: 'text' | 'enhanced' = 'text' 28 @Input() markdownType: 'text' | 'enhanced' = 'text'
30 @Input() markdownVideo = false 29 @Input() markdownVideo = false
31 @Input() name = 'description' 30 @Input() name = 'description'
32 31
33 textareaMarginRight = '0' 32 @ViewChild('textarea') textareaElement: ElementRef
34 flexDirection = 'column' 33
35 truncatedPreviewHTML = '' 34 truncatedPreviewHTML = ''
36 previewHTML = '' 35 previewHTML = ''
36 isMaximized = false
37 37
38 private contentChanged = new Subject<string>() 38 private contentChanged = new Subject<string>()
39 39
@@ -51,11 +51,6 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
51 .subscribe(() => this.updatePreviews()) 51 .subscribe(() => this.updatePreviews())
52 52
53 this.contentChanged.next(this.content) 53 this.contentChanged.next(this.content)
54
55 if (this.previewColumn) {
56 this.flexDirection = 'row'
57 this.textareaMarginRight = '15px'
58 }
59 } 54 }
60 55
61 propagateChange = (_: any) => { /* empty */ } 56 propagateChange = (_: any) => { /* empty */ }
@@ -80,8 +75,26 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
80 this.contentChanged.next(this.content) 75 this.contentChanged.next(this.content)
81 } 76 }
82 77
83 arePreviewsDisplayed () { 78 onMaximizeClick () {
84 return this.screenService.isInSmallView() === false 79 this.isMaximized = !this.isMaximized
80
81 // Make sure textarea have the focus
82 this.textareaElement.nativeElement.focus()
83
84 // Make sure the window has no scrollbars
85 if (!this.isMaximized) {
86 this.unlockBodyScroll()
87 } else {
88 this.lockBodyScroll()
89 }
90 }
91
92 private lockBodyScroll () {
93 document.getElementById('content').classList.add('lock-scroll')
94 }
95
96 private unlockBodyScroll () {
97 document.getElementById('content').classList.remove('lock-scroll')
85 } 98 }
86 99
87 private async updatePreviews () { 100 private async updatePreviews () {