Allows you to switch between Rich text and Raw HTML Editor
This commit is contained in:
@ -13,6 +13,12 @@
|
||||
<label for="Name" class="control-label">Content: </label>
|
||||
</td>
|
||||
<td>
|
||||
@if (!RichTextEditorMode)
|
||||
{
|
||||
<textarea class="form-control" @bind="@content" rows="5" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<RichTextEditor @ref="@RichTextEditorHtml">
|
||||
<ToolbarContent>
|
||||
<select class="ql-header">
|
||||
@ -42,9 +48,18 @@
|
||||
</span>
|
||||
</ToolbarContent>
|
||||
</RichTextEditor>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@if (!RichTextEditorMode)
|
||||
{
|
||||
<button type="button" class="btn btn-secondary" @onclick="RichTextEditor">Rich Text Editor</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-secondary" @onclick="RawHTMLEditor">Raw HTML Editor</button>
|
||||
}
|
||||
<button type="button" class="btn btn-success" @onclick="SaveContent">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
@ -56,6 +71,7 @@
|
||||
public override string Title { get { return "Edit Html/Text"; } }
|
||||
|
||||
RichTextEditor RichTextEditorHtml;
|
||||
bool RichTextEditorMode = true;
|
||||
string content;
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
@ -66,19 +82,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
|
||||
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = htmltext.Content;
|
||||
createdby = htmltext.CreatedBy;
|
||||
createdon = htmltext.CreatedOn;
|
||||
modifiedby = htmltext.ModifiedBy;
|
||||
modifiedon = htmltext.ModifiedOn;
|
||||
|
||||
await RichTextEditorHtml.LoadContent(content);
|
||||
}
|
||||
await LoadText();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -87,9 +91,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadText()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
|
||||
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = htmltext.Content;
|
||||
createdby = htmltext.CreatedBy;
|
||||
createdon = htmltext.CreatedOn;
|
||||
modifiedby = htmltext.ModifiedBy;
|
||||
modifiedon = htmltext.ModifiedOn;
|
||||
|
||||
if (RichTextEditorMode)
|
||||
{
|
||||
await RichTextEditorHtml.LoadContent(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RichTextEditor()
|
||||
{
|
||||
RichTextEditorMode = true;
|
||||
await LoadText();
|
||||
}
|
||||
|
||||
private async Task RawHTMLEditor()
|
||||
{
|
||||
RichTextEditorMode = false;
|
||||
await LoadText();
|
||||
}
|
||||
|
||||
private async Task SaveContent()
|
||||
{
|
||||
if (RichTextEditorMode)
|
||||
{
|
||||
content = await this.RichTextEditorHtml.GetHTML();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user