Fix #1837 RichTextEditor Content not re-Rendering

Change to the OnAfterRenderAsync method and changed OnInitialized to OnParametersSet
This commit is contained in:
Leigh
2021-12-03 06:31:45 +01:00
parent 9664ff67f3
commit 65d468be33

View File

@ -120,19 +120,19 @@
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" } new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" }
}; };
protected override void OnInitialized() protected override void OnParametersSet()
{ {
_content = Content; // raw HTML _content = Content; // raw HTML
} }
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) var interop = new RichTextEditorInterop(JSRuntime);
if (firstRender)
{ {
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
var interop = new RichTextEditorInterop(JSRuntime);
await interop.CreateEditor( await interop.CreateEditor(
_editorElement, _editorElement,
_toolBar, _toolBar,
@ -140,14 +140,15 @@
Placeholder, Placeholder,
Theme, Theme,
DebugLevel); DebugLevel);
await interop.LoadEditorContent(_editorElement, Content);
_content = Content; // raw HTML
// preserve a copy of the rich text content ( Quill sanitizes content so we need to retrieve it from the editor )
_original = await interop.GetHtml(_editorElement);
} }
await interop.LoadEditorContent(_editorElement, Content);
_content = Content; // raw HTML
// preserve a copy of the rich text content ( Quill sanitizes content so we need to retrieve it from the editor )
_original = await interop.GetHtml(_editorElement);
} }
public void CloseFileManager() public void CloseFileManager()