mirror of
https://github.com/moodle/moodle.git
synced 2025-08-02 07:39:54 +02:00
Merge branch 'MDL-68639-master' of https://github.com/xcaro/moodle
This commit is contained in:
commit
517fe298c3
4 changed files with 76 additions and 1 deletions
|
@ -71,6 +71,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed
|
||||||
// Run the indent command.
|
// Run the indent command.
|
||||||
document.execCommand('indent', false, null);
|
document.execCommand('indent', false, null);
|
||||||
|
|
||||||
|
// Fix indent list item.
|
||||||
|
this.fixupListItemsAfterIndent();
|
||||||
|
|
||||||
// Get all blockquotes, both existing and new.
|
// Get all blockquotes, both existing and new.
|
||||||
blockquotes = this.editor.all('blockquote');
|
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.replace(clone);
|
||||||
indent = editor.one('.editor-indent');
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},outdent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),o=t.size();t.addClass("pre-existing"),this.replaceEditorIndents(this.editor),window.rangy.restoreSelection(e),e=window.rangy.saveSelection(),document.execCommand("outdent",!1,null),(t=this.editor.all("blockquote")).size()!==o?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},replaceBlockquote:function(e){var t,o,i,n,d;for(e.all("blockquote").setAttribute("data-iterate",!0),t=e.one("blockquote"),o=r.one("body.dir-ltr")?"marginLeft":"marginRight";t;){if(t.removeAttribute("data-iterate"),t.hasClass("pre-existing"))t.removeClass("pre-existing");else{for(i=r.Node.create("<div></div>").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("<blockquote></blockquote>").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"]});
|
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<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},outdent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),i=t.size();t.addClass("pre-existing"),this.replaceEditorIndents(this.editor),window.rangy.restoreSelection(e),e=window.rangy.saveSelection(),document.execCommand("outdent",!1,null),(t=this.editor.all("blockquote")).size()!==i?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},replaceBlockquote:function(e){var t,i,o,n,d;for(e.all("blockquote").setAttribute("data-iterate",!0),t=e.one("blockquote"),i=r.one("body.dir-ltr")?"marginLeft":"marginRight";t;){if(t.removeAttribute("data-iterate"),t.hasClass("pre-existing"))t.removeClass("pre-existing");else{for(o=r.Node.create("<div></div>").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("<blockquote></blockquote>").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"]});
|
|
@ -71,6 +71,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed
|
||||||
// Run the indent command.
|
// Run the indent command.
|
||||||
document.execCommand('indent', false, null);
|
document.execCommand('indent', false, null);
|
||||||
|
|
||||||
|
// Fix indent list item.
|
||||||
|
this.fixupListItemsAfterIndent();
|
||||||
|
|
||||||
// Get all blockquotes, both existing and new.
|
// Get all blockquotes, both existing and new.
|
||||||
blockquotes = this.editor.all('blockquote');
|
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.replace(clone);
|
||||||
indent = editor.one('.editor-indent');
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,9 @@ Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.Ed
|
||||||
// Run the indent command.
|
// Run the indent command.
|
||||||
document.execCommand('indent', false, null);
|
document.execCommand('indent', false, null);
|
||||||
|
|
||||||
|
// Fix indent list item.
|
||||||
|
this.fixupListItemsAfterIndent();
|
||||||
|
|
||||||
// Get all blockquotes, both existing and new.
|
// Get all blockquotes, both existing and new.
|
||||||
blockquotes = this.editor.all('blockquote');
|
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.replace(clone);
|
||||||
indent = editor.one('.editor-indent');
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue