var node = this;\r
if(passed)\r
succeedingNodes.push(node);\r
- if(node.isSameNode(textNode.get(0)))\r
+ if(node === textNode.get(0))\r
passed = true;\r
});\r
\r
Canvas.prototype.listCreate = function(options) {\r
var element1 = $(this.content.find('#' + options.start.getId()).get(0));\r
var element2 = $(this.content.find('#' + options.end.getId()).get(0));\r
- if(!element1.parent().get(0).isSameNode(element2.parent().get(0)))\r
+ if(!element1.parent().get(0) === element2.parent().get(0))\r
return false;\r
\r
var parent = element1.parent();\r
var canvas = this;\r
parent.contents().each(function() {\r
var node = this;\r
- if(node.isSameNode(element1.get(0)))\r
+ if(node === element1.get(0))\r
place = 'inside';\r
if(place === 'inside') {\r
var $node;\r
$node.attr('wlxml-class', 'item');\r
nodesToWrap.push($node);\r
}\r
- if(node.isSameNode(element2.get(0)))\r
+ if(node === element2.get(0))\r
return false;\r
});\r
\r
var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items');\r
- element1.before(list);\r
+ \r
+ var parentNode = options.start.parent();\r
+ \r
+ var toret;\r
+ if(parentNode && parentNode.isOfClass('list-items')) {\r
+ list.wrap('<div wlxml-tag="div" wlxml-class="item">');\r
+ toret = list.parent();\r
+ } else {\r
+ toret = list;\r
+ }\r
+ \r
+ \r
+ element1.before(toret);\r
\r
nodesToWrap.forEach(function(node) {\r
node.remove();\r
var listElement = options.pointer.getClass() === 'list-items' ? pointerElement : \r
pointerElement.parents('[wlxml-class|="list-items"][wlxml-tag]');\r
\r
- listElement.find('[wlxml-class=item]').each(function() {\r
- $(this).removeAttr('wlxml-class');\r
- });\r
+ var nested = false;\r
+ if(listElement.length > 1) {\r
+ listElement = $(listElement[0]);\r
+ nested = true;\r
+ }\r
+ \r
+ if(nested) {\r
+ listElement.unwrap();\r
+ } else {\r
+ listElement.find('[wlxml-class=item]').each(function() {\r
+ $(this).removeAttr('wlxml-class');\r
+ });\r
+ }\r
listElement.children().unwrap();\r
};\r
\r