Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Paragraphs.CreateAsync(Int32, CancellationToken) Method

Inserts a paragraph mark at the specified position and creates a new paragraph.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public ValueTask<Paragraph> CreateAsync(
    int position,
    CancellationToken cancellationToken = default(CancellationToken)
)

#Parameters

Name Type Description
position Int32

The position where to insert the paragraph mark.

#Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

#Returns

Type Description
ValueTask<Paragraph>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is a paragraph object.

#Remarks

The paragraph mark (¶) indicates the end of the new paragraph.

Razor
<DxRichEdit @ref="richEdit" CssClass="w-100 ch-720"/>

@code {
    DxRichEdit richEdit;
    async Task InitializeDocument() {
        Document documentAPI = richEdit.DocumentAPI;
        documentAPI.BeginUpdate();
        documentAPI.BeginTransaction();
        await CreateTitleParagraph(documentAPI);
        await documentAPI.EndTransaction();
        documentAPI.EndUpdate();
    }
    async Task CreateTitleParagraph(Document documentAPI) {
        Paragraph titleParagraph = await documentAPI.Paragraphs.CreateAsync(0);
        await titleParagraph.ChangePropertiesAsync(properties => { properties.SpacingAfter = 400; });
        TextSpan titleParagraphTextSpan = await documentAPI.AddTextAsync(0, "Albert Einstein");
        await titleParagraphTextSpan.ChangePropertiesAsync(properties => {
            properties.FontName = "Arial";
            properties.FontSize = 24;
            properties.FontBold = true;
        });
    }
}

Run Demo: Document API

See Also