Skip to main content

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.1.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

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.

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

@code {
    DxRichEdit richEdit;
    async Task InitializeDocument() {
        Document documentAPI = richEdit.DocumentAPI;
        documentAPI.BeginUpdate();
        await CreateTitleParagraph(documentAPI);
        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