Documentation

Offset

get #

Arguments
element (optional) Node, Element, Dom

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

The editor selection offset:

var offset = this.app.create('offset');
var value = this.offset.get();
console.log(value.start, value.end);

The element selection offset:

var offset = this.app.create('offset');
var value = offset.get(element);

set #

Arguments
value Object
element (optional) Node, Element, Dom

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

Set the editor offset:

var offset = this.app.create('offset');
offset.set({ start: 1, end: 10 });

Set the element offset:

var offset = this.app.create('offset');
offset.set({ start: 1, end: 10 }. element);