<div *ngIf="account" class="row">
<div class="block col-md-6 col-sm-12">
<div i18n class="small-title">Description</div>
- <div class="content">{{ getAccountDescription() }}</div>
+ <div class="content" [innerHtml]="getAccountDescription()"></div>
</div>
<div class="block col-md-6 col-sm-12">
import { AccountService } from '@app/shared/account/account.service'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { Subscription } from 'rxjs'
+import { MarkdownService } from '@app/videos/shared'
@Component({
selector: 'my-account-about',
})
export class AccountAboutComponent implements OnInit, OnDestroy {
account: Account
+ descriptionHTML = ''
private accountSub: Subscription
constructor (
private route: ActivatedRoute,
private i18n: I18n,
- private accountService: AccountService
+ private accountService: AccountService,
+ private markdownService: MarkdownService
) { }
ngOnInit () {
// Parent get the account for us
this.accountSub = this.accountService.accountLoaded
- .subscribe(account => this.account = account)
+ .subscribe(account => {
+ this.account = account
+ this.descriptionHTML = this.markdownService.textMarkdownToHTML(this.account.description)
+ })
}
ngOnDestroy () {
}
getAccountDescription () {
- if (this.account.description) return this.account.description
+ if (this.descriptionHTML) return this.descriptionHTML
return this.i18n('No description')
}
<div class="description col-md-6 col-sm-12">
<div class="block">
<div i18n class="small-title">Description</div>
- <div class="content">{{ getVideoChannelDescription() }}</div>
+ <div class="content" [innerHtml]="getVideoChannelDescription()"></div>
</div>
- <div class="block" *ngIf="videoChannel.support">
+ <div class="block" *ngIf="supportHTML">
<div i18n class="small-title">Support this channel</div>
- <div class="content">{{ videoChannel.support }}</div>
+ <div class="content" [innerHtml]="supportHTML"></div>
</div>
</div>
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { Subscription } from 'rxjs'
+import { MarkdownService } from '@app/videos/shared'
@Component({
selector: 'my-video-channel-about',
})
export class VideoChannelAboutComponent implements OnInit, OnDestroy {
videoChannel: VideoChannel
+ descriptionHTML = ''
+ supportHTML = ''
private videoChannelSub: Subscription
constructor (
private route: ActivatedRoute,
private i18n: I18n,
- private videoChannelService: VideoChannelService
+ private videoChannelService: VideoChannelService,
+ private markdownService: MarkdownService
) { }
ngOnInit () {
// Parent get the video channel for us
this.videoChannelSub = this.videoChannelService.videoChannelLoaded
- .subscribe(videoChannel => this.videoChannel = videoChannel)
+ .subscribe(videoChannel => {
+ this.videoChannel = videoChannel
+
+ this.descriptionHTML = this.markdownService.textMarkdownToHTML(this.videoChannel.description)
+ this.supportHTML = this.markdownService.enhancedMarkdownToHTML(this.videoChannel.support)
+ })
}
ngOnDestroy () {
}
getVideoChannelDescription () {
- if (this.videoChannel.description) return this.videoChannel.description
+ if (this.descriptionHTML) return this.descriptionHTML
return this.i18n('No description')
}
show () {
this.modal.show()
- if (this.video.support) {
- this.videoHTMLSupport = this.markdownService.enhancedMarkdownToHTML(this.video.support)
- } else {
- this.videoHTMLSupport = ''
- }
+ this.videoHTMLSupport = this.markdownService.enhancedMarkdownToHTML(this.video.support)
}
hide () {
}
private setVideoDescriptionHTML () {
- if (!this.video.description) {
- this.videoHTMLDescription = ''
- return
- }
-
this.videoHTMLDescription = this.markdownService.textMarkdownToHTML(this.video.description)
}
}
textMarkdownToHTML (markdown: string) {
- const html = this.textMarkdownIt.render(markdown)
+ if (!markdown) return ''
+ const html = this.textMarkdownIt.render(markdown)
return this.avoidTruncatedLinks(html)
}
enhancedMarkdownToHTML (markdown: string) {
- const html = this.enhancedMarkdownIt.render(markdown)
+ if (!markdown) return ''
+ const html = this.enhancedMarkdownIt.render(markdown)
return this.avoidTruncatedLinks(html)
}