@using Oqtane.Modules.HtmlText.Services
@namespace Oqtane.Modules.HtmlText
@inherits ModuleBase
@inject IHtmlTextService HtmlTextService
@inject ISettingService SettingService
@inject IStringLocalizer Localizer
@if (PageState.EditMode)
{
}
@((MarkupString)content)
@if (PageState.EditMode && content.Length > 3000)
{
}
@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");
if (bool.Parse(SettingService.GetSetting(ModuleState.Settings, "DynamicTokens", "false")))
{
content = ReplaceTokens(content);
}
}
else
{
content = "";
}
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading Content {Error}", ex.Message);
AddModuleMessage(Localizer["Error.Content.Load"], MessageType.Error);
}
}
}