X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b54134dba23e4a09a31655ff6697eacb915659bb..bb204203f5f64dd13b256263fd398e1463d4eaf9:/src/smartxml/smartxml.js?ds=inline diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 08897cc..3ee49b7 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -79,6 +79,10 @@ $.extend(DocumentNode.prototype, { return this.document.root.sameNode(this); }, + isInDocument: function() { + return this.document.containsNode(this); + }, + isSiblingOf: function(node) { return node && this.parent().sameNode(node.parent()); }, @@ -219,6 +223,22 @@ $.extend(ElementNode.prototype, { return node && (node.nativeNode === this.nativeNode || node._$.parents().index(this._$) !== -1); }, + getLastTextNode: function() { + var contents = this.contents(), + toret; + + contents.reverse().some(function(node) { + if(node.nodeType === Node.TEXT_NODE) { + toret = node; + return true; + } + toret = node.getLastTextNode(); + return !!toret; + }); + + return toret; + }, + toXML: function() { var wrapper = $('