getSelectionAnchor: function() {
return this.getSelectionBoundry('anchor');
},
+ getSelectionFocus: function() {
+ return this.getSelectionBoundry('focus');
+ },
getSelectionBoundry: function(which) {
var selection = window.getSelection(),
anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
offsetAtEnd: anchorElement && anchorElement.getText().length === selection.anchorOffset
};
}
+ if(which === 'focus') {
+ return {
+ element: focusElement,
+ offset: selection.focusOffset,
+ offsetAtBeginning: selection.focusOffset === 0,
+ offsetAtEnd: focusElement && focusElement.getText().length === selection.focusOffset
+ };
+ }
var element,
offset;
parent2 = selectionEnd.element.parent() || undefined;
if(params.toggle) {
+ var selectionFocus = cursor.getSelectionFocus();
canvas.list.create({element1: parent1, element2: parent2});
+ canvas.setCurrentElement(selectionFocus.element, {caretTo: selectionFocus.offset});
} else {
if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
canvas.list.extractItems({element1: parent1, element2: parent2, merge: false});