From 2476b3409884b845d635d296a2cce6aae190b294 Mon Sep 17 00:00:00 2001 From: Jack Fistelmann Date: Wed, 11 Sep 2024 17:03:29 +0200 Subject: [PATCH] feat(blazor): html ui message alert added property to control whether the message is html or not closes #19785 --- .../AspNetCore/Components/Messages/UiMessageOptions.cs | 5 +++++ .../Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor | 9 ++++++++- .../Components/UiMessageAlert.razor.cs | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs index a13029a5804..93faa51b4eb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs @@ -49,4 +49,9 @@ public class UiMessageOptions /// Custom icon for the Cancel button. /// public object? CancelButtonIcon { get; set; } + + /// + /// Whether the message is html (true) or plain text (false) + /// + public bool IsMessageHtmlMarkup { get; set; } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor index 629317aea6d..9e0d86c112d 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor @@ -16,7 +16,14 @@ } - @Message + @if (!IsMessageHtmlMarkup) + { + @Message + } + else + { + @((MarkupString)Message) + } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs index 60ba8e8dd7c..1bedfea916f 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs @@ -21,6 +21,9 @@ protected virtual bool CenterMessage protected virtual bool ShowMessageIcon => Options?.ShowMessageIcon ?? true; + protected virtual bool IsMessageHtmlMarkup + => Options?.IsMessageHtmlMarkup ?? false; + protected virtual object? MessageIcon => Options?.MessageIcon ?? MessageType switch { UiMessageType.Info => IconName.Info,