diff --git a/frontend/src/app/shared/pipes/paragraph.pipe.ts b/frontend/src/app/shared/pipes/paragraph.pipe.ts new file mode 100644 index 0000000..ecbb4a1 --- /dev/null +++ b/frontend/src/app/shared/pipes/paragraph.pipe.ts @@ -0,0 +1,16 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'paragraph' +}) +export class ParagraphPipe implements PipeTransform { + transform(value: string): string { + if (!value) return ''; + + // Replace newlines with paragraph tags + const paragraphs = value.split(/\n+/); + return paragraphs + .map(p => `

${p}

`) + .join(''); + } +} diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts index a43257e..ef8cb32 100644 --- a/frontend/src/app/shared/shared.module.ts +++ b/frontend/src/app/shared/shared.module.ts @@ -7,6 +7,7 @@ import { ConfirmModalComponent } from './components/modals/confirm-modal/confirm // * pipes import { DateFormatPipe } from './pipes/date-format/date-format.pipe'; +import { ParagraphPipe } from './pipes/paragraph.pipe'; // * other import { RatingModule } from 'ngx-bootstrap/rating'; @@ -34,14 +35,14 @@ import { MediaSelectorPipe } from './pipes/media-selector/media-selector.pipe'; RatingModule.forRoot(), ToastrModule.forRoot(), - ], - declarations: [ + ], declarations: [ // * pipes DateFormatPipe, FloatFormatPipe, MinutesFormatPipe, BetterMinutesFormatPipe, MediaSelectorPipe, + ParagraphPipe, // * directives StopScrollDirective, @@ -58,14 +59,14 @@ import { MediaSelectorPipe } from './pipes/media-selector/media-selector.pipe'; NotificationPopupComponent, ContextMenuComponent, - ], - exports: [ + ], exports: [ // * pipes DateFormatPipe, FloatFormatPipe, MinutesFormatPipe, BetterMinutesFormatPipe, MediaSelectorPipe, + ParagraphPipe, // * directives StopScrollDirective,