this.eventBus.on('elementToggled', function(toggle, element) {
if(!toggle) {
- canvas.setCurrentElement(element.getPreviousTextElement());
+ canvas.setCurrentElement(canvas.getPreviousTextElement(element));
}
});
},
}
},
+ getPreviousTextElement: function(relativeToElement, includeInvisible) {
+ return this.getNearestTextElement('above', relativeToElement, includeInvisible);
+ },
+
+ getNextTextElement: function(relativeToElement, includeInvisible) {
+ return this.getNearestTextElement('below', relativeToElement, includeInvisible);
+ },
+
+ getNearestTextElement: function(direction, relativeToElement, includeInvisible) {
+ includeInvisible = includeInvisible !== undefined ? includeInvisible : false;
+ var selector = '[document-text-element]' + (includeInvisible ? '' : ':visible');
+ return this.getDocumentElement(utils.nearestInDocumentOrder(selector, direction, relativeToElement.dom()[0]));
+ },
+
contains: function(element) {
return element.dom().parents().index(this.wrapper) !== -1;
},
return other && (typeof other === typeof this) && other.dom()[0] === this.dom()[0];
},
- getPreviousTextElement: function(includeInvisible) {
- return this.getNearestTextElement('above', includeInvisible);
- },
-
- getNextTextElement: function(includeInvisible) {
- return this.getNearestTextElement('below', includeInvisible);
- },
-
- getNearestTextElement: function(direction, includeInvisible) {
- includeInvisible = includeInvisible !== undefined ? includeInvisible : false;
- var selector = '[document-text-element]' + (includeInvisible ? '' : ':visible');
- return this.canvas.getDocumentElement(utils.nearestInDocumentOrder(selector, direction, this.dom()[0]));
- },
-
trigger: function() {
//this.canvas.bus.trigger()
}
if(direction === 'above') {
if(start.offsetAtBeginning) {
- goto = start.element.getNearestTextElement('above');
+ goto = canvas.getNearestTextElement('above', start.element);
caretTo = 'end';
} else {
goto = start.element;
}
} else {
if(end.offsetAtEnd) {
- goto = start.element.getNearestTextElement('below');
+ goto = canvas.getNearestTextElement('below', start.element);
caretTo = 'start';
} else {
goto = end.element;
if(grandParent && grandParent.children().length === 1) {
goto = grandParent.wlxmlNode.append({text: ''});
} else {
- goto = element.getNearestTextElement(direction);
+ goto = canvas.getNearestTextElement(direction, element);
}
parent.wlxmlNode.detach();
} else {
- goto = element.getNearestTextElement(direction);
+ goto = canvas.getNearestTextElement(direction, element);
element.wlxmlNode.detach();
}
canvas.setCurrentElement(goto, {caretTo: caretTo});
}
else if(cursorAtOperationEdge) {
if(direction === 'below') {
- element = element.getNearestTextElement(direction);
+ element = canvas.getNearestTextElement(direction, element);
}
if(element) {
goto = element.wlxmlNode.mergeContentUp();