SubDocument.AddTextAsync(Int32, String, CancellationToken) Method
Inserts the text at the specified position.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v23.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public ValueTask<TextSpan> AddTextAsync(
int position,
string text,
CancellationToken cancellationToken = default(CancellationToken)
)
Parameters
Name | Type | Description |
---|---|---|
position | Int32 | The position in the sub-document where to insert the text. |
text | String | The text to insert. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellationToken | CancellationToken | null | An object that propagates a cancellation notification. |
Returns
Type | Description |
---|---|
ValueTask<TextSpan> | A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the inserted text span. |
Remarks
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;
@* ... *@
Document documentAPI = richEdit.DocumentAPI;
@* ... *@
string bodyParagraphText = "Albert Einstein (14 March 1879 - 18 April 1955) was a German-born theoretical physicist, widely acknowledged to be one of the greatest physicists of all time. Einstein is known for developing the theory of relativity, but he also made important contributions to the development of the theory of quantum mechanics.";
TextSpan bodyParagraphTextSpan = await documentAPI.AddTextAsync(0, bodyParagraphText);
await bodyParagraphTextSpan.ChangePropertiesAsync(properties => {
properties.FontName = "Segoe UI";
properties.FontSize = 12;
});
@* ... *@
}
See Also