get #

Arguments:

  • el (optional) Node Element Dom

Returns: Object Boolean

Return the object with the selection offset (start and end). Return false if the focus is not in editor or is not in the specified element.

// editor selection offset
var offset = this.offset.get();
console.log(offset.start, offset.end);

// element selection offset
var offset = this.offset.get(element);

set #

Arguments
offset Object
el (optional) Node Element Dom

Set the selection in the editor or in the element by the specified object.

// set editor offset
this.offset.set({ start: 1, end: 10 });

// set element offset
this.offset.set({ start: 1, end: 10 }. element);

size #

Arguments
el (optional) Node Element Dom

Return the size/length of the element or the editor.

// editor size
var size = this.offset.size();

// element size
var size = this.offset.size(element);