+import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
-import 'rxjs/add/operator/debounceTime'
-import 'rxjs/add/operator/distinctUntilChanged'
-import { isInSmallView } from '@app/shared/misc/utils'
-import { MarkdownService } from '@app/videos/shared'
-import { Subject } from 'rxjs/Subject'
+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',
private contentChanged = new Subject<string>()
- constructor (private markdownService: MarkdownService) {}
+ constructor (
+ private screenService: ScreenService,
+ private markdownService: MarkdownService
+) {}
ngOnInit () {
this.contentChanged
- .debounceTime(150)
- .distinctUntilChanged()
- .subscribe(() => this.updatePreviews())
+ .pipe(
+ debounceTime(150),
+ distinctUntilChanged()
+ )
+ .subscribe(() => this.updatePreviews())
this.contentChanged.next(this.content)
}
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) {