diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-20 16:13:05 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-20 16:13:55 +0100 |
commit | 07fa4c97ca50b83b0bee9230da97d02401b4e05f (patch) | |
tree | 07a5ef1b14d8f0596c241456e4cc772f38c0e4ba /client/src/app/shared/forms | |
parent | dddf58c8ce58f6cdd4b8ba93690cceae8f52c37d (diff) | |
download | PeerTube-07fa4c97ca50b83b0bee9230da97d02401b4e05f.tar.gz PeerTube-07fa4c97ca50b83b0bee9230da97d02401b4e05f.tar.zst PeerTube-07fa4c97ca50b83b0bee9230da97d02401b4e05f.zip |
Add support to video support on client
Diffstat (limited to 'client/src/app/shared/forms')
4 files changed, 38 insertions, 22 deletions
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index 34a237a12..9ecbbbd60 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts | |||
@@ -44,10 +44,10 @@ export const VIDEO_CHANNEL = { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | export const VIDEO_DESCRIPTION = { | 46 | export const VIDEO_DESCRIPTION = { |
47 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(3000) ], | 47 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], |
48 | MESSAGES: { | 48 | MESSAGES: { |
49 | 'minlength': 'Video description must be at least 3 characters long.', | 49 | 'minlength': 'Video description must be at least 3 characters long.', |
50 | 'maxlength': 'Video description cannot be more than 3000 characters long.' | 50 | 'maxlength': 'Video description cannot be more than 10000 characters long.' |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
@@ -58,3 +58,11 @@ export const VIDEO_TAGS = { | |||
58 | 'maxlength': 'A tag should be less than 30 characters long.' | 58 | 'maxlength': 'A tag should be less than 30 characters long.' |
59 | } | 59 | } |
60 | } | 60 | } |
61 | |||
62 | export const VIDEO_SUPPORT = { | ||
63 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(300) ], | ||
64 | MESSAGES: { | ||
65 | 'minlength': 'Video support must be at least 3 characters long.', | ||
66 | 'maxlength': 'Video support cannot be more than 300 characters long.' | ||
67 | } | ||
68 | } | ||
diff --git a/client/src/app/shared/forms/markdown-textarea.component.html b/client/src/app/shared/forms/markdown-textarea.component.html index e8c5ded5b..46a97b163 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.html +++ b/client/src/app/shared/forms/markdown-textarea.component.html | |||
@@ -1,12 +1,12 @@ | |||
1 | <div class="root" [ngStyle]="{ 'flex-direction': flexDirection }"> | 1 | <div class="root" [ngStyle]="{ 'flex-direction': flexDirection }"> |
2 | <textarea | 2 | <textarea |
3 | [(ngModel)]="description" (ngModelChange)="onModelChange()" | 3 | [(ngModel)]="content" (ngModelChange)="onModelChange()" |
4 | [ngClass]="classes" [ngStyle]="{ width: textareaWidth, height: textareaHeight, 'margin-right': textareaMarginRight }" | 4 | [ngClass]="classes" [ngStyle]="{ width: textareaWidth, height: textareaHeight, 'margin-right': textareaMarginRight }" |
5 | id="description" name="description"> | 5 | id="description" name="description"> |
6 | </textarea> | 6 | </textarea> |
7 | 7 | ||
8 | <tabset *ngIf="arePreviewsDisplayed()" class="previews"> | 8 | <tabset *ngIf="arePreviewsDisplayed()" class="previews"> |
9 | <tab *ngIf="truncate !== undefined" heading="Truncated description preview" [innerHTML]="truncatedDescriptionHTML"></tab> | 9 | <tab *ngIf="truncate !== undefined" heading="Truncated preview" [innerHTML]="truncatedPreviewHTML"></tab> |
10 | <tab heading="Complete description preview" [innerHTML]="descriptionHTML"></tab> | 10 | <tab heading="Complete preview" [innerHTML]="previewHTML"></tab> |
11 | </tabset> | 11 | </tabset> |
12 | </div> | 12 | </div> |
diff --git a/client/src/app/shared/forms/markdown-textarea.component.scss b/client/src/app/shared/forms/markdown-textarea.component.scss index 82aff541d..6f7494621 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.scss +++ b/client/src/app/shared/forms/markdown-textarea.component.scss | |||
@@ -22,6 +22,7 @@ | |||
22 | min-height: 75px; | 22 | min-height: 75px; |
23 | padding: 15px; | 23 | padding: 15px; |
24 | font-size: 15px; | 24 | font-size: 15px; |
25 | word-wrap: break-word; | ||
25 | } | 26 | } |
26 | } | 27 | } |
27 | } | 28 | } |
diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts index 2eae1b27e..928a63b28 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.ts +++ b/client/src/app/shared/forms/markdown-textarea.component.ts | |||
@@ -21,29 +21,30 @@ import truncate from 'lodash-es/truncate' | |||
21 | }) | 21 | }) |
22 | 22 | ||
23 | export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { | 23 | export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { |
24 | @Input() description = '' | 24 | @Input() content = '' |
25 | @Input() classes: string[] = [] | 25 | @Input() classes: string[] = [] |
26 | @Input() textareaWidth = '100%' | 26 | @Input() textareaWidth = '100%' |
27 | @Input() textareaHeight = '150px' | 27 | @Input() textareaHeight = '150px' |
28 | @Input() previewColumn = false | 28 | @Input() previewColumn = false |
29 | @Input() truncate: number | 29 | @Input() truncate: number |
30 | @Input() markdownType: 'text' | 'enhanced' = 'text' | ||
30 | 31 | ||
31 | textareaMarginRight = '0' | 32 | textareaMarginRight = '0' |
32 | flexDirection = 'column' | 33 | flexDirection = 'column' |
33 | truncatedDescriptionHTML = '' | 34 | truncatedPreviewHTML = '' |
34 | descriptionHTML = '' | 35 | previewHTML = '' |
35 | 36 | ||
36 | private descriptionChanged = new Subject<string>() | 37 | private contentChanged = new Subject<string>() |
37 | 38 | ||
38 | constructor (private markdownService: MarkdownService) {} | 39 | constructor (private markdownService: MarkdownService) {} |
39 | 40 | ||
40 | ngOnInit () { | 41 | ngOnInit () { |
41 | this.descriptionChanged | 42 | this.contentChanged |
42 | .debounceTime(150) | 43 | .debounceTime(150) |
43 | .distinctUntilChanged() | 44 | .distinctUntilChanged() |
44 | .subscribe(() => this.updateDescriptionPreviews()) | 45 | .subscribe(() => this.updatePreviews()) |
45 | 46 | ||
46 | this.descriptionChanged.next(this.description) | 47 | this.contentChanged.next(this.content) |
47 | 48 | ||
48 | if (this.previewColumn) { | 49 | if (this.previewColumn) { |
49 | this.flexDirection = 'row' | 50 | this.flexDirection = 'row' |
@@ -54,9 +55,9 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { | |||
54 | propagateChange = (_: any) => { /* empty */ } | 55 | propagateChange = (_: any) => { /* empty */ } |
55 | 56 | ||
56 | writeValue (description: string) { | 57 | writeValue (description: string) { |
57 | this.description = description | 58 | this.content = description |
58 | 59 | ||
59 | this.descriptionChanged.next(this.description) | 60 | this.contentChanged.next(this.content) |
60 | } | 61 | } |
61 | 62 | ||
62 | registerOnChange (fn: (_: any) => void) { | 63 | registerOnChange (fn: (_: any) => void) { |
@@ -68,19 +69,25 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { | |||
68 | } | 69 | } |
69 | 70 | ||
70 | onModelChange () { | 71 | onModelChange () { |
71 | this.propagateChange(this.description) | 72 | this.propagateChange(this.content) |
72 | 73 | ||
73 | this.descriptionChanged.next(this.description) | 74 | this.contentChanged.next(this.content) |
74 | } | 75 | } |
75 | 76 | ||
76 | arePreviewsDisplayed () { | 77 | arePreviewsDisplayed () { |
77 | return isInSmallView() === false | 78 | return isInSmallView() === false |
78 | } | 79 | } |
79 | 80 | ||
80 | private updateDescriptionPreviews () { | 81 | private updatePreviews () { |
81 | if (this.description === null || this.description === undefined) return | 82 | if (this.content === null || this.content === undefined) return |
82 | 83 | ||
83 | this.truncatedDescriptionHTML = this.markdownService.markdownToHTML(truncate(this.description, { length: this.truncate })) | 84 | this.truncatedPreviewHTML = this.markdownRender(truncate(this.content, { length: this.truncate })) |
84 | this.descriptionHTML = this.markdownService.markdownToHTML(this.description) | 85 | this.previewHTML = this.markdownRender(this.content) |
86 | } | ||
87 | |||
88 | private markdownRender (text: string) { | ||
89 | if (this.markdownType === 'text') return this.markdownService.textMarkdownToHTML(text) | ||
90 | |||
91 | return this.markdownService.enhancedMarkdownToHTML(text) | ||
85 | } | 92 | } |
86 | } | 93 | } |