MDL-43870 atto_indent: Removing browser styling after execCommand
This commit is contained in:
committed by
Damyon Wiese
parent
b03d59821a
commit
5a06d5d71d
+19
-1
@@ -18,18 +18,36 @@ YUI.add('moodle-atto_indent-button', function (Y, NAME) {
|
||||
/**
|
||||
* Atto text editor indent plugin.
|
||||
*
|
||||
* @package editor-atto
|
||||
* @package atto_indent
|
||||
* @copyright 2013 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
M.atto_indent = M.atto_indent || {
|
||||
init : function(params) {
|
||||
var click = function(e, elementid) {
|
||||
var editable;
|
||||
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
M.editor_atto.focus(elementid);
|
||||
}
|
||||
|
||||
// This is adding a <blockquote> which is not ideal but that is the easiest to put in place
|
||||
// for now. When disabling the styleWithCSS, some browser will use <blockquote> so we cannot
|
||||
// rely on it for <div>s, and that would not work when indenting lists either....
|
||||
// Handling it ourselves is even worse as it would require to get a parent and wrap
|
||||
// a div with a margin around it. Considering that multiple <p> should end up in the
|
||||
// same <div>, that table cells should not be wrapped, and that lists work differently too.
|
||||
document.execCommand('indent', false, null);
|
||||
|
||||
// Some browsers add style attributes to the blockquote, let's get rid of them.
|
||||
// It is really tricky to figure out what blockquote was just added, so removing
|
||||
// the styles on all of them seems OK.
|
||||
// Eg. Chrome changes the selection after adding the blockquote, so we cannot target it.
|
||||
// IE adds a dir attribute to the blockquote too, but it's probably OK to leave it...
|
||||
editable = M.editor_atto.get_editable_node(elementid);
|
||||
editable.all('blockquote').removeAttribute('style');
|
||||
|
||||
// Clean the YUI ids from the HTML.
|
||||
M.editor_atto.text_updated(elementid);
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
YUI.add("moodle-atto_indent-button",function(e,t){M.atto_indent=M.atto_indent||{init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("indent",!1,null),M.editor_atto.text_updated(t)},n=M.util.image_url("e/increase_indent","core");M.editor_atto.add_toolbar_button(e.elementid,"indent",n,e.group,t)}}},"@VERSION@",{requires:["node"]});
|
||||
YUI.add("moodle-atto_indent-button",function(e,t){M.atto_indent=M.atto_indent||{init:function(e){var t=function(e,t){var n;e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),document.execCommand("indent",!1,null),n=M.editor_atto.get_editable_node(t),n.all("blockquote").removeAttribute("style"),M.editor_atto.text_updated(t)},n=M.util.image_url("e/increase_indent","core");M.editor_atto.add_toolbar_button(e.elementid,"indent",n,e.group,t)}}},"@VERSION@",{requires:["node"]});
|
||||
|
||||
Vendored
+19
-1
@@ -18,18 +18,36 @@ YUI.add('moodle-atto_indent-button', function (Y, NAME) {
|
||||
/**
|
||||
* Atto text editor indent plugin.
|
||||
*
|
||||
* @package editor-atto
|
||||
* @package atto_indent
|
||||
* @copyright 2013 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
M.atto_indent = M.atto_indent || {
|
||||
init : function(params) {
|
||||
var click = function(e, elementid) {
|
||||
var editable;
|
||||
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
M.editor_atto.focus(elementid);
|
||||
}
|
||||
|
||||
// This is adding a <blockquote> which is not ideal but that is the easiest to put in place
|
||||
// for now. When disabling the styleWithCSS, some browser will use <blockquote> so we cannot
|
||||
// rely on it for <div>s, and that would not work when indenting lists either....
|
||||
// Handling it ourselves is even worse as it would require to get a parent and wrap
|
||||
// a div with a margin around it. Considering that multiple <p> should end up in the
|
||||
// same <div>, that table cells should not be wrapped, and that lists work differently too.
|
||||
document.execCommand('indent', false, null);
|
||||
|
||||
// Some browsers add style attributes to the blockquote, let's get rid of them.
|
||||
// It is really tricky to figure out what blockquote was just added, so removing
|
||||
// the styles on all of them seems OK.
|
||||
// Eg. Chrome changes the selection after adding the blockquote, so we cannot target it.
|
||||
// IE adds a dir attribute to the blockquote too, but it's probably OK to leave it...
|
||||
editable = M.editor_atto.get_editable_node(elementid);
|
||||
editable.all('blockquote').removeAttribute('style');
|
||||
|
||||
// Clean the YUI ids from the HTML.
|
||||
M.editor_atto.text_updated(elementid);
|
||||
};
|
||||
|
||||
+19
-1
@@ -16,18 +16,36 @@
|
||||
/**
|
||||
* Atto text editor indent plugin.
|
||||
*
|
||||
* @package editor-atto
|
||||
* @package atto_indent
|
||||
* @copyright 2013 Damyon Wiese <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
M.atto_indent = M.atto_indent || {
|
||||
init : function(params) {
|
||||
var click = function(e, elementid) {
|
||||
var editable;
|
||||
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
M.editor_atto.focus(elementid);
|
||||
}
|
||||
|
||||
// This is adding a <blockquote> which is not ideal but that is the easiest to put in place
|
||||
// for now. When disabling the styleWithCSS, some browser will use <blockquote> so we cannot
|
||||
// rely on it for <div>s, and that would not work when indenting lists either....
|
||||
// Handling it ourselves is even worse as it would require to get a parent and wrap
|
||||
// a div with a margin around it. Considering that multiple <p> should end up in the
|
||||
// same <div>, that table cells should not be wrapped, and that lists work differently too.
|
||||
document.execCommand('indent', false, null);
|
||||
|
||||
// Some browsers add style attributes to the blockquote, let's get rid of them.
|
||||
// It is really tricky to figure out what blockquote was just added, so removing
|
||||
// the styles on all of them seems OK.
|
||||
// Eg. Chrome changes the selection after adding the blockquote, so we cannot target it.
|
||||
// IE adds a dir attribute to the blockquote too, but it's probably OK to leave it...
|
||||
editable = M.editor_atto.get_editable_node(elementid);
|
||||
editable.all('blockquote').removeAttribute('style');
|
||||
|
||||
// Clean the YUI ids from the HTML.
|
||||
M.editor_atto.text_updated(elementid);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user