+ 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;
+ },
+
+ triggerSelectionChanged: function() {
+ this.trigger('selectionChanged', this.getSelection());
+ var s = this.getSelection(),
+ f = s.toDocumentFragment();
+ if(f && f instanceof f.RangeFragment) {
+ var $current = this.wrapper.find('.current-node-element');
+ var current = $current && this.getDocumentElement($current.parent()[0]);
+
+ if($current) {
+ $current.removeClass('current-node-element');
+ }
+ if(current) {
+ current.markAsCurrent(false);
+ }
+ }
+ },