Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more changes for #4134 - ensure HTML content is preserved #4139

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Oqtane.Client/Modules/Controls/RichTextEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
private bool _richfilemanager = false;
private FileManager _fileManager;
private string _richhtml = string.Empty;
private string _originalrichhtml = string.Empty;
private bool _rawfilemanager = false;
private string _rawhtml = string.Empty;
private string _originalrawhtml = string.Empty;
Expand Down Expand Up @@ -156,6 +157,7 @@
_richhtml = Content;
_rawhtml = Content;
_originalrawhtml = _rawhtml; // preserve for comparison later
_originalrichhtml = "";
_contentchanged = true;

if (!AllowRichText)
Expand Down Expand Up @@ -184,6 +186,9 @@

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 as it may have changed)
_originalrichhtml = await interop.GetHtml(_editorElement);

_initialized = true;
}
else
Expand All @@ -194,6 +199,7 @@
{
// reload if content passed to component has changed
await interop.LoadEditorContent(_editorElement, _richhtml);
_originalrichhtml = await interop.GetHtml(_editorElement);
}
else
{
Expand Down Expand Up @@ -232,18 +238,24 @@
}
else
{
var richhtml = "";

if (AllowRichText)
{
// return rich text content
var interop = new RichTextEditorInterop(JSRuntime);
return await interop.GetHtml(_editorElement);
richhtml = await interop.GetHtml(_editorElement);
}

if (richhtml != _originalrichhtml && !string.IsNullOrEmpty(richhtml))
{
return richhtml;
}
else
{
// return original raw html content
return _originalrawhtml;
// return original raw html content
return _originalrawhtml;
}
}
}
}

public async Task InsertRichImage()
Expand Down