From 3a28068b481962f2907f0dcd2e1ba5de558d99cf Mon Sep 17 00:00:00 2001 From: sbwalker Date: Fri, 12 Jan 2024 15:49:34 -0500 Subject: [PATCH] fix issue where rich text was not being refreshed in the editor when content changed, and original rich text was not always preserved --- .../Modules/Controls/RichTextEditor.razor | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor index ad7980d1..24a14170 100644 --- a/Oqtane.Client/Modules/Controls/RichTextEditor.razor +++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor @@ -162,27 +162,31 @@ _richhtml = Content; _rawhtml = Content; _originalrawhtml = _rawhtml; // preserve for comparison later + _originalrichhtml = ""; } protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); - var interop = new RichTextEditorInterop(JSRuntime); - - if (firstRender) + if (AllowRichText) { - await interop.CreateEditor( - _editorElement, - _toolBar, - ReadOnly, - Placeholder, - Theme, - DebugLevel); + var interop = new RichTextEditorInterop(JSRuntime); + + if (firstRender) + { + await interop.CreateEditor( + _editorElement, + _toolBar, + ReadOnly, + Placeholder, + Theme, + DebugLevel); + } await interop.LoadEditorContent(_editorElement, _richhtml); - if (AllowRichText) + if (string.IsNullOrEmpty(_originalrichhtml)) { // 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);