Back to Devexpress

Bookmark Class

blazor-devexpress-dot-blazor-dot-richedit-0bbfec5e.md

latest4.0 KB
Original Source

Bookmark Class

A bookmark in a document.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public class Bookmark :
    DocumentElementBase,
    IIndexBasedTransactionalObject,
    ITransactableObject

Remarks

A bookmark is an anchor in a document. Users can navigate to this anchor when they click a corresponding hyperlink.

Create a Bookmark

Call a Bookmarks.CreateAsync method to add a bookmark to a sub-document.

razor
<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.

csharp
// 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");

Find a Bookmark

Use the following methods to find a bookmark:

Remove a Bookmark

Use the following methods to remove a bookmark:

The Bookmark Dialog

The Rich Text Editor invokes this dialog when a user selects the InsertBookmark ribbon command or Bookmark context menu command. The Bookmark dialog allows users to create and delete bookmarks and navigate through them.

Inheritance

Object DevExpress.Blazor.RichEdit.Internal.DocumentObject DocumentElementBase Bookmark

See Also

Bookmark Members

DevExpress.Blazor.RichEdit Namespace