From 613c130665fcb0ba0fad117ea36e0959369918eb Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Wed, 4 Mar 2020 23:01:37 +1100 Subject: [PATCH] MDL-45227 atto_align: Make IE follow css styling --- .../moodle-atto_align-button-debug.js | 9 +++++++++ .../moodle-atto_align-button-min.js | 2 +- .../moodle-atto_align-button/moodle-atto_align-button.js | 9 +++++++++ .../atto/plugins/align/yui/src/button/js/button.js | 9 +++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-debug.js b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-debug.js index 60f5e4ffbef..38645d7d2e3 100644 --- a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-debug.js +++ b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-debug.js @@ -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(); diff --git a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-min.js b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-min.js index 204f472c85e..15107ef58d5 100644 --- a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-min.js +++ b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button-min.js @@ -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"]}); diff --git a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button.js b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button.js index 60f5e4ffbef..38645d7d2e3 100644 --- a/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button.js +++ b/lib/editor/atto/plugins/align/yui/build/moodle-atto_align-button/moodle-atto_align-button.js @@ -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(); diff --git a/lib/editor/atto/plugins/align/yui/src/button/js/button.js b/lib/editor/atto/plugins/align/yui/src/button/js/button.js index a1d62df13de..019699a598a 100644 --- a/lib/editor/atto/plugins/align/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/align/yui/src/button/js/button.js @@ -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();