MDL-45227 atto_align: Make IE follow css styling

This commit is contained in:
Shamim Rezaie 2020-03-04 23:01:37 +11:00
parent 31d62654a6
commit 613c130665
4 changed files with 28 additions and 1 deletions

View File

@ -83,6 +83,15 @@ Y.namespace('M.atto_align').Button = Y.Base.create('button', Y.M.editor_atto.Edi
document.execCommand(justification, false, null);
// To clean up IE's mess.
this.editor.all('*[align]').each(function(node) {
var align = node.get('align');
if (align) {
node.setStyle('text-align', align);
node.removeAttribute('align');
}
}, this);
// Re-disable the CSS styling after making the change.
host.disableCssStyling();

View File

@ -1 +1 @@
YUI.add("moodle-atto_align-button",function(e,t){e.namespace("M.atto_align").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){var e;e="justifyLeft",this.addButton({icon:"e/align_left",title:"leftalign",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyCenter",this.addButton({icon:"e/align_center",title:"center",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyRight",this.addButton({icon:"e/align_right",title:"rightalign",buttonName:e,callback:this._changeStyle,callbackArgs:e})},_changeStyle:function(e,t){var n=this.get("host");n.enableCssStyling(),document.execCommand(t,!1,null),n.disableCssStyling(),this.markUpdated(),this.editor.focus()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
YUI.add("moodle-atto_align-button",function(e,t){e.namespace("M.atto_align").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){var e;e="justifyLeft",this.addButton({icon:"e/align_left",title:"leftalign",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyCenter",this.addButton({icon:"e/align_center",title:"center",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyRight",this.addButton({icon:"e/align_right",title:"rightalign",buttonName:e,callback:this._changeStyle,callbackArgs:e})},_changeStyle:function(e,t){var n=this.get("host");n.enableCssStyling(),document.execCommand(t,!1,null),this.editor.all("*[align]").each(function(e){var t=e.get("align");t&&(e.setStyle("text-align",t),e.removeAttribute("align"))},this),n.disableCssStyling(),this.markUpdated(),this.editor.focus()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});

View File

@ -83,6 +83,15 @@ Y.namespace('M.atto_align').Button = Y.Base.create('button', Y.M.editor_atto.Edi
document.execCommand(justification, false, null);
// To clean up IE's mess.
this.editor.all('*[align]').each(function(node) {
var align = node.get('align');
if (align) {
node.setStyle('text-align', align);
node.removeAttribute('align');
}
}, this);
// Re-disable the CSS styling after making the change.
host.disableCssStyling();

View File

@ -81,6 +81,15 @@ Y.namespace('M.atto_align').Button = Y.Base.create('button', Y.M.editor_atto.Edi
document.execCommand(justification, false, null);
// To clean up IE's mess.
this.editor.all('*[align]').each(function(node) {
var align = node.get('align');
if (align) {
node.setStyle('text-align', align);
node.removeAttribute('align');
}
}, this);
// Re-disable the CSS styling after making the change.
host.disableCssStyling();