<form *ngIf="hasRegisteredSettings()" role="form" (ngSubmit)="formValidated()" [formGroup]="form">
<div class="form-group" *ngFor="let setting of registeredSettings">
<label *ngIf="setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
+
<input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" />
+
<textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>
+ <my-help *ngIf="setting.type === 'markdown-text'" helpType="markdownText"></my-help>
+
+ <my-help *ngIf="setting.type === 'markdown-enhanced'" helpType="markdownEnhanced"></my-help>
+
+ <my-markdown-textarea
+ *ngIf="setting.type === 'markdown-text'"
+ markdownType="text" [id]="setting.name" [formControlName]="setting.name" textareaWidth="500px" [previewColumn]="false"
+ [classes]="{ 'input-error': formErrors['settings.name'] }"
+ ></my-markdown-textarea>
+
+ <my-markdown-textarea
+ *ngIf="setting.type === 'markdown-enhanced'"
+ markdownType="enhanced" [id]="setting.name" [formControlName]="setting.name" textareaWidth="500px" [previewColumn]="false"
+ [classes]="{ 'input-error': formErrors['settings.name'] }"
+ ></my-markdown-textarea>
+
<my-peertube-checkbox
*ngIf="setting.type === 'input-checkbox'"
[id]="setting.name"
import { AuthService } from '@app/core/auth'
import { Notifier } from '@app/core/notification'
import { RestExtractor } from '@app/shared/rest'
+import { MarkdownService } from '@app/shared/renderer'
import { PluginType } from '@shared/models/plugins/plugin.type'
import { PublicServerSetting } from '@shared/models/plugins/public-server.setting'
import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
private router: Router,
private authService: AuthService,
private notifier: Notifier,
+ private markdownRenderer: MarkdownService,
private server: ServerService,
private zone: NgZone,
private authHttp: HttpClient,
this.customModal.show(input)
},
+ markdownRenderer: {
+ textMarkdownToHTML: (textMarkdown: string) => {
+ return this.markdownRenderer.textMarkdownToHTML(textMarkdown)
+ },
+
+ enhancedMarkdownToHTML: (enhancedMarkdown: string) => {
+ return this.markdownRenderer.enhancedMarkdownToHTML(enhancedMarkdown)
+ }
+ },
+
translate: (value: string) => {
return this.translationsObservable
.pipe(map(allTranslations => allTranslations[npmName]))
confirm?: { value: string, action?: () => void }
}) => void
+ markdownRenderer: {
+ textMarkdownToHTML: (textMarkdown: string) => Promise<string>
+ enhancedMarkdownToHTML: (enhancedMarkdown: string) => Promise<string>
+ }
+
translate: (toTranslate: string) => Promise<string>
}
export interface RegisterServerSettingOptions {
name: string
label: string
- type: 'input' | 'input-checkbox' | 'input-textarea'
+ type: 'input' | 'input-checkbox' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
// If the setting is not private, anyone can view its value (client code included)
// If the setting is private, only server-side hooks can access it
name: 'admin-name',
label: 'Admin name',
type: 'input',
+ // type: input | input-checkbox | input-textarea | markdown-text | markdown-enhanced
default: 'my super name'
})
notifier.error('Error message content.')
```
+#### Markdown Renderer
+
+To render a formatted markdown text to HTML:
+
+```js
+const { markdownRenderer } = peertubeHelpers
+
+await markdownRenderer.textMarkdownToHTML('**My Bold Text**')
+// return <strong>My Bold Text</strong>
+
+await markdownRenderer.enhancedMarkdownToHTML('![alt-img](http://.../my-image.jpg)')
+// return <img alt=alt-img src=http://.../my-image.jpg />
+```
+
#### Custom Modal
To show a custom modal: