Editor.Selection
Description
The selection object provides a way to access the editor's selection, range and cursor.
Use a scope variable for Commands
When writing code for commands and you need information about the selection, then you can use the
xmlSelection scope variable instead of the Editor.Selection object. The scope variable will return the same object as Editor.SelectionThe difference is that when the scope variable is used your command code will be automatically executed each time the selection changes.
scope.get("xmlSelection")
An example with Editor.Selection
function makeStrong() {
var doc = Editor.getActiveDocument();
var selection = Editor.Selection;
if (!selection.isCollapsed()) {
selection.getRange().surroundContents(doc.createElement('strong'));
} else {
alert('You need to select content in order to make it bold.');
}
}