Browse Source

Refactoring

pull/15489/head
Salih 4 years ago
parent
commit
840829ed52
  1. 5
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Renderers/MarkdownToHtmlRenderer.cs
  2. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs

5
modules/cms-kit/src/Volo.CmsKit.Common.Web/Renderers/MarkdownToHtmlRenderer.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -34,7 +35,7 @@ public class MarkdownToHtmlRenderer : IMarkdownToHtmlRenderer, ITransientDepende
html = _htmlSanitizer.Sanitize(html); html = _htmlSanitizer.Sanitize(html);
} }
if(referralLinks != null) if(!referralLinks.IsNullOrWhiteSpace())
{ {
html = SetReferralLinks(html, referralLinks); html = SetReferralLinks(html, referralLinks);
} }

4
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs

@ -101,12 +101,12 @@ public class CommentingViewComponent : AbpViewComponent
private async Task ConvertMarkdownTextsToHtml(CommentingViewModel viewModel) private async Task ConvertMarkdownTextsToHtml(CommentingViewModel viewModel)
{ {
viewModel.RawCommentTexts = new Dictionary<Guid, string>(); viewModel.RawCommentTexts = new Dictionary<Guid, string>();
var referralLinks = viewModel.ReferralLinks?.ToArray(); var referralLinks = viewModel.ReferralLinks?.JoinAsString(" ");
foreach (var comment in viewModel.Comments) foreach (var comment in viewModel.Comments)
{ {
viewModel.RawCommentTexts.Add(comment.Id, comment.Text); viewModel.RawCommentTexts.Add(comment.Id, comment.Text);
comment.Text = await MarkdownToHtmlRenderer.RenderAsync(comment.Text, allowHtmlTags: false, preventXSS: true, referralLinks: referralLinks.JoinAsString(" ")); comment.Text = await MarkdownToHtmlRenderer.RenderAsync(comment.Text, allowHtmlTags: false, preventXSS: true, referralLinks: referralLinks);
foreach (var reply in comment.Replies) foreach (var reply in comment.Replies)
{ {

Loading…
Cancel
Save