X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e0aad96df245c7148966887cbcc77417a4b7675b..804d77fa4cea068e90b6461f1a5f151fe6f67fbc:/src/editor/modules/documentCanvas/canvas/canvas.js?ds=sidebyside diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 0ec22a1..a43799c 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -233,7 +233,7 @@ $.extend(Canvas.prototype, Backbone.Events, { this.eventBus.on('elementToggled', function(toggle, element) { if(!toggle) { - canvas.setCurrentElement(element.getPreviousTextElement()); + canvas.setCurrentElement(canvas.getPreviousTextElement(element)); } }); }, @@ -270,6 +270,20 @@ $.extend(Canvas.prototype, Backbone.Events, { } }, + 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; },