Back to Devexpress

Paragraphs.CreateAsync(Int32, CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-paragraphs-dot-createasync-x28-system-dot-int32-system-dot-threading-dot-cancellationtoken-x29.md

latest2.6 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

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

Parameters

NameTypeDescription
positionInt32

The position where to insert the paragraph mark.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
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

Paragraphs Class

Paragraphs Members

DevExpress.Blazor.RichEdit Namespace