Merge pull request #4137 from sbwalker/dev
fix #4134 - RichTextEditor scenarios
This commit is contained in:
@ -109,12 +109,12 @@
|
|||||||
private bool _richfilemanager = false;
|
private bool _richfilemanager = false;
|
||||||
private FileManager _fileManager;
|
private FileManager _fileManager;
|
||||||
private string _richhtml = string.Empty;
|
private string _richhtml = string.Empty;
|
||||||
private string _originalrichhtml = string.Empty;
|
|
||||||
private bool _rawfilemanager = false;
|
private bool _rawfilemanager = false;
|
||||||
private string _rawhtml = string.Empty;
|
private string _rawhtml = string.Empty;
|
||||||
private string _originalrawhtml = string.Empty;
|
private string _originalrawhtml = string.Empty;
|
||||||
private string _message = string.Empty;
|
private string _message = string.Empty;
|
||||||
private string _activetab = "Rich";
|
private string _activetab = "Rich";
|
||||||
|
private bool _contentchanged = false;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
@ -156,7 +156,7 @@
|
|||||||
_richhtml = Content;
|
_richhtml = Content;
|
||||||
_rawhtml = Content;
|
_rawhtml = Content;
|
||||||
_originalrawhtml = _rawhtml; // preserve for comparison later
|
_originalrawhtml = _rawhtml; // preserve for comparison later
|
||||||
_originalrichhtml = "";
|
_contentchanged = true;
|
||||||
|
|
||||||
if (!AllowRichText)
|
if (!AllowRichText)
|
||||||
{
|
{
|
||||||
@ -181,24 +181,32 @@
|
|||||||
Placeholder,
|
Placeholder,
|
||||||
Theme,
|
Theme,
|
||||||
DebugLevel);
|
DebugLevel);
|
||||||
}
|
|
||||||
|
|
||||||
|
await interop.LoadEditorContent(_editorElement, _richhtml);
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (_initialized)
|
if (_initialized)
|
||||||
{
|
{
|
||||||
if (!_richfilemanager) // do not override the content when the file manager is displayed
|
if (_contentchanged)
|
||||||
{
|
{
|
||||||
|
// reload if content passed to component has changed
|
||||||
await interop.LoadEditorContent(_editorElement, _richhtml);
|
await interop.LoadEditorContent(_editorElement, _richhtml);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
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)
|
var richhtml = await interop.GetHtml(_editorElement);
|
||||||
_originalrichhtml = await interop.GetHtml(_editorElement);
|
if (richhtml != _richhtml)
|
||||||
|
{
|
||||||
|
await interop.LoadEditorContent(_editorElement, richhtml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_contentchanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_initialized = true; // ensures that the rich text editor is created before trying to access its methods
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseRichFileManager()
|
public void CloseRichFileManager()
|
||||||
@ -224,17 +232,11 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var richhtml = "";
|
|
||||||
if (AllowRichText)
|
if (AllowRichText)
|
||||||
{
|
{
|
||||||
// return rich text content if it has changed
|
// return rich text content
|
||||||
var interop = new RichTextEditorInterop(JSRuntime);
|
var interop = new RichTextEditorInterop(JSRuntime);
|
||||||
richhtml = await interop.GetHtml(_editorElement);
|
return await interop.GetHtml(_editorElement);
|
||||||
}
|
|
||||||
// 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
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user