diff --git a/Oqtane.Client/Modules/HtmlText/Edit.razor b/Oqtane.Client/Modules/HtmlText/Edit.razor
index 48f6daf7..282c23ba 100644
--- a/Oqtane.Client/Modules/HtmlText/Edit.razor
+++ b/Oqtane.Client/Modules/HtmlText/Edit.razor
@@ -70,8 +70,8 @@ else
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
public override string Title { get { return "Edit Html/Text"; } }
- RichTextEditor RichTextEditorHtml;
bool RichTextEditorMode = true;
+ RichTextEditor RichTextEditorHtml;
string content;
string createdby;
DateTime createdon;
@@ -117,13 +117,20 @@ else
private async Task RichTextEditor()
{
RichTextEditorMode = true;
- await LoadText();
+ //TODO: maybe exists better solution than delay. Without this editor becomes corrupted.
+ await Task.Delay(100);
+ await RichTextEditorHtml.LoadContent(content);
+ StateHasChanged();
}
private async Task RawHTMLEditor()
{
+ if (RichTextEditorMode)
+ {
+ content = await this.RichTextEditorHtml.GetHTML();
+ }
RichTextEditorMode = false;
- await LoadText();
+ // await LoadText();
}
private async Task SaveContent()
diff --git a/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs b/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
index 6027e62c..8639a737 100644
--- a/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
+++ b/Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using System.Net.Http;
using Microsoft.AspNetCore.Components;
@@ -31,8 +33,10 @@ namespace Oqtane.Modules.HtmlText.Services
HtmlTextInfo htmltext;
try
{
- // exception handling is required because GetJsonAsync() returns an error if no content exists for the ModuleId ( https://github.com/aspnet/AspNetCore/issues/14041 )
- htmltext = await _http.GetJsonAsync(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
+ //because GetJsonAsync() returns an error if no content exists for the ModuleId ( https://github.com/aspnet/AspNetCore/issues/14041 )
+ //null value is transfered as empty list
+ var htmltextList = await _http.GetJsonAsync>(apiurl + "/" + ModuleId.ToString() + "?entityid=" + ModuleId.ToString());
+ htmltext = htmltextList.FirstOrDefault();
}
catch
{
diff --git a/Oqtane.Client/Themes/Controls/ControlPanel.razor b/Oqtane.Client/Themes/Controls/ControlPanel.razor
index 2680fa3b..d731b99e 100644
--- a/Oqtane.Client/Themes/Controls/ControlPanel.razor
+++ b/Oqtane.Client/Themes/Controls/ControlPanel.razor
@@ -317,7 +317,7 @@
}
PageModule pagemodule = new PageModule();
- pagemodule.PageId = (pageid != "-") ? PageState.Page.PageId : int.Parse(pageid);
+ pagemodule.PageId = (pageid == "-") ? PageState.Page.PageId : int.Parse(pageid);
pagemodule.ModuleId = int.Parse(moduleid);
pagemodule.Title = title;
if (pagemodule.Title == "")
diff --git a/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs b/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
index 30349611..bb8db89c 100644
--- a/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
+++ b/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Oqtane.Infrastructure;
using Oqtane.Shared;
using System;
+using System.Collections.Generic;
namespace Oqtane.Modules.HtmlText.Controllers
{
@@ -29,22 +30,24 @@ namespace Oqtane.Modules.HtmlText.Controllers
// GET api//5
[HttpGet("{id}")]
[Authorize(Policy = "ViewModule")]
- public HtmlTextInfo Get(int id)
+ public List Get(int id)
{
+ var list = new List();
try
{
HtmlTextInfo HtmlText = null;
if (_entityId == id)
{
HtmlText = _htmlText.GetHtmlText(id);
+ list.Add(HtmlText);
}
- return HtmlText;
}
catch (Exception ex)
{
_logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message);
throw;
}
+ return list;
}
// POST api/