X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7bc06393365fdffe695cef6dd825edf4ce521919..5b89eff5afcb92f0e7b20daf62eae30aeb7b4e1c:/modules/documentCanvas/canvas/documentElement.js diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 0558a3e..b7e8352 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -101,6 +101,20 @@ $.extend(DocumentElement.prototype, { return toret; }, + 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])); + }, + isVisible: function() { return this instanceof DocumentTextElement || this.getWlxmlTag() !== 'metadata'; },