1 wysihtml5.commands.outdentList = {
2 exec: function(composer, command, value) {
3 var listEls = composer.selection.getSelectionParentsByTag('LI');
5 return this.tryToPullLiLevel(listEls, composer);
10 state: function(composer, command) {
14 tryToPullLiLevel: function(liNodes, composer) {
15 var listNode, outerListNode, outerLiNode, list, prevLi, liNode, afterList,
19 composer.selection.executeAndRestoreRangy(function() {
21 for (var i = liNodes.length; i--;) {
23 if (liNode.parentNode) {
24 listNode = liNode.parentNode;
26 if (listNode.tagName === 'OL' || listNode.tagName === 'UL') {
29 outerListNode = wysihtml5.dom.getParentElement(listNode.parentNode, { nodeName: ['OL', 'UL']}, false, composer.element);
30 outerLiNode = wysihtml5.dom.getParentElement(listNode.parentNode, { nodeName: ['LI']}, false, composer.element);
32 if (outerListNode && outerLiNode) {
34 if (liNode.nextSibling) {
35 afterList = that.getAfterList(listNode, liNode);
36 liNode.appendChild(afterList);
38 outerListNode.insertBefore(liNode, outerLiNode.nextSibling);
42 if (liNode.nextSibling) {
43 afterList = that.getAfterList(listNode, liNode);
44 liNode.appendChild(afterList);
47 for (var j = liNode.childNodes.length; j--;) {
48 listNode.parentNode.insertBefore(liNode.childNodes[j], listNode.nextSibling);
51 listNode.parentNode.insertBefore(document.createElement('br'), listNode.nextSibling);
52 liNode.parentNode.removeChild(liNode);
57 if (listNode.childNodes.length === 0) {
58 listNode.parentNode.removeChild(listNode);
68 getAfterList: function(listNode, liNode) {
69 var nodeName = listNode.nodeName,
70 newList = document.createElement(nodeName);
72 while (liNode.nextSibling) {
73 newList.appendChild(liNode.nextSibling);