oqtane.framework/Oqtane.Client/Modules/HtmlText/Index.razor

41 lines
1.1 KiB
Plaintext

@using Oqtane.Modules.HtmlText.Services
@namespace Oqtane.Modules.HtmlText
@inherits ModuleBase
@inject IHtmlTextService HtmlTextService
@inject IStringLocalizer<Index> Localizer
@if (PageState.EditMode)
{
<div class="text-center mb-2">
<ActionLink Action="Edit" EditMode="true" ResourceKey="Edit" />
</div>
}
@((MarkupString)content)
@code {
private string content = "";
public override string RenderMode => RenderModes.Static;
protected override async Task OnParametersSetAsync()
{
try
{
if (ShouldRender())
{
var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
content = htmltext.Content;
content = Utilities.FormatContent(content, PageState.Alias, "render");
}
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading Content {Error}", ex.Message);
AddModuleMessage(Localizer["Error.Content.Load"], MessageType.Error);
}
}
}