oqtane.framework: [BUG] RichTextEditor content is always empty and can't be saved for rich text mode
Oqtane Info
Version - 5.1.0 (latest dev branch) Render Mode - Static Interactivity - Server Database - SQL Server
Describe the bug
Rich Text Editor content is always empty after the new _initialize property was added to resolve https://github.com/oqtane/oqtane.blogs/issues/44 (error that I was also facing).
Here’s a sample demo video in the latest dev branch where it can be seen that the content for Rich Text mode is empty, while the RawHtml is fine.
I debugged RichTextEditor component and the branch inside the _initialized condition is never accessed, so await interop.LoadEditorContent(_editorElement, _richhtml); is never called and the content is empty.
if (_initialized)
{
if (!_richfilemanager) // do not override the content when the file manager is displayed
{
await interop.LoadEditorContent(_editorElement, _richhtml);
}
if (string.IsNullOrEmpty(_originalrichhtml))
{
// preserve a copy of the rich text content (Quill sanitizes content so we need to retrieve it from the editor as it may have changed)
_originalrichhtml = await interop.GetHtml(_editorElement);
}
}
Also, new content is not saved (always empty) when in RichText mode but is saved when written in raw html. Here’s another sample video:
I believe I’ve traced it to this condition of the GetHtml method, where if the _originalrichhtml is empty because we are actually writing it for the first time, it immediately returns the _originalrichhtml, which is obviously empty. I’ve debugged it and richhtml did actually contain the desired value, but it returns the empty original one.
// 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;
}
else
{
// return original raw html content
return _originalrawhtml;
}
Lastly, inserting images in rich mode is still displaying some weird behaviour even after fixing https://github.com/oqtane/oqtane.framework/issues/4108. In this case, the content is not lost when the image is inserted, it’s lost when the FileManager is closed without inserting an image.
Here’s a sample video:
Expected Behavior
RichText mode should load and save content properly.
Steps To Reproduce
Test all the issues I reported in the latest dev branch with the Oqtane HtmlText modules in the home page.
Anything else?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (24 by maintainers)
Commits related to this issue
- fix #4134 - RichTextEditor scenarios — committed to sbwalker/oqtane.framework by sbwalker 3 years ago
- Merge pull request #4137 from sbwalker/dev fix #4134 - RichTextEditor scenarios — committed to oqtane/oqtane.framework by sbwalker 3 years ago
- more changes for #4134 - ensure HTML content is preserved — committed to sbwalker/oqtane.framework by sbwalker 3 years ago
- Merge pull request #4139 from sbwalker/dev more changes for #4134 - ensure HTML content is preserved — committed to oqtane/oqtane.framework by sbwalker 3 years ago
- fixes for #4134 - Rich Text Editor — committed to sbwalker/oqtane.framework by sbwalker 3 years ago
- Merge pull request #4144 from sbwalker/dev fixes for #4134 - Rich Text Editor — committed to oqtane/oqtane.framework by sbwalker 3 years ago
I mentioned above that I am unable to reproduce the latest behavior as there is no use case within the framework which utilizes the component in the way your custom module uses it. I am going to close this issue as completed as I believe it resolves the original issue which was reported - and does not introduce any new regression issues in the various use cases which are testable (ie. Html/Text module, Blog module, etc…)