Skip to main content

Document.GetIsEmptyAsync(CancellationToken) Method

Returns whether the document is empty.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public ValueTask<bool> GetIsEmptyAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)

Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

Returns

Type Description
ValueTask<Boolean>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is a value that indicates whether the document is empty.

Remarks

A document is empty if it contains only an empty main sub-document. If a document contains an empty header, footer, or text box, the GetIsEmptyAsync method returns false.

The following code snippet creates a new document if an open document is not empty:

<DxRichEdit @ref="@richEdit" />

@code {
    DxRichEdit richEdit { get; set; }

    async void CreateNewDocument() {
        bool isEmpty = await richEdit.DocumentAPI.GetIsEmptyAsync();
        if (!isEmpty)
            await richEdit.NewDocumentAsync();
    }
}
See Also