ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to "show more" to markdown textarea
Chocobozzz66b27aafac4f
diff --git a/client/src/app/+video-watch/shared/metadata/video-description.component.html b/client/src/app/+video-watch/shared/metadata/video-description.component.htmlindex 16f3e38811..b63a3d2a28 100644--- a/client/src/app/+video-watch/shared/metadata/video-description.component.html+++ b/client/src/app/+video-watch/shared/metadata/video-description.component.html@@ -13,14 +13,13 @@(click)="completeDescriptionShown = !completeDescriptionShown"class="video-info-description-more button-unstyle">- <ng-container *ngIf="!completeDescriptionShown">+ @if (completeDescriptionShown) {+ <ng-container i18n>Show less</ng-container>+ <span class="chevron-up"></span>+ } @else {<ng-container i18n>Show more</ng-container><span class="chevron-down"></span>- </ng-container>+ }- <ng-container *ngIf="completeDescriptionShown">- <ng-container i18n>Show less</ng-container>- <span class="chevron-up"></span>- </ng-container></button></div>diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.htmlindex f693729313..b552bdcb24 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html@@ -37,7 +37,7 @@<my-markdown-textareainputId="description"formControlName="description" [markdownVideo]="videoEdit.getVideoAttributes()"- [formError]="formErrors.description" withEmoji="true"+ [formError]="formErrors.description" withEmoji="true" withShowMoreButton="true"></my-markdown-textarea></div>@@ -166,7 +166,7 @@<div *ngIf="canBeDeleted()" class="form-group"><label i18n for="deleteVideo">Delete your video</label>- <div class="form-group-description" i18n>Warning: this is a definitive action!l!</div>+ <div class="form-group-description" i18n>Warning: this is a definitive action!</div><button class="peertube-button danger-button" (click)="deleteVideo()" i18n>Delete</button></div>diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.html b/client/src/app/shared/shared-forms/markdown-textarea.component.htmlindex 43392edb83..12cb8bd5ec 100644--- a/client/src/app/shared/shared-forms/markdown-textarea.component.html+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.html@@ -3,7 +3,7 @@<div [innerHTML]="previewHTML"></div></ng-template>-<div class="root" [ngClass]="{ 'maximized': isMaximized, monospace: monospace() }">+<div class="root" [ngClass]="{ 'maximized': maximized, monospace: monospace() }"><textarea #textarea[(ngModel)]="content" (ngModelChange)="onModelChange()"@@ -12,13 +12,13 @@[id]="inputId()" [name]="inputId()" [dir]="dir()"></textarea>- <div *ngIf="isMaximized" class="preview-maximized muted-2">+ <div *ngIf="maximized" class="preview-maximized muted-2"><ng-container *ngTemplateOutlet="previewContent"></ng-container></div><div *ngIf="withPreview()" class="buttons mt-3"><button- *ngIf="!isMaximized"+ *ngIf="!maximized"type="button" class="peertube-button secondary-button" (click)="previewCollapsed = !previewCollapsed"[attr.aria-expanded]="!previewCollapsed" [attr.aria-controls]="inputId() + '-collapse'">@@ -32,7 +32,7 @@</button><button type="button" (click)="onMaximizeClick()" class="maximize-button button-as-link" [disabled]="disabled">- @if (isMaximized) {+ @if (maximized) {<ng-container i18n>Exit full-screen editor</ng-container>} @else {<ng-container i18n>Full-screen editor</ng-container>@@ -41,11 +41,26 @@</div><div- *ngIf="!isMaximized" class="preview-collapse mt-3 muted-2"- #collapse="ngbCollapse" [(ngbCollapse)]="previewCollapsed" [id]="inputId() + '-collapse'"+ *ngIf="!maximized" class="preview-collapse preview mt-3 muted-2"+ [ngClass]="{ 'ellipsis-multiline-3': truncated }"+ #collapse="ngbCollapse" [(ngbCollapse)]="previewCollapsed" [id]="inputId() + '-collapse'" #previewEl><ng-container *ngTemplateOutlet="previewContent"></ng-container></div></div>-<div *ngIf="!isMaximized && formError()" class="form-error" role="alert">{{ formError() }}</div>+@if (!maximized) {+ @if (withShowMoreButton() && (!truncated || hasEllipsis())) {+ <button type="button" (click)="truncated = !truncated" class="button-unstyle show-more-toggle">+ @if (truncated) {+ <ng-container i18n>Show more</ng-container>+ <span class="chevron-down"></span>+ } @else {+ <ng-container i18n>Show less</ng-container>+ <span class="chevron-up"></span>+ }+ </button>+ }++ <div *ngIf="formError()" class="form-error" role="alert">{{ formError() }}</div>+}diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.scss b/client/src/app/shared/shared-forms/markdown-textarea.component.scssindex 95c3b3b908..2fc33800b5 100644--- a/client/src/app/shared/shared-forms/markdown-textarea.component.scss+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.scss@@ -11,12 +11,9 @@@include peertube-textarea(100%, 170px);}- .preview {- min-height: 75px;- max-height: 210px;-- overflow-y: auto;- word-wrap: break-word;+ .preview,+ .preview-maximized {+ @include peertube-word-wrap;}.buttons {@@ -86,6 +83,14 @@}}+.show-more-toggle {+ font-weight: $font-bold;+ color: pvar(--fg-300);+ margin-top: 1rem;++ @include font-size(14px);+}+@include on-small-main-col () {.maximize-button {display: none;diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.tsindex 7637586ed8..67f52046a9 100644--- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts@@ -33,6 +33,8 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,private screenService = inject(ScreenService)private markdownService = inject(MarkdownService)+ readonly previewEl = viewChild<ElementRef<HTMLElement>>('previewEl')+readonly content = model('')readonly formError = input<string | FormReactiveErrors | FormReactiveErrors[]>(undefined)@@ -51,6 +53,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,readonly withPreview = input(true, { transform: booleanAttribute })readonly withHtml = input(false, { transform: booleanAttribute })readonly withEmoji = input(false, { transform: booleanAttribute })+ readonly withShowMoreButton = input(false, { transform: booleanAttribute })readonly monospace = input(false, { transform: booleanAttribute })@@ -59,9 +62,10 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,previewHTML: SafeHtml | string = ''- isMaximized = false+ maximized = falsedisabled = falsepreviewCollapsed = true+ truncated = falseprivate contentChanged = new Subject<string>()private scrollPosition: [number, number]@@ -75,6 +79,8 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,.subscribe(() => this.updatePreviews())this.contentChanged.next(this.content())++ this.truncated = this.withShowMoreButton()}ngOnDestroy () {@@ -109,7 +115,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,onMaximizeClick () {if (this.disabled) return- this.isMaximized = !this.isMaximized+ this.maximized = !this.maximized// Make sure textarea have the focus// Except on touchscreens devices, the virtual keyboard may move up and hide the textarea in maximized mode@@ -118,7 +124,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,}// Make sure the window has no scrollbars- if (!this.isMaximized) {+ if (!this.maximized) {this.unlockBodyScroll()} else {this.lockBodyScroll()@@ -129,6 +135,13 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,this.disabled = isDisabled}+ hasEllipsis () {+ const el = this.previewEl()?.nativeElement+ if (!el) return false++ return el.offsetHeight < el.scrollHeight+ }+private lockBodyScroll () {this.scrollPosition = this.viewportScroller.getScrollPosition()document.getElementById('content').classList.add('lock-scroll')