tinymce.dom.BookmarkManager

This class handles selection bookmarks.

Summary

Constructors

Name Summary Defined by

BookmarkManager()

Constructs a new BookmarkManager instance for a specific selection instance.

BookmarkManager

Methods

Name Summary Defined by

getBookmark()

Returns a bookmark location for the current selection. This bookmark object can then be used to restore the selection after some content modification to the document.

BookmarkManager

isBookmarkNode()

Returns true/false if the specified node is a bookmark node or not.

BookmarkManager

moveToBookmark()

Restores the selection to the specified bookmark.

BookmarkManager

Constructors

BookmarkManager

public constructor function BookmarkManager(selection: tinymce.dom.Selection)

Constructs a new BookmarkManager instance for a specific selection instance.

Parameters

  • selection (Selection) - Selection instance to handle bookmarks for.

Methods

getBookmark()

getBookmark(type: Number, normalized: Boolean): Object

Returns a bookmark location for the current selection. This bookmark object can then be used to restore the selection after some content modification to the document.

Examples

// Stores a bookmark of the current selection
const bm = tinymce.activeEditor.selection.getBookmark();

tinymce.activeEditor.setContent(tinymce.activeEditor.getContent() + 'Some new content');

// Restore the selection bookmark
tinymce.activeEditor.selection.moveToBookmark(bm);

Parameters

  • type (Number) - Optional state if the bookmark should be simple or not. Default is complex.

  • normalized (Boolean) - Optional state that enables you to get a position that it would be after normalization.

Return value

  • Object - Bookmark object, use moveToBookmark with this object to restore the selection.


isBookmarkNode()

isBookmarkNode(node: DOMNode): Boolean

Returns true/false if the specified node is a bookmark node or not.

Parameters

  • node (DOMNode) - DOM Node to check if it’s a bookmark node or not.

Return value

  • Boolean - true/false if the node is a bookmark node or not.


moveToBookmark()

moveToBookmark(bookmark: Object)

Restores the selection to the specified bookmark.

Examples

// Stores a bookmark of the current selection
const bm = tinymce.activeEditor.selection.getBookmark();

tinymce.activeEditor.setContent(tinymce.activeEditor.getContent() + 'Some new content');

// Restore the selection bookmark
tinymce.activeEditor.selection.moveToBookmark(bm);

Parameters

  • bookmark (Object) - Bookmark to restore selection from.