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>
|
<label for="Name" class="control-label">Content: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@if (!RichTextEditorMode)
|
||||||
|
{
|
||||||
|
<textarea class="form-control" @bind="@content" rows="5" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
<RichTextEditor @ref="@RichTextEditorHtml">
|
<RichTextEditor @ref="@RichTextEditorHtml">
|
||||||
<ToolbarContent>
|
<ToolbarContent>
|
||||||
<select class="ql-header">
|
<select class="ql-header">
|
||||||
@ -42,9 +48,18 @@
|
|||||||
</span>
|
</span>
|
||||||
</ToolbarContent>
|
</ToolbarContent>
|
||||||
</RichTextEditor>
|
</RichTextEditor>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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>
|
<button type="button" class="btn btn-success" @onclick="SaveContent">Save</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||||
<br />
|
<br />
|
||||||
@ -56,6 +71,7 @@
|
|||||||
public override string Title { get { return "Edit Html/Text"; } }
|
public override string Title { get { return "Edit Html/Text"; } }
|
||||||
|
|
||||||
RichTextEditor RichTextEditorHtml;
|
RichTextEditor RichTextEditorHtml;
|
||||||
|
bool RichTextEditorMode = true;
|
||||||
string content;
|
string content;
|
||||||
string createdby;
|
string createdby;
|
||||||
DateTime createdon;
|
DateTime createdon;
|
||||||
@ -66,19 +82,7 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
|
await LoadText();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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()
|
private async Task SaveContent()
|
||||||
|
{
|
||||||
|
if (RichTextEditorMode)
|
||||||
{
|
{
|
||||||
content = await this.RichTextEditorHtml.GetHTML();
|
content = await this.RichTextEditorHtml.GetHTML();
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user