blazor-devexpress-dot-blazor-dot-richedit-dot-contentchangedeventargs-d177e8b9.md
Gets the sub-document in which content was changed.
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public SubDocument SubDocument { get; }
| Type | Description |
|---|---|
| SubDocument |
The sub-document.
|
You can access this event argument inside the ContentInserted and ContentRemoved event handlers. Depending on the event, the SubDocument property returns the sub-document into which content was inserted or from which content was removed. To get the changed interval within this sub-document, use the Interval event argument.
The following code snippet demonstrates how you can log changes:
<DxRichEdit ContentInserted="OnContentInserted" ContentRemoved="OnContentRemoved"/>
@code {
string filePath;
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
filePath = @"C:\ChangeLogs\" + DateTime.Now.ToString("yyyy-M-d") + ".txt";
using (FileStream fs = File.Create(filePath));
}
async void OnContentInserted(ContentChangedEventArgs args) {
TextSpan textSpan = await args.SubDocument.GetTextSpanAsync(args.Interval);
File.AppendAllText(filePath,
"'" + textSpan.Text + "': was inserted to " + args.SubDocument.Type.ToString() +'\n');
}
async void OnContentRemoved(ContentRemovedEventArgs args) {
File.AppendAllText(filePath,
"'" + args.RemovedText + "': was removed from " + args.SubDocument.Type.ToString() +'\n');
}
}
See Also