Skip to content

Commit

Permalink
Merge pull request #4139 from sbwalker/dev
Browse files Browse the repository at this point in the history
more changes for #4134 - ensure HTML content is preserved
  • Loading branch information
sbwalker committed Apr 12, 2024
2 parents bcf7bcb + 39dff1e commit 611ba97
Showing 1 changed file with 17 additions and 5 deletions.
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

0 comments on commit 611ba97

Please sign in to comment.