Hey guys, I have a question (:
We build a comment section in our application with your RTE and it's working great so far, but:
Is there a way to get the Markup of the RTE at any point with a call? We know that ValueChanged gets called OnBlur and that we can configure a SaveInterval and can use AutoSaveOnIdle, but our problem is that our users should be able to send a message by pressing enter, so they don't unfocus the RTE by pressing anywhere else.
We can't use a very low SaveIntverval like 1ms, because it causes a very high network usage (we don't know why) in our application. The Windows ResourceMonitor says, that the receiving bits are raising from 1000 B/s up to >50.000 B/s by just clickling in the RTE when we use SaveInterval="1" with no AutoSaveOnIdle.
If we use AutoSaveOnIdle with a Delay like 10 ms, if someone types and presses Enter immedeatly, we don't have the whole text while sending the message (we need the Markup, the plain text we get by _editor.GetText() is not what we need).
Is there any way to access the Markup with a call? _editor.GetXhtml() doesn't help here (We receive the last saved value). Do you have any suggestions?
Btw: When writing in the RTE and then disabling the RTE with e.g. Enter, the RTE gets disabled but I am still able to write in it, because I never loss focus. :P
Best regards,
Patrick
|
<head>
. . .
<script src="~/jsinterop.js"></script>
</head> |
|
window.RichTextEditor = {
getValue: function (id) {
var rteInstance = document.getElementById(id).blazor__instance;
// Retrieve the current Rich Text Editor value.
return rteInstance.getInputInnerHtml();
}
} |
|
@using Syncfusion.Blazor.RichTextEditor
<div @onkeydown="@onEnterClick" @onkeydown:preventDefault="@isPreventKey">
<SfRichTextEditor @ref="@rteObj" @bind-Value="@this.rteValue">
</SfRichTextEditor>
b</div>
@code {
[Inject]
IJSRuntime JsRuntime { get; set; }
SfRichTextEditor rteObj;
public string rteValue { get; set; }
private bool isPreventKey { get; set; }
public async Task onEnterClick(KeyboardEventArgs args)
{
this.isPreventKey = false;
if (args.Key == "Enter" && args.Code == "Enter")
{
this.isPreventKey = true;
//Method called on enter key press.
string result = await JsRuntime.InvokeAsync<string>("RichTextEditor.getValue", this.rteObj.ID);
}
}
} |
That's exactly what i was looking for! Thank you very much! Great support!