return false;\r
});\r
\r
- var list = canvasNode.create({tag: 'div', klass: 'list-items'}).dom; //this._createNode('div', 'list-items');\r
- element1.before(list);\r
+ var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items');\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
Canvas.prototype.listRemove = function(options) {\r
var pointerElement = $(this.content.find('#' + options.pointer.getId()));\r
var listElement = options.pointer.getClass() === 'list-items' ? pointerElement : \r
- pointerElement.parent('[wlxml-class="list-items"][wlxml-tag]');\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
\r
Canvas.prototype.nodeInsideList = function(options) {\r
if(options.node) {\r
- if(options.node.getClass() === 'list-items' || options.node.getClass() === 'item')\r
+ if(options.node.isOfClass('list-items') || options.node.isOfClass('item'))\r
return true;\r
var pointerElement = $(this.content.find('#' + options.node.getId()));\r
return pointerElement.parents('[wlxml-class=list-items], [wlxml-class=item]').length > 0;\r