Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Allow formatting in transcription widget

Chocobozzzfceab5d2b83f
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html b/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html
index 36e809b3d4..61e4ab8919 100644
--- a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html
+++ b/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html
@@ -55,7 +55,7 @@
[ngClass]="getSegmentClasses(segment)"
>
<strong class="segment-start me-2">{{ segment.startFormatted }}</strong>
- <span class="segment-text fs-7" [innerHTML]="segment.text | nl2br"></span>
+ <span class="segment-text fs-7" [innerHTML]="segment.text | nl2br: true"></span>
</div>
</div>
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss b/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss
index e1fcbc43d8..794c4a9699 100644
--- a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss
+++ b/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss
@@ -14,8 +14,7 @@ input[type=text] {
}
.settings-button my-global-icon {
- width: 18px;
- height: 18px;
+ @include global-icon-size(18px);
}
.settings-panel {
diff --git a/client/src/app/core/renderer/html-renderer.service.ts b/client/src/app/core/renderer/html-renderer.service.ts
index 01b766ec74..75a23192f8 100644
--- a/client/src/app/core/renderer/html-renderer.service.ts
+++ b/client/src/app/core/renderer/html-renderer.service.ts
@@ -60,11 +60,15 @@ export class HtmlRendererService {
})
}
- convertToBr (text: string) {
+ convertToBr (text: string, allowFormatting = false) {
const html = text.replace(/\r?\n/g, '<br />')
+ const additionalAllowed = allowFormatting
+ ? [ 'b', 'i', 'u', 'strong', 'em' ]
+ : []
+
return DOMPurify.sanitize(html, {
- ALLOWED_TAGS: [ 'br' ]
+ ALLOWED_TAGS: [ ...additionalAllowed, 'br' ]
})
}
diff --git a/client/src/app/shared/shared-main/common/nl2br.pipe.ts b/client/src/app/shared/shared-main/common/nl2br.pipe.ts
index 7b860b8940..7c424b9315 100644
--- a/client/src/app/shared/shared-main/common/nl2br.pipe.ts
+++ b/client/src/app/shared/shared-main/common/nl2br.pipe.ts
@@ -8,7 +8,7 @@ import { HtmlRendererService } from '@app/core'
export class Nl2BrPipe implements PipeTransform {
private htmlRenderer = inject(HtmlRendererService)
- transform (value: string): string {
- return this.htmlRenderer.convertToBr(value)
+ transform (value: string, allowFormatting = false): string {
+ return this.htmlRenderer.convertToBr(value, allowFormatting)
}
}