TINY BLOG > Important changes to Tiny Cloud pricing > Find out more

tinymce.dom.BookmarkManager

This class handles selection bookmarks.

Constructors

name summary defined by
BookmarkManager() Constructs a new BookmarkManager instance for a specific selection instance. tinymce.dom.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. tinymce.dom.BookmarkManager
isBookmarkNode() Returns true/false if the specified node is a bookmark node or not. tinymce.dom.BookmarkManager
moveToBookmark() Restores the selection to the specified bookmark. tinymce.dom.BookmarkManager

Constructors

BookmarkManager

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

Constructs a new BookmarkManager instance for a specific selection instance.

Parameters

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
var 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):Boolean

Restores the selection to the specified bookmark.

Examples
// Stores a bookmark of the current selection
var 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.
Return value
  • Boolean - true/false if it was successful or not.

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.