Back to Devexpress

DxRichEdit.ContentRemoved Event

blazor-devexpress-dot-blazor-dot-richedit-dot-dxrichedit-1fdfe460.md

latest2.9 KB
Original Source

DxRichEdit.ContentRemoved Event

Occurs after content was removed from the Rich Text Editor’s document.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
[Parameter]
public EventCallback<ContentRemovedEventArgs> ContentRemoved { get; set; }

Event Data

The ContentRemoved event's data class is ContentRemovedEventArgs. The following properties provide information specific to this event:

PropertyDescription
IntervalGets the sub-document‘s interval in which content was changed. Inherited from ContentChangedEventArgs.
RemovedTextGets the textual representation of the removed content.
SubDocumentGets the sub-document in which content was changed. Inherited from ContentChangedEventArgs.

Remarks

The Rich Text Editor fires this event in the following cases:

  • Content was removed from the document.
  • Content was moved inside the document.
  • A non-empty field was updated.

The following code snippet demonstrates how you can log changes:

razor
<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

ContentInserted

DxRichEdit Class

DxRichEdit Members

DevExpress.Blazor.RichEdit Namespace