DxRichEdit.ContentInserted Event
Occurs after content was inserted in the Rich Text Editor’s document.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
[Parameter]
public EventCallback<ContentChangedEventArgs> ContentInserted { get; set; }
Event Data
The ContentInserted event's data class is ContentChangedEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Interval | Gets the sub-document‘s interval in which content was changed. |
SubDocument | Gets the sub-document in which content was changed. |
Remarks
The Rich Text Editor fires this event in the following cases:
- New content was added to the document.
- Content was moved inside the document.
- A non-empty field was updated.
The following code snippet demonstrates how you can obtain the inserted content and remove new images and text boxes from the document:
<DxRichEdit ContentInserted="OnContentInserted" />
@code {
async void OnContentInserted(ContentChangedEventArgs args) {
// Obtains the inserted content as a text span
TextSpan textSpan = await args.SubDocument.GetTextSpanAsync(args.Interval);
// Converts the inserted content to plain text
string text = textSpan.Text;
// Removes inserted images and text boxes
for (int i = text.Length - 1; i >= 0; i--) {
if (text[i] == '')
await args.SubDocument.RemoveAsync(args.Interval.Start + i, 1);
}
}
}
See Also