Skip to main content

Document Class

A document in the Rich Text Editor.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public class Document :
    SubDocument

The following members return Document objects:

Remarks

The Document class combines the document’s common and the main sub-document‘s functionalities.

How to Process a Batch of Changes in the Document without Intermediate Updates

Enclose your code in the BeginUpdate(Boolean) - EndUpdate() method calls to suppress the RichEdit’s visual updates and improve its performance when you make multiple changes to a document.

Each call to BeginUpdate(Boolean) should be paired with the EndUpdate() call. The BeginUpdate(Boolean) method locks the component to prevent it from re-rendering after each modification. The EndUpdate() method unlocks the control to apply all changes.

<DxRichEdit @ref="richEdit" />
@code {
    DxRichEdit richEdit;
    protected override Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender)
            InitializeDocument();
        return base.OnAfterRenderAsync(firstRender);
    }

    async void InitializeDocument() {
    /* Surround the code that contains an asynchronous operation with a try-catch block to handle
    the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
        try {
            richEdit.DocumentAPI.BeginUpdate();
            IReadOnlyList<Paragraph> paragraphs = await richEdit.DocumentAPI.Paragraphs.GetAllAsync();
            foreach (Paragraph p in paragraphs)
                await p.ChangePropertiesAsync(properties => {/*...*/});
            richEdit.DocumentAPI.EndUpdate();
            }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}

Structural Elements

A Document object provides access to structural elements contained in the main sub-document. Use the following properties to access a specific element’s collection:

Use the Lists property to access a collection of the document’s List objects.

Implements

DevExpress.Utils.IBatchUpdateHandler

Inheritance

See Also