diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-31 11:33:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-31 11:33:49 +0200 |
commit | 8ee25e17b88b970703f4df9e74cb4726bbffd837 (patch) | |
tree | 450d73715c747c82efe6c919ebeda6411c01c5e0 /client/src/app/+about/about-instance/about-instance.component.ts | |
parent | 15f35256af15b97d2298cc44e76ffcafe73a1c88 (diff) | |
download | PeerTube-8ee25e17b88b970703f4df9e74cb4726bbffd837.tar.gz PeerTube-8ee25e17b88b970703f4df9e74cb4726bbffd837.tar.zst PeerTube-8ee25e17b88b970703f4df9e74cb4726bbffd837.zip |
Add ability to set custom markdown in description
Diffstat (limited to 'client/src/app/+about/about-instance/about-instance.component.ts')
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.component.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index 7eb382a46..2e0996429 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { ViewportScroller } from '@angular/common' | 1 | import { ViewportScroller } from '@angular/common' |
2 | import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core' | 2 | import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute } from '@angular/router' | 3 | import { ActivatedRoute } from '@angular/router' |
4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | 4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
5 | import { Notifier } from '@app/core' | 5 | import { Notifier } from '@app/core' |
6 | import { copyToClipboard } from '../../../root-helpers/utils' | 6 | import { CustomMarkupService } from '@app/shared/shared-custom-markup' |
7 | import { InstanceService } from '@app/shared/shared-instance' | 7 | import { InstanceService } from '@app/shared/shared-instance' |
8 | import { ServerConfig } from '@shared/models' | 8 | import { About, ServerConfig } from '@shared/models' |
9 | import { copyToClipboard } from '../../../root-helpers/utils' | ||
9 | import { ResolverData } from './about-instance.resolver' | 10 | import { ResolverData } from './about-instance.resolver' |
10 | 11 | ||
11 | @Component({ | 12 | @Component({ |
@@ -14,12 +15,13 @@ import { ResolverData } from './about-instance.resolver' | |||
14 | styleUrls: [ './about-instance.component.scss' ] | 15 | styleUrls: [ './about-instance.component.scss' ] |
15 | }) | 16 | }) |
16 | export class AboutInstanceComponent implements OnInit, AfterViewChecked { | 17 | export class AboutInstanceComponent implements OnInit, AfterViewChecked { |
18 | @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef<HTMLInputElement> | ||
17 | @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent | 19 | @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent |
18 | 20 | ||
19 | shortDescription = '' | 21 | shortDescription = '' |
22 | descriptionContent: string | ||
20 | 23 | ||
21 | html = { | 24 | html = { |
22 | description: '', | ||
23 | terms: '', | 25 | terms: '', |
24 | codeOfConduct: '', | 26 | codeOfConduct: '', |
25 | moderationInformation: '', | 27 | moderationInformation: '', |
@@ -40,6 +42,7 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
40 | private lastScrollHash: string | 42 | private lastScrollHash: string |
41 | 43 | ||
42 | constructor ( | 44 | constructor ( |
45 | private customMarkupService: CustomMarkupService, | ||
43 | private viewportScroller: ViewportScroller, | 46 | private viewportScroller: ViewportScroller, |
44 | private route: ActivatedRoute, | 47 | private route: ActivatedRoute, |
45 | private notifier: Notifier, | 48 | private notifier: Notifier, |
@@ -67,9 +70,12 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
67 | this.categories = categories | 70 | this.categories = categories |
68 | 71 | ||
69 | this.shortDescription = about.instance.shortDescription | 72 | this.shortDescription = about.instance.shortDescription |
73 | this.descriptionContent = about.instance.description | ||
70 | 74 | ||
71 | this.html = await this.instanceService.buildHtml(about) | 75 | this.html = await this.instanceService.buildHtml(about) |
72 | 76 | ||
77 | await this.injectDescription(about) | ||
78 | |||
73 | this.initialized = true | 79 | this.initialized = true |
74 | } | 80 | } |
75 | 81 | ||
@@ -90,4 +96,10 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
90 | copyToClipboard(link) | 96 | copyToClipboard(link) |
91 | this.notifier.success(link, $localize `Link copied`) | 97 | this.notifier.success(link, $localize `Link copied`) |
92 | } | 98 | } |
99 | |||
100 | private async injectDescription (about: About) { | ||
101 | const element = await this.customMarkupService.buildElement(about.instance.description) | ||
102 | |||
103 | this.descriptionWrapper.nativeElement.appendChild(element) | ||
104 | } | ||
93 | } | 105 | } |