X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fforms%2Fmarkdown-textarea.component.ts;h=49a57f29debd6b4ee148be8c3e1bb7ed89cd6eac;hb=8dfceec44a5eec8b0190d1d5076aab0f03a0cb52;hp=dcc85f3cdbbe17ee6b1b456849dcb633a57d4d96;hpb=db400f447a9f7aae1c56fa25396e93069744483f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts index dcc85f3cd..49a57f29d 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.ts +++ b/client/src/app/shared/forms/markdown-textarea.component.ts @@ -1,10 +1,10 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators' import { Component, forwardRef, Input, OnInit } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' -import { isInSmallView } from '@app/shared/misc/utils' -import { MarkdownService } from '@app/videos/shared' import { Subject } from 'rxjs' import truncate from 'lodash-es/truncate' +import { ScreenService } from '@app/shared/misc/screen.service' +import { MarkdownService } from '@app/shared/renderer' @Component({ selector: 'my-markdown-textarea', @@ -35,7 +35,10 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { private contentChanged = new Subject() - constructor (private markdownService: MarkdownService) {} + constructor ( + private screenService: ScreenService, + private markdownService: MarkdownService +) {} ngOnInit () { this.contentChanged @@ -76,14 +79,14 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { } arePreviewsDisplayed () { - return isInSmallView() === false + return this.screenService.isInSmallView() === false } - private updatePreviews () { + private async updatePreviews () { if (this.content === null || this.content === undefined) return - this.truncatedPreviewHTML = this.markdownRender(truncate(this.content, { length: this.truncate })) - this.previewHTML = this.markdownRender(this.content) + this.truncatedPreviewHTML = await this.markdownRender(truncate(this.content, { length: this.truncate })) + this.previewHTML = await this.markdownRender(this.content) } private markdownRender (text: string) {