From 0e45e336f62a411b3c423be46d16252355c754d7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2022 10:47:39 +0100 Subject: Fix HTML in account/channel description --- .../src/app/shared/shared-abuse-list/abuse-list-table.component.ts | 6 +++--- client/src/app/shared/shared-custom-markup/custom-markup.service.ts | 2 +- .../peertube-custom-tags/channel-miniature-markup.component.ts | 6 +++++- client/src/app/shared/shared-forms/markdown-textarea.component.ts | 4 ++-- client/src/app/shared/shared-instance/instance.service.ts | 2 +- .../src/app/shared/shared-support-modal/support-modal.component.ts | 2 +- .../shared-video-playlist/video-playlist-miniature.component.ts | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts index a3a71ae20..569a37b17 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts @@ -214,8 +214,8 @@ export class AbuseListTableComponent extends RestTable implements OnInit { abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` } else { const truncated = truncate(abuse.comment.text, { length: 100 }) - abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) - abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true) + abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: truncated, withHtml: true }) + abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true }) } } @@ -451,6 +451,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit { } private toHtml (text: string) { - return this.markdownRenderer.textMarkdownToHTML(text) + return this.markdownRenderer.textMarkdownToHTML({ markdown: text }) } } diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts index d738a644e..618c3dd4f 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts @@ -58,7 +58,7 @@ export class CustomMarkupService { } async buildElement (text: string) { - const html = await this.markdown.customPageMarkdownToHTML(text, this.getSupportedTags()) + const html = await this.markdown.customPageMarkdownToHTML({ markdown: text, additionalAllowedTags: this.getSupportedTags() }) const rootElement = document.createElement('div') rootElement.innerHTML = html diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index e9c466a90..ba12b7139 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -42,7 +42,11 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O tap(channel => { this.channel = channel }), - switchMap(() => from(this.markdown.textMarkdownToHTML(this.channel.description))), + switchMap(() => from(this.markdown.textMarkdownToHTML({ + markdown: this.channel.description, + withEmoji: true, + withHtml: true + }))), tap(html => { this.descriptionHTML = html }), diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts index 089991884..e3371f22c 100644 --- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts +++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts @@ -144,9 +144,9 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { html = result } else if (this.markdownType === 'text') { - html = await this.markdownService.textMarkdownToHTML(text) + html = await this.markdownService.textMarkdownToHTML({ markdown: text }) } else { - html = await this.markdownService.enhancedMarkdownToHTML(text) + html = await this.markdownService.enhancedMarkdownToHTML({ markdown: text }) } if (this.markdownVideo) { diff --git a/client/src/app/shared/shared-instance/instance.service.ts b/client/src/app/shared/shared-instance/instance.service.ts index 0241f56ef..89f47db24 100644 --- a/client/src/app/shared/shared-instance/instance.service.ts +++ b/client/src/app/shared/shared-instance/instance.service.ts @@ -51,7 +51,7 @@ export class InstanceService { } for (const key of Object.keys(html)) { - html[key] = await this.markdownService.textMarkdownToHTML(about.instance[key]) + html[key] = await this.markdownService.textMarkdownToHTML({ markdown: about.instance[key] }) } return html diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.ts b/client/src/app/shared/shared-support-modal/support-modal.component.ts index 08e997f7b..f330228e1 100644 --- a/client/src/app/shared/shared-support-modal/support-modal.component.ts +++ b/client/src/app/shared/shared-support-modal/support-modal.component.ts @@ -27,7 +27,7 @@ export class SupportModalComponent { const support = this.video?.support || this.videoChannel.support - this.markdownService.enhancedMarkdownToHTML(support) + this.markdownService.enhancedMarkdownToHTML({ markdown: support }) .then(r => { this.htmlSupport = r }) diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts index dd9fe0a5a..225c4eb64 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts @@ -32,7 +32,7 @@ export class VideoPlaylistMiniatureComponent implements OnInit { async ngOnInit () { this.buildPlaylistUrl() if (this.displayDescription) { - this.playlistDescription = await this.markdownService.textMarkdownToHTML(this.playlist.description) + this.playlistDescription = await this.markdownService.textMarkdownToHTML({ markdown: this.playlist.description }) } } -- cgit v1.2.3