Merge pull request #3641 from sbwalker/dev

fix issue where rich text was not being refreshed in the editor when content changed, and original rich text was not always preserved
This commit is contained in:
Shaun Walker 2024-01-12 15:49:53 -05:00 committed by GitHub
commit e44b31d755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,12 +162,15 @@
_richhtml = Content; _richhtml = Content;
_rawhtml = Content; _rawhtml = Content;
_originalrawhtml = _rawhtml; // preserve for comparison later _originalrawhtml = _rawhtml; // preserve for comparison later
_originalrichhtml = "";
} }
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
if (AllowRichText)
{
var interop = new RichTextEditorInterop(JSRuntime); var interop = new RichTextEditorInterop(JSRuntime);
if (firstRender) if (firstRender)
@ -179,10 +182,11 @@
Placeholder, Placeholder,
Theme, Theme,
DebugLevel); DebugLevel);
}
await interop.LoadEditorContent(_editorElement, _richhtml); 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) // 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); _originalrichhtml = await interop.GetHtml(_editorElement);