+ 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 && element.dom && 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) {
+ if(this.currentNodeElement) {
+ this.currentNodeElement.updateState({active: false});
+ this.currentNodeElement = null;
+ }
+ }
+ },
+
+ getSelection: function() {
+ return new Selection(this);
+ },
+
+ select: function(fragment) {
+ if(fragment instanceof this.wlxmlDocument.RangeFragment) {
+ this.setCurrentElement(fragment.endNode, {caretTo: fragment.endOffset});
+ } else if(fragment instanceof this.wlxmlDocument.NodeFragment) {
+ var params = {
+ caretTo: fragment instanceof this.wlxmlDocument.CaretFragment ? fragment.offset : 'start'
+ };
+ this.setCurrentElement(fragment.node, params);
+ } else {
+ logger.debug('Fragment not supported');
+ }
+ },