blazor-devexpress-dot-blazor-dot-richedit-dot-subdocument-dot-addtextasync-x28-system-dot-int32-system-dot-string-system-dot-threading-dot-cancellationtoken-x29.md
Inserts the text at the specified position.
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public ValueTask<TextSpan> AddTextAsync(
int position,
string text,
CancellationToken cancellationToken = default(CancellationToken)
)
| Name | Type | Description |
|---|---|---|
| position | Int32 |
The position in the sub-document where to insert the text.
| | text | String |
The text to insert.
|
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null |
An object that propagates a cancellation notification.
|
| Type | Description |
|---|---|
| ValueTask<TextSpan> |
A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the inserted text span.
|
Use the ChangePropertiesAsync(Action<CharacterProperties>, CancellationToken) method to specify character properties of the inserted text.
<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;
});
}
}
See Also