Bookmarks in Blazor DocumentEditor Component
2 Aug 20231 minute to read
Bookmark is a powerful tool that helps you to mark a place in the document to find again easily. You can enter many bookmarks in the document and give each one a unique name to identify easily.
Blazor Word Processor
component (a.k.a Document Editor) component provides built-in dialog and using code to add, delete, and navigate bookmarks within the document. To add a bookmark, select a portion of text in the document. After that, jump to the location or add links to it within the document using built-in hyperlink dialog. You can also delete bookmarks from a document.
NOTE
Bookmark names need to begin with a letter. They can include both numbers and letters, but not spaces. To separate the words, use an underscore. Bookmark names starting with an underscore are called hidden bookmarks. For example, bookmarks generated for table of contents.
You can open the bookmark dialog using Bookmark options in toolbar. You can also explore our Blazor Word Processor - Bookmark
example to know more about bookmark.
Add bookmark
Using InsertBookmarkAsync
method, Bookmark can be added to the selected text.
await container.DocumentEditor.Editor.InsertBookmarkAsync("Bookmark1");
Select Bookmark
You can select the bookmark in the document using SelectBookmarkAsync
method by providing Bookmark name to select as shown in the following code snippet.
await container.DocumentEditor.Selection.SelectBookmarkAsync("Bookmark1");
Delete Bookmark
You can delete bookmark in the document using DeleteBookmarkAsync
method as shown in the following code snippet.
await container.DocumentEditor.Editor.DeleteBookmarkAsync("Bookmark1");
Get Bookmark
You can get all the bookmarks in the document using GetBookmarksAsync
method as shown in the following code snippet.
await container.DocumentEditor.Selection.GetBookmarksAsync(false);
NOTE
Parameter denotes is include hidden bookmarks. If false, ignore hidden bookmark.