SubDocument.ClearFormattingAsync(Interval, CancellationToken) Method
Resets character formatting in the sub-document’s interval to the default settings.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public ValueTask ClearFormattingAsync(
Interval interval,
CancellationToken cancellationToken = default(CancellationToken)
)
Parameters
Name | Type | Description |
---|---|---|
interval | Interval | An interval in the sub-document. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellationToken | CancellationToken | null | An object that propagates a cancellation notification. |
Returns
Type | Description |
---|---|
ValueTask | A structure that stores an awaitable result of an asynchronous operation. |
Remarks
Call the ChangeDefaultCharacterPropertiesAsync method to change an open document’s default character formatting. Refer to the following link for a list of all available format settings: CharacterProperties.
The following code snippet changes default font name and size of a document’s text once the document is loaded in the Rich Text Editor:
<DxRichEdit DocumentLoaded=OnDocumentLoaded/>
@code {
async Task OnDocumentLoaded(Document document) {
await document.ChangeDefaultCharacterPropertiesAsync(properties => {
properties.FontName = "Times New Roman";
properties.FontSize = 12;
});
}
}
The Rich Text Editor applies the default character formatting to a text interval in the following cases:
You call a ClearFormattingAsync method overload:
<DxRichEdit @ref="richEdit" @bind-Selection=@selection/> @code { DxRichEdit richEdit; Selection selection; async Task ResetCharacterProperties() { // Resets character formatting in the main sub-document await richEdit.DocumentAPI.ClearFormattingAsync(); // Resets character formatting in the selected intervals foreach(Interval interval in selection.Intervals) { await selection.ActiveSubDocument.ClearFormattingAsync(interval); } } }
A user selects the Clear Formatting ribbon command.
A user presses Ctrl + Space Bar.
To customize character properties of a text span, call its ChangePropertiesAsync method.