diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js index bfac56eb2c351..72008e298996d 100644 --- a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js @@ -71,6 +71,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed // Run the indent command. document.execCommand('indent', false, null); + // Fix indent list item. + this.fixupListItemsAfterIndent(); + // Get all blockquotes, both existing and new. blockquotes = this.editor.all('blockquote'); @@ -195,6 +198,28 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed indent.replace(clone); indent = editor.one('.editor-indent'); } + }, + /** + * Fixup for list item after indent. + * + * @method fixupListItemsAfterIndent + */ + fixupListItemsAfterIndent: function() { + var selection = window.rangy.getSelection(), + rootelement = this.editor.getDOMNode(), + listelement = selection.anchorNode.parentElement; + + listelement = listelement.closest('ol, ul'); + if (!(listelement && rootelement.contains(listelement))) { + return; + } + + // We will move the child list into previous list item of the parent. + var previous = listelement.previousElementSibling; + if (previous && previous.tagName === 'LI') { + previous.appendChild(listelement); + selection.collapseToEnd(); + } } }); diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js index 239e77ac77f5a..0e1f34cdf4daa 100644 --- a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_indent-button",function(r,e){r.namespace("M.atto_indent").Button=r.Base.create("button",r.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addButton({icon:"e/decrease_indent",title:"outdent",buttonName:"outdent",callback:this.outdent}),this.addButton({icon:"e/increase_indent",title:"indent",buttonName:"indent",callback:this.indent})},indent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),o=t.size();this.editor.all(".rangySelectionBoundary").setStyle("display",null),t.addClass("pre-existing"),document.execCommand("indent",!1,null),(t=this.editor.all("blockquote")).size()!==o?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0").setAttrs(t.getAttrs()).setStyle(o,"30px").addClass("editor-indent"),d=(n=t.getDOMNode().childNodes)[0];void 0!==d;)i.append(d),d=n[0];t.replace(i)}t=e.one("blockquote[data-iterate]")}},replaceEditorIndents:function(e){for(var t,o,i,n=e.one(".editor-indent");n;){for(t=r.Node.create("
").setAttrs(n.getAttrs()).removeClass("editor-indent"),i=(o=n.getDOMNode().childNodes)[0];void 0!==i;)t.append(i),i=o[0];n.replace(t),n=e.one(".editor-indent")}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); \ No newline at end of file +YUI.add("moodle-atto_indent-button",function(r,e){r.namespace("M.atto_indent").Button=r.Base.create("button",r.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addButton({icon:"e/decrease_indent",title:"outdent",buttonName:"outdent",callback:this.outdent}),this.addButton({icon:"e/increase_indent",title:"indent",buttonName:"indent",callback:this.indent})},indent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),i=t.size();this.editor.all(".rangySelectionBoundary").setStyle("display",null),t.addClass("pre-existing"),document.execCommand("indent",!1,null),this.fixupListItemsAfterIndent(),(t=this.editor.all("blockquote")).size()!==i?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0").setAttrs(t.getAttrs()).setStyle(i,"30px").addClass("editor-indent"),d=(n=t.getDOMNode().childNodes)[0];void 0!==d;)o.append(d),d=n[0];t.replace(o)}t=e.one("blockquote[data-iterate]")}},replaceEditorIndents:function(e){for(var t,i,o,n=e.one(".editor-indent");n;){for(t=r.Node.create("
").setAttrs(n.getAttrs()).removeClass("editor-indent"),o=(i=n.getDOMNode().childNodes)[0];void 0!==o;)t.append(o),o=i[0];n.replace(t),n=e.one(".editor-indent")}},fixupListItemsAfterIndent:function(){var e,t=window.rangy.getSelection(),i=this.editor.getDOMNode(),o=t.anchorNode.parentElement;(o=o.closest("ol, ul"))&&i.contains(o)&&(e=o.previousElementSibling)&&"LI"===e.tagName&&(e.appendChild(o),t.collapseToEnd())}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); \ No newline at end of file diff --git a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js index bfac56eb2c351..72008e298996d 100644 --- a/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js +++ b/lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js @@ -71,6 +71,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed // Run the indent command. document.execCommand('indent', false, null); + // Fix indent list item. + this.fixupListItemsAfterIndent(); + // Get all blockquotes, both existing and new. blockquotes = this.editor.all('blockquote'); @@ -195,6 +198,28 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed indent.replace(clone); indent = editor.one('.editor-indent'); } + }, + /** + * Fixup for list item after indent. + * + * @method fixupListItemsAfterIndent + */ + fixupListItemsAfterIndent: function() { + var selection = window.rangy.getSelection(), + rootelement = this.editor.getDOMNode(), + listelement = selection.anchorNode.parentElement; + + listelement = listelement.closest('ol, ul'); + if (!(listelement && rootelement.contains(listelement))) { + return; + } + + // We will move the child list into previous list item of the parent. + var previous = listelement.previousElementSibling; + if (previous && previous.tagName === 'LI') { + previous.appendChild(listelement); + selection.collapseToEnd(); + } } }); diff --git a/lib/editor/atto/plugins/indent/yui/src/button/js/button.js b/lib/editor/atto/plugins/indent/yui/src/button/js/button.js index bc37415828bdc..d309ff5f78ace 100644 --- a/lib/editor/atto/plugins/indent/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/indent/yui/src/button/js/button.js @@ -69,6 +69,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed // Run the indent command. document.execCommand('indent', false, null); + // Fix indent list item. + this.fixupListItemsAfterIndent(); + // Get all blockquotes, both existing and new. blockquotes = this.editor.all('blockquote'); @@ -193,5 +196,27 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed indent.replace(clone); indent = editor.one('.editor-indent'); } + }, + /** + * Fixup for list item after indent. + * + * @method fixupListItemsAfterIndent + */ + fixupListItemsAfterIndent: function() { + var selection = window.rangy.getSelection(), + rootelement = this.editor.getDOMNode(), + listelement = selection.anchorNode.parentElement; + + listelement = listelement.closest('ol, ul'); + if (!(listelement && rootelement.contains(listelement))) { + return; + } + + // We will move the child list into previous list item of the parent. + var previous = listelement.previousElementSibling; + if (previous && previous.tagName === 'LI') { + previous.appendChild(listelement); + selection.collapseToEnd(); + } } });