mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Instance homepage support (#4007)
* Prepare homepage parsers * Add ability to update instance hompage * Add ability to set homepage as landing page * Add homepage preview in admin * Dynamically update left menu for homepage * Inject home content in homepage * Add videos list and channel miniature custom markup * Remove unused elements in markup service
This commit is contained in:
parent
eb34ec30e0
commit
2539932e16
84 changed files with 1761 additions and 407 deletions
|
@ -1,9 +1,10 @@
|
|||
import { ViewportScroller } from '@angular/common'
|
||||
import truncate from 'lodash-es/truncate'
|
||||
import { Subject } from 'rxjs'
|
||||
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
|
||||
import { ViewportScroller } from '@angular/common'
|
||||
import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { SafeHtml } from '@angular/platform-browser'
|
||||
import { MarkdownService, ScreenService } from '@app/core'
|
||||
|
||||
@Component({
|
||||
|
@ -21,18 +22,27 @@ import { MarkdownService, ScreenService } from '@app/core'
|
|||
|
||||
export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
|
||||
@Input() content = ''
|
||||
|
||||
@Input() classes: string[] | { [klass: string]: any[] | any } = []
|
||||
|
||||
@Input() textareaMaxWidth = '100%'
|
||||
@Input() textareaHeight = '150px'
|
||||
|
||||
@Input() truncate: number
|
||||
|
||||
@Input() markdownType: 'text' | 'enhanced' = 'text'
|
||||
@Input() customMarkdownRenderer?: (text: string) => Promise<string | HTMLElement>
|
||||
|
||||
@Input() markdownVideo = false
|
||||
|
||||
@Input() name = 'description'
|
||||
|
||||
@ViewChild('textarea') textareaElement: ElementRef
|
||||
@ViewChild('previewElement') previewElement: ElementRef
|
||||
|
||||
truncatedPreviewHTML: SafeHtml | string = ''
|
||||
previewHTML: SafeHtml | string = ''
|
||||
|
||||
truncatedPreviewHTML = ''
|
||||
previewHTML = ''
|
||||
isMaximized = false
|
||||
|
||||
maximizeInText = $localize`Maximize editor`
|
||||
|
@ -115,10 +125,31 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
|
|||
}
|
||||
|
||||
private async markdownRender (text: string) {
|
||||
const html = this.markdownType === 'text' ?
|
||||
await this.markdownService.textMarkdownToHTML(text) :
|
||||
await this.markdownService.enhancedMarkdownToHTML(text)
|
||||
let html: string
|
||||
|
||||
return this.markdownVideo ? this.markdownService.processVideoTimestamps(html) : html
|
||||
if (this.customMarkdownRenderer) {
|
||||
const result = await this.customMarkdownRenderer(text)
|
||||
|
||||
if (result instanceof HTMLElement) {
|
||||
html = ''
|
||||
|
||||
const wrapperElement = this.previewElement.nativeElement as HTMLElement
|
||||
wrapperElement.innerHTML = ''
|
||||
wrapperElement.appendChild(result)
|
||||
return
|
||||
}
|
||||
|
||||
html = result
|
||||
} else if (this.markdownType === 'text') {
|
||||
html = await this.markdownService.textMarkdownToHTML(text)
|
||||
} else {
|
||||
html = await this.markdownService.enhancedMarkdownToHTML(text)
|
||||
}
|
||||
|
||||
if (this.markdownVideo) {
|
||||
html = this.markdownService.processVideoTimestamps(html)
|
||||
}
|
||||
|
||||
return html
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue