+Canvas.prototype.nodeInsertAfter = function(options) {\r
+ var element = $(this.content.find('#' + options.after.getId()).get(0));\r
+ element.after(options.node.dom);\r
+};\r
+\r
+Canvas.prototype.nodeWrap = function(options) {\r
+ options = _.extend({textNodeIdx: 0}, options);\r
+ if(typeof options.textNodeIdx === 'number')\r
+ options.textNodeIdx = [options.textNodeIdx];\r
+ \r
+ var container = $(this.content.find('#' + options.inside.getId()).get(0)),\r
+ containerContent = container.contents(),\r
+ idx1 = Math.min.apply(Math, options.textNodeIdx),\r
+ idx2 = Math.max.apply(Math, options.textNodeIdx),\r
+ textNode1 = $(containerContent.get(idx1)),\r
+ textNode2 = $(containerContent.get(idx2)),\r
+ sameNode = textNode1.get(0) === textNode2.get(0),\r
+ prefixOutside = textNode1.text().substr(0, options.offsetStart),\r
+ prefixInside = textNode1.text().substr(options.offsetStart),\r
+ suffixInside = textNode2.text().substr(0, options.offsetEnd),\r
+ suffixOutside = textNode2.text().substr(options.offsetEnd)\r
+ ;\r
+ \r
+ textNode1.after(options._with.dom);\r
+ textNode1.detach();\r
+ \r
+ options._with.dom.before(prefixOutside);\r
+ if(sameNode) {\r
+ var core = textNode1.text().substr(options.offsetStart, options.offsetEnd - options.offsetStart);\r
+ options._with.setContent(core);\r
+ } else {\r
+ textNode2.detach();\r
+ options._with.dom.append(prefixInside);\r
+ for(var i = idx1 + 1; i < idx2; i++) {\r
+ options._with.dom.append(containerContent[i]);\r
+ }\r
+ options._with.dom.append(suffixInside);\r
+ }\r
+ options._with.dom.after(suffixOutside);\r
+};\r
+\r
+Canvas.prototype.nodeSplit = function(options) {\r
+ options = _.extend({textNodeIdx: 0}, options);\r
+ \r
+ var nodeToSplit = $(this.content.find('#' + options.node.getId()).get(0));\r