From ac3144fca4d36fe92911323696146d7ecfdb6f00 Mon Sep 17 00:00:00 2001 From: Michael Washington Date: Fri, 29 Nov 2019 15:03:48 -0800 Subject: [PATCH 1/5] Not working --- .../Modules/Controls/RichTextEditor.razor | 88 +++++++++++++++++++ Oqtane.Client/Modules/HtmlText/Edit.razor | 38 +++++++- Oqtane.Client/Shared/Interop.cs | 3 +- Oqtane.Client/Shared/RichTextEditorInterop.cs | 70 +++++++++++++++ Oqtane.Client/wwwroot/index.html | 3 + Oqtane.Client/wwwroot/js/interop.js | 32 +++++++ Oqtane.Server/Pages/_Host.cshtml | 3 + Oqtane.Server/appsettings.json | 2 +- Oqtane.Server/wwwroot/js/interop.js | 34 ++++++- 9 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 Oqtane.Client/Modules/Controls/RichTextEditor.razor create mode 100644 Oqtane.Client/Shared/RichTextEditorInterop.cs diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor new file mode 100644 index 00000000..527b091c --- /dev/null +++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor @@ -0,0 +1,88 @@ +@namespace Oqtane.Modules.Controls +@inherits ModuleBase +@inject IJSRuntime JSRuntime + +
+ @ToolbarContent +
+
+ @EditorContent +
+ +@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 GetText() + { + return await RichTextEditorInterop.GetText( + JSRuntime, + EditorElement); + } + + public async Task GetHTML() + { + return await RichTextEditorInterop.GetHTML( + JSRuntime, + EditorElement); + } + + public async Task 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); + } +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/HtmlText/Edit.razor b/Oqtane.Client/Modules/HtmlText/Edit.razor index f9d891d4..42a9763c 100644 --- a/Oqtane.Client/Modules/HtmlText/Edit.razor +++ b/Oqtane.Client/Modules/HtmlText/Edit.razor @@ -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 @@ -