X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b54134dba23e4a09a31655ff6697eacb915659bb..232e5bd6f1b93f27e227a291b7913867e7d76be7:/src/smartxml/smartxml.js 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 = $('
'); wrapper.append(this._getXMLDOMToDump()); @@ -243,6 +263,11 @@ $.extend(TextNode.prototype, { return this.nativeNode.data; }, + + containsNode: function() { + return false; + }, + triggerTextChangeEvent: function() { var event = new events.ChangeEvent('nodeTextChange', {node: this}); this.document.trigger('change', event);