- var prefix = textElement.data.substr(0, options.offset);\r
- var suffix = textElement.data.substr(options.offset);\r
- var prefixNode = this._createNode(element.attr('wlxml-tag'), element.attr('wlxml-class'));\r
- var suffixNode = this._createNode(element.attr('wlxml-tag'), element.attr('wlxml-class'));\r
- prefixNode.text(prefix);\r
- suffixNode.text(suffix);\r
- element.before(prefixNode);\r
- element.after(suffixNode);\r
- element.remove();\r
+ var textNode = $(nodeContents.get(options.textNodeIdx));\r
+\r
+ var succeedingNodes = [];\r
+ var passed = false;\r
+ nodeContents.each(function() {\r
+ var node = this;\r
+ if(passed)\r
+ succeedingNodes.push(node);\r
+ if(node.isSameNode(textNode.get(0)))\r
+ passed = true;\r
+ });\r
+ \r
+ var prefix = textNode.text().substr(0, options.offset);\r
+ var suffix = textNode.text().substr(options.offset);\r
+ \r
+ textNode.before(prefix);\r
+ textNode.remove();\r
+ \r
+ var newNode = this._createNode(nodeToSplit.attr('wlxml-tag'), nodeToSplit.attr('wlxml-class'));\r
+ newNode.append(suffix);\r
+ succeedingNodes.forEach(function(node) {\r
+ newNode.append(node)\r
+ });\r
+ nodeToSplit.after(newNode);\r
+ return newNode;\r