Skip to main content

Document.ChangeDefaultCharacterPropertiesAsync(Action<CharacterProperties>, CancellationToken) Method

Sets the default character formatting in the document.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public ValueTask ChangeDefaultCharacterPropertiesAsync(
    Action<CharacterProperties> modifier,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

Name Type Description
modifier Action<CharacterProperties>

A delegate method that configures default values of the character properties.

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 example below demonstrates how to change 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.

See Also