X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/8c9d3b6afa002ad4db684dadcf8a50ca27f8701d..5b89eff5afcb92f0e7b20daf62eae30aeb7b4e1c:/modules/documentCanvas/canvas/documentElement.js diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 7dd1f7d..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'; }, @@ -148,8 +162,10 @@ $.extend(DocumentNodeElement, { } element.data('other-attrs', params.others); - if(params.rawChildren) { + if(params.rawChildren && params.rawChildren.length) { container.append(params.rawChildren); + } else if(params.prepopulateOnEmpty) { + element.append(DocumentTextElement.create({text: ''})); } return dom; },