aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
diff options
context:
space:
mode:
authorlutangar <johan.dufour@gmail.com>2022-08-30 17:13:26 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-09-08 08:41:36 +0200
commit2873a53efd8913b6b5fbf305320f88731cd07771 (patch)
tree5063f5b38f222ce27f6923dc4bb8765f713ac4c7 /client/src/app/+videos/+video-edit/shared/video-edit.component.ts
parent5f016383a4fabf2f296cda6d5e383719ee9d5e27 (diff)
downloadPeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.tar.gz
PeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.tar.zst
PeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.zip
Set scroll position at top of the textarea when opening the subtitle editor.
## Description This set the position of the scrollbar at the top of the textarea when opening the __subtitle editor__. Previously the textarea scroll position was at the bottom of the textarea which doesn't make much sense when you want to edit a subtitle : you most likely want to edit the beginning of the subtitle first. This also set the caret position on the first character. ## Design decision I had to use a *component approach* instead of an `<ng-template>` for the edition modal because the `@viewChild` directive doesn't work for elements __inside__ an `<ng-template>`. I needed the `viewChild` directive to get an `ElementRef` of the `textarea`. > See the following issue and its workaround : > - https://github.com/valor-software/ngx-bootstrap/issues/3825 > - https://stackblitz.com/edit/angular-t5dfp7 > - https://medium.com/@izzatnadiri/how-to-pass-data-to-and-receive-from-ng-bootstrap-modals-916f2ad5d66e ## Related issues Closes [peertube-plugin-transcription/#39](https://gitlab.com/apps_education/peertube/plugin-transcription/-/issues/39)
Diffstat (limited to 'client/src/app/+videos/+video-edit/shared/video-edit.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index 99f8c9034..0275f66f5 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -35,10 +35,11 @@ import {
35} from '@shared/models' 35} from '@shared/models'
36import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' 36import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
37import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' 37import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
38import { VideoCaptionEditModalComponent } from './video-caption-edit-modal/video-caption-edit-modal.component' 38import { VideoCaptionEditModalContentComponent } from './video-caption-edit-modal-content/video-caption-edit-modal-content.component'
39import { VideoEditType } from './video-edit.type' 39import { VideoEditType } from './video-edit.type'
40import { VideoSource } from '@shared/models/videos/video-source' 40import { VideoSource } from '@shared/models/videos/video-source'
41import { logger } from '@root-helpers/logger' 41import { logger } from '@root-helpers/logger'
42import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
42 43
43type VideoLanguages = VideoConstant<string> & { group?: string } 44type VideoLanguages = VideoConstant<string> & { group?: string }
44type PluginField = { 45type PluginField = {
@@ -70,7 +71,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
70 @Input() liveVideo: LiveVideo 71 @Input() liveVideo: LiveVideo
71 72
72 @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent 73 @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent
73 @ViewChild('videoCaptionEditModal', { static: true }) editCaptionModal: VideoCaptionEditModalComponent
74 74
75 @Output() formBuilt = new EventEmitter<void>() 75 @Output() formBuilt = new EventEmitter<void>()
76 @Output() pluginFieldsAdded = new EventEmitter<void>() 76 @Output() pluginFieldsAdded = new EventEmitter<void>()
@@ -128,7 +128,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
128 private i18nPrimengCalendarService: I18nPrimengCalendarService, 128 private i18nPrimengCalendarService: I18nPrimengCalendarService,
129 private ngZone: NgZone, 129 private ngZone: NgZone,
130 private hooks: HooksService, 130 private hooks: HooksService,
131 private cd: ChangeDetectorRef 131 private cd: ChangeDetectorRef,
132 private modalService: NgbModal
132 ) { 133 ) {
133 this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone() 134 this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
134 this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat() 135 this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
@@ -286,6 +287,13 @@ export class VideoEditComponent implements OnInit, OnDestroy {
286 this.videoCaptionAddModal.show() 287 this.videoCaptionAddModal.show()
287 } 288 }
288 289
290 openEditCaptionModal (videoCaption: VideoCaptionWithPathEdit) {
291 const modalRef = this.modalService.open(VideoCaptionEditModalContentComponent, { centered: true, keyboard: false })
292 modalRef.componentInstance.videoCaption = videoCaption
293 modalRef.componentInstance.serverConfig = this.serverConfig
294 modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this))
295 }
296
289 isSaveReplayEnabled () { 297 isSaveReplayEnabled () {
290 return this.serverConfig.live.allowReplay 298 return this.serverConfig.live.allowReplay
291 } 299 }