smartxml: DocumentNode.getIndex function for syntactic sugar
[fnpeditor.git] / src / smartxml / smartxml.js
index 7e0d9b3..b4036d3 100644 (file)
@@ -78,6 +78,10 @@ $.extend(DocumentNode.prototype, {
           insertion.insertsNew = true;
         }
         return insertion;
+    },
+
+    getIndex: function() {
+        return this.parent().indexOf(this);
     }
 });
 
@@ -275,7 +279,7 @@ $.extend(TextNode.prototype, {
                 textNodeIdx: this.parent().indexOf(this),
                 offsetStart: Math.min(desc.start, desc.end),
                 offsetEnd: Math.max(desc.start, desc.end),
-                _with: {tag: desc.tagName, attrs: desc.attrs}
+                _with: {tagName: desc.tagName, attrs: desc.attrs}
             });
         } else {
             return DocumentNode.prototype.wrapWith.call(this, desc);
@@ -396,7 +400,7 @@ $.extend(Document.prototype, Backbone.Events, {
             throw new Error('Wrapping text in non-sibling text nodes not supported.');
         }
         
-        var wrapperElement = this.createElementNode({tagName: params._with.tag, attrs: params._with.attrs});
+        var wrapperElement = this.createElementNode({tagName: params._with.tagName, attrs: params._with.attrs});
         textNode1.after(wrapperElement);
         textNode1.detach();