+ },
+ getDocumentElement: function(from) {
+ if(from instanceof HTMLElement || from instanceof Text) {
+ return documentElement.wrap(from, this);
+ }
+ },
+ 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().some(function(element) {
+ var _e = 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(_e.sameNode(params.element2))
+ return true;
+ });
+
+ var listElement = documentElement.DocumentNodeElement.create({tag: 'div', klass: 'list-items' + (params.type === 'enum' ? '-enum' : '')});
+
+ var toret;
+ if(parent.is('list')) {
+ listElement.wrapWithNodeElement({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) {
+ params = _.extend({merge: true}, 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;