blazor-devexpress-dot-blazor-dot-richedit-0bbfec5e.md
A bookmark in a document.
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public class Bookmark :
DocumentElementBase,
IIndexBasedTransactionalObject,
ITransactableObject
A bookmark is an anchor in a document. Users can navigate to this anchor when they click a corresponding hyperlink.
Call a Bookmarks.CreateAsync method to add a bookmark to a sub-document.
<DxRichEdit @ref="@richEdit" />
@code {
DxRichEdit richEdit { get; set; }
@* ... *@
/* Surround the code that contains an asynchronous operation with a try-catch block to handle
the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
try {
@* ... *@
// Create a bookmark
var bookmarkTextSpan = await richEdit.DocumentAPI.AddTextAsync("Chapter 1");
var bookmarkChapter1 = await richEdit.DocumentAPI.Bookmarks.CreateAsync(bookmarkTextSpan.Interval, "chapter1Bookmark");
@* ... *@
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
Call a Hyperlinks.CreateAsync method to create a hyperlink that navigates to the bookmark.
// Create a hyperlink to the bookmark
var hlChapter1Span = await richEdit.DocumentAPI.AddTextAsync("To learn more, see the Chapter 1");
await richEdit.DocumentAPI.Hyperlinks.CreateAsync(hlChapter1Span.Interval, "", bookmarkChapter1.Name, "Go to Chapter 1");
Use the following methods to find a bookmark:
GetAsync(String, CancellationToken) - finds a bookmark by name
GetAsync(Int32, CancellationToken) - finds a bookmark by index in the collection
GetAllAsync(CancellationToken) - gets the collection of the bookmarks
Use the following methods to remove a bookmark:
RemoveAsync(Bookmark, CancellationToken) - removes the specified bookmark.
RemoveAsync(Int32, CancellationToken) - removes a bookmark with the specified index.
RemoveAsync(String, CancellationToken) - removes a bookmark with the specified name.
The Rich Text Editor invokes this dialog when a user selects the Insert → Bookmark ribbon command or Bookmark context menu command. The Bookmark dialog allows users to create and delete bookmarks and navigate through them.
Object DevExpress.Blazor.RichEdit.Internal.DocumentObject DocumentElementBase Bookmark
See Also