Not working

This commit is contained in:
Michael Washington
2019-11-29 15:03:48 -08:00
parent 248d73cd31
commit ac3144fca4
9 changed files with 269 additions and 4 deletions

View File

@ -0,0 +1,88 @@
@namespace Oqtane.Modules.Controls
@inherits ModuleBase
@inject IJSRuntime JSRuntime
<div @ref="@ToolBar">
@ToolbarContent
</div>
<div @ref="@EditorElement">
@EditorContent
</div>
@code {
[Parameter]
public RenderFragment EditorContent { get; set; }
[Parameter]
public RenderFragment ToolbarContent { get; set; }
[Parameter]
public bool ReadOnly { get; set; }
= false;
[Parameter]
public string Placeholder { get; set; }
= "Compose an epic...";
[Parameter]
public string Theme { get; set; }
= "snow";
[Parameter]
public string DebugLevel { get; set; }
= "info";
private ElementReference EditorElement;
private ElementReference ToolBar;
protected override async Task
OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await RichTextEditorInterop.CreateEditor(
JSRuntime,
EditorElement,
ToolBar,
ReadOnly,
Placeholder,
Theme,
DebugLevel);
}
}
public async Task<string> GetText()
{
return await RichTextEditorInterop.GetText(
JSRuntime,
EditorElement);
}
public async Task<string> GetHTML()
{
return await RichTextEditorInterop.GetHTML(
JSRuntime,
EditorElement);
}
public async Task<string> GetContent()
{
return await RichTextEditorInterop.GetContent(
JSRuntime,
EditorElement);
}
public async Task LoadContent(string Content)
{
await RichTextEditorInterop.LoadEditorContent(
JSRuntime,
EditorElement, Content);
}
public async Task EnableEditor(bool mode)
{
await RichTextEditorInterop.EnableEditor(
JSRuntime,
EditorElement, mode);
}
}

View File

@ -1,5 +1,6 @@
@using Oqtane.Modules.HtmlText.Services
@using Oqtane.Modules.HtmlText.Models
@using Oqtane.Modules.Controls
@namespace Oqtane.Modules.HtmlText
@inherits ModuleBase
@inject NavigationManager NavigationManager
@ -12,7 +13,38 @@
<label for="Name" class="control-label">Content: </label>
</td>
<td>
<textarea class="form-control" @bind="@content" rows="5" />
<RichTextEditor @ref="@RichTextEditorHtml">
<ToolbarContent>
<select class="ql-header">
<option selected=""></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
<option value="4"></option>
<option value="5"></option>
</select>
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
<select class="ql-background"></select>
</span>
<span class="ql-formats">
<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>
</span>
<span class="ql-formats">
<button class="ql-link"></button>
</span>
</ToolbarContent>
<EditorContent>
@((MarkupString)@content)
</EditorContent>
</RichTextEditor>
</td>
</tr>
</table>
@ -26,6 +58,7 @@
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
public override string Title { get { return "Edit Html/Text"; } }
RichTextEditor RichTextEditorHtml;
string content;
string createdby;
DateTime createdon;
@ -38,6 +71,7 @@
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
content = htmltext.Content;
@ -56,6 +90,8 @@
private async Task SaveContent()
{
content = await this.RichTextEditorHtml.GetHTML();
try
{
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);