X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/fa6ee2c363cdfdebcb4b76e4d9c4347a4cb19065..refs/tags/wordpress-4.2:/wp-includes/js/tinymce/plugins/lists/plugin.js diff --git a/wp-includes/js/tinymce/plugins/lists/plugin.js b/wp-includes/js/tinymce/plugins/lists/plugin.js index 036ba67d..a13c8ec5 100644 --- a/wp-includes/js/tinymce/plugins/lists/plugin.js +++ b/wp-includes/js/tinymce/plugins/lists/plugin.js @@ -207,16 +207,30 @@ tinymce.PluginManager.add('lists', function(editor) { } function splitList(ul, li, newBlock) { - var tmpRng, fragment; + var tmpRng, fragment, bookmarks, node; - var bookmarks = dom.select('span[data-mce-type="bookmark"]', ul); + function removeAndKeepBookmarks(targetNode) { + tinymce.each(bookmarks, function(node) { + targetNode.parentNode.insertBefore(node, li.parentNode); + }); + dom.remove(targetNode); + } + + bookmarks = dom.select('span[data-mce-type="bookmark"]', ul); newBlock = newBlock || createNewTextBlock(li); tmpRng = dom.createRng(); tmpRng.setStartAfter(li); tmpRng.setEndAfter(ul); fragment = tmpRng.extractContents(); + for (node = fragment.firstChild; node; node = node.firstChild) { + if (node.nodeName == 'LI' && dom.isEmpty(node)) { + dom.remove(node); + break; + } + } + if (!dom.isEmpty(fragment)) { dom.insertAfter(fragment, ul); } @@ -224,14 +238,14 @@ tinymce.PluginManager.add('lists', function(editor) { dom.insertAfter(newBlock, ul); if (dom.isEmpty(li.parentNode)) { - tinymce.each(bookmarks, function(node) { - li.parentNode.parentNode.insertBefore(node, li.parentNode); - }); - - dom.remove(li.parentNode); + removeAndKeepBookmarks(li.parentNode); } dom.remove(li); + + if (dom.isEmpty(ul)) { + dom.remove(ul); + } } function mergeWithAdjacentLists(listBlock) { @@ -709,14 +723,22 @@ tinymce.PluginManager.add('lists', function(editor) { } }; - editor.addCommand('Indent', function() { - if (!indentSelection()) { - return true; + editor.on('BeforeExecCommand', function(e) { + var cmd = e.command.toLowerCase(), isHandled; + + if (cmd == "indent") { + if (indentSelection()) { + isHandled = true; + } + } else if (cmd == "outdent") { + if (outdentSelection()) { + isHandled = true; + } } - }); - editor.addCommand('Outdent', function() { - if (!outdentSelection()) { + if (isHandled) { + editor.fire('ExecCommand', {command: e.command}); + e.preventDefault(); return true; } });