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:


let offset = this.app.create('offset');
let obj = toffset.get();
console.log(obj.start, obj.end);

The element selection offset:


let offset = this.app.create('offset');
let obj = offset.get(element);
console.log(obj.start, obj.end);

set #

Arguments
element Node, Element, Dom, Boolean
value Object

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

Set the editor offset:


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

Set the element offset:


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