diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
index 413f63a1..ad7980d1 100644
--- a/Oqtane.Client/Modules/Controls/RichTextEditor.razor
+++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor
@@ -6,70 +6,75 @@
-
-
- @if (_richfilemanager)
- {
-
-
-
- }
-
- @if (AllowRawHtml)
- {
- @((MarkupString)" ")
- }
- @if (AllowFileManagement)
- {
-
- }
- @if (_richfilemanager)
- {
- @((MarkupString)" ")
-
- }
-
-
-
-
- @if (ToolbarContent != null)
- {
- @ToolbarContent
- }
- else
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
+
+ @if (AllowRichText)
+ {
+
+ @if (_richfilemanager)
+ {
+
+
+
+ }
+
+ @if (AllowRawHtml)
+ {
+
+
+ @((MarkupString)" ")
+ }
+ @if (AllowFileManagement)
+ {
+
+ }
+ @if (_richfilemanager)
+ {
+ @((MarkupString)" ")
+
+ }
+
+
+
+
+ @if (ToolbarContent != null)
+ {
+ @ToolbarContent
+ }
+ else
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+ }
@if (AllowRawHtml)
{
@@ -106,7 +111,6 @@
@code {
- private string _activeTab = "Rich";
private ElementReference _editorElement;
private ElementReference _toolBar;
private bool _richfilemanager = false;
@@ -130,6 +134,9 @@
[Parameter]
public bool AllowFileManagement { get; set; } = true;
+ [Parameter]
+ public bool AllowRichText { get; set; } = true;
+
[Parameter]
public bool AllowRawHtml { get; set; } = true;
@@ -175,57 +182,59 @@
await interop.LoadEditorContent(_editorElement, _richhtml);
- // preserve a copy of the rich text content (Quill sanitizes content so we need to retrieve it from the editor)
- _originalrichhtml = await interop.GetHtml(_editorElement);
- if (_originalrichhtml != _originalrawhtml)
+ if (AllowRichText)
{
- _activeTab = "Raw";
- StateHasChanged();
+ // preserve a copy of the rich text content (Quill sanitizes content so we need to retrieve it from the editor)
+ _originalrichhtml = await interop.GetHtml(_editorElement);
}
+ }
+ }
- }
- }
+ public void CloseRichFileManager()
+ {
+ _richfilemanager = false;
+ _message = string.Empty;
+ StateHasChanged();
+ }
- public void CloseRichFileManager()
- {
- _richfilemanager = false;
- _message = string.Empty;
- StateHasChanged();
- }
+ public void CloseRawFileManager()
+ {
+ _rawfilemanager = false;
+ _message = string.Empty;
+ StateHasChanged();
+ }
- public void CloseRawFileManager()
- {
- _rawfilemanager = false;
- _message = string.Empty;
- StateHasChanged();
- }
+ public void RefreshRichText()
+ {
+ _richhtml = _rawhtml;
+ StateHasChanged();
+ }
- public void RefreshRichText()
- {
- _richhtml = _rawhtml;
- StateHasChanged();
- }
+ public async Task RefreshRawHtml()
+ {
+ var interop = new RichTextEditorInterop(JSRuntime);
+ _rawhtml = await interop.GetHtml(_editorElement);
+ StateHasChanged();
+ }
- public async Task RefreshRawHtml()
- {
- var interop = new RichTextEditorInterop(JSRuntime);
- _rawhtml = await interop.GetHtml(_editorElement);
- StateHasChanged();
- }
-
- public async Task
GetHtml()
- {
- // evaluate raw html content as first priority
- if (_rawhtml != _originalrawhtml)
- {
- return _rawhtml;
- }
- else
- {
- // return rich text content if it has changed
- var interop = new RichTextEditorInterop(JSRuntime);
- var richhtml = await interop.GetHtml(_editorElement);
- if (richhtml != _originalrichhtml)
+ public async Task GetHtml()
+ {
+ // evaluate raw html content as first priority
+ if (_rawhtml != _originalrawhtml)
+ {
+ return _rawhtml;
+ }
+ else
+ {
+ var richhtml = "";
+ if (AllowRichText)
+ {
+ // return rich text content if it has changed
+ var interop = new RichTextEditorInterop(JSRuntime);
+ richhtml = await interop.GetHtml(_editorElement);
+ }
+ // rich text value will only be blank if AllowRichText is disabled or the JS Interop method failed
+ if (richhtml != _originalrichhtml && !string.IsNullOrEmpty(richhtml) && !string.IsNullOrEmpty(_originalrichhtml))
{
return richhtml;
}