+ },
+ list: {}
+});
+
+$.extend(Canvas.prototype.list, {
+ create: function(params) {
+ if(!(params.element1.parent().sameNode(params.element2.parent())))
+ return false;
+
+ var parent = params.element1.parent();
+
+ if(parent.childIndex(params.element1) > parent.childIndex(params.element2)) {
+ var tmp = params.element1;
+ params.element1 = params.element2;
+ params.element2 = tmp;
+ }
+
+ var elementsToWrap = [];
+
+ var place = 'before';
+ var canvas = this;
+ parent.children().forEach(function(element) {
+ if(element.sameNode(params.element1))
+ place = 'inside';
+ if(place === 'inside') {
+ if(element instanceof documentElement.DocumentTextElement) {
+ element = element.wrapWithNodeElement({tag: 'div', klass: 'list.item'});
+ if(element.children()[0].sameNode(params.element1))
+ params.element1 = element;
+ }
+ element.setWlxmlClass('item');
+ elementsToWrap.push(element);
+ }
+ if(element.sameNode(params.element2))
+ return false;
+ });
+
+ var listElement = documentElement.DocumentNodeElement.create({tag: 'div', klass: 'list-items' + (params.type === 'enum' ? '-enum' : '')});
+
+ var toret;
+ if(parent.is('list')) {
+ listElement.wrap({tag: 'div', klass: 'item'});
+ toret = listElement.parent();
+ } else {
+ toret = listElement;
+ }
+
+ params.element1.before(toret);
+
+ elementsToWrap.forEach(function(element) {
+ element.detach();
+ listElement.append(element);
+ });
+ },
+ extractItems: function(params) {
+ var list = params.element1.parent();
+ if(!list.is('list') || !(list.sameNode(params.element2.parent())))
+ return false;
+
+ var idx1 = list.childIndex(params.element1),
+ idx2 = list.childIndex(params.element2),
+ precedingItems = [],
+ extractedItems = [],
+ succeedingItems = [],
+ items = list.children(),
+ listIsNested = list.parent().getWlxmlClass() === 'item',
+ i;
+
+ if(idx1 > idx2) {
+ var tmp = idx1; idx1 = idx2; idx2 = tmp;
+ }