Hi Mark,
Greetings from Syncfusion support.
We have validated your query “Is it possible to programmatically scroll the text to the bottom? I am adding text to the control from with C# code, and I would then like the text to scroll to the bottom when it has been added, again, ideally through C# code.”
By default, the Rich Text Editor doesn’t have the support to scroll to the bottom of the text content added, and also it cannot be achieved using the C# code. But this can be achieved using the JSInterop concept. We have prepared a sample for your reference,
Code Snippet:
_Host.cshtml
<head>
. . .
<script src="~/jsinterop.js"></script>
</head> |
Index.razor
<SfButton OnClick="@addContent">Add Content</SfButton>
<SfRichTextEditor @ref="RteObj" Value="@rteValue" Height="500px" Width="100%">
@*<RichTextEditorToolbarSettings Items="@Tools" Enable="true"></RichTextEditorToolbarSettings>*@
</SfRichTextEditor>
@code {
[Inject]
IJSRuntime JsRuntime { get; set; }
SfRichTextEditor RteObj;
public string rteValue { get; set; }
public async Task addContent()
{
this.rteValue = "RTE content . . .";
await Task.Delay(500);
JsRuntime.InvokeAsync<string>("RichTextEditor.scrollToView");
}
} |
jsinterop.js
window.RichTextEditor = {
scrollToView: function () {
var currentElement = document.querySelector('.e-richtexteditor .e-content').lastElementChild;
currentElement.focus()
currentElement.scrollIntoView(false);
}
} |
Please check the above code snippet and the sample and let us know if it satisfies your requirement.
Regards,
Revanth