From 8ee25e17b88b970703f4df9e74cb4726bbffd837 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 31 May 2021 11:33:49 +0200 Subject: Add ability to set custom markdown in description --- .../about-instance/about-instance.component.html | 4 ++-- .../about-instance/about-instance.component.ts | 20 ++++++++++++++++---- client/src/app/+about/about.module.ts | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'client/src/app/+about') diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.html index 1f372090e..29dfd89fb 100644 --- a/client/src/app/+about/about-instance/about-instance.component.html +++ b/client/src/app/+about/about-instance/about-instance.component.html @@ -91,7 +91,7 @@
Description -
+
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 @@ import { ViewportScroller } from '@angular/common' -import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core' +import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' import { Notifier } from '@app/core' -import { copyToClipboard } from '../../../root-helpers/utils' +import { CustomMarkupService } from '@app/shared/shared-custom-markup' import { InstanceService } from '@app/shared/shared-instance' -import { ServerConfig } from '@shared/models' +import { About, ServerConfig } from '@shared/models' +import { copyToClipboard } from '../../../root-helpers/utils' import { ResolverData } from './about-instance.resolver' @Component({ @@ -14,12 +15,13 @@ import { ResolverData } from './about-instance.resolver' styleUrls: [ './about-instance.component.scss' ] }) export class AboutInstanceComponent implements OnInit, AfterViewChecked { + @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent shortDescription = '' + descriptionContent: string html = { - description: '', terms: '', codeOfConduct: '', moderationInformation: '', @@ -40,6 +42,7 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { private lastScrollHash: string constructor ( + private customMarkupService: CustomMarkupService, private viewportScroller: ViewportScroller, private route: ActivatedRoute, private notifier: Notifier, @@ -67,9 +70,12 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { this.categories = categories this.shortDescription = about.instance.shortDescription + this.descriptionContent = about.instance.description this.html = await this.instanceService.buildHtml(about) + await this.injectDescription(about) + this.initialized = true } @@ -90,4 +96,10 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { copyToClipboard(link) this.notifier.success(link, $localize `Link copied`) } + + private async injectDescription (about: About) { + const element = await this.customMarkupService.buildElement(about.instance.description) + + this.descriptionWrapper.nativeElement.appendChild(element) + } } diff --git a/client/src/app/+about/about.module.ts b/client/src/app/+about/about.module.ts index 1aca14033..dfea52fb8 100644 --- a/client/src/app/+about/about.module.ts +++ b/client/src/app/+about/about.module.ts @@ -5,6 +5,7 @@ import { AboutInstanceResolver } from '@app/+about/about-instance/about-instance import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' import { AboutPeertubeContributorsComponent } from '@app/+about/about-peertube/about-peertube-contributors.component' import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component' +import { SharedCustomMarkupModule } from '@app/shared/shared-custom-markup' import { SharedFormModule } from '@app/shared/shared-forms' import { SharedGlobalIconModule } from '@app/shared/shared-icons' import { SharedInstanceModule } from '@app/shared/shared-instance' @@ -19,7 +20,8 @@ import { AboutComponent } from './about.component' SharedMainModule, SharedFormModule, SharedInstanceModule, - SharedGlobalIconModule + SharedGlobalIconModule, + SharedCustomMarkupModule ], declarations: [ -- cgit v1.2.3