MDL-44221 editor_atto: fixed bug creating table in IE <= 10

This involved introducing a insert_html_at_focus_point method for
the editor and using that instead of insertHTML
This commit is contained in:
Sam Hemelryk
2014-03-26 10:01:44 +08:00
committed by Damyon Wiese
parent 9d535d04c2
commit 2faf4c4584
8 changed files with 59 additions and 5 deletions
@@ -594,7 +594,7 @@ M.atto_table = M.atto_table || {
tablehtml += '</tbody>' + nl;
tablehtml += '</table>' + nl + '<br/>';
document.execCommand('insertHTML', false, tablehtml);
M.editor_atto.insert_html_at_focus_point(tablehtml);
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(elementid);
File diff suppressed because one or more lines are too long
@@ -594,7 +594,7 @@ M.atto_table = M.atto_table || {
tablehtml += '</tbody>' + nl;
tablehtml += '</table>' + nl + '<br/>';
document.execCommand('insertHTML', false, tablehtml);
M.editor_atto.insert_html_at_focus_point(tablehtml);
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(elementid);
+1 -1
View File
@@ -592,7 +592,7 @@ M.atto_table = M.atto_table || {
tablehtml += '</tbody>' + nl;
tablehtml += '</table>' + nl + '<br/>';
document.execCommand('insertHTML', false, tablehtml);
M.editor_atto.insert_html_at_focus_point(tablehtml);
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(elementid);
@@ -1313,6 +1313,24 @@ M.editor_atto = M.editor_atto || {
}
}
}
},
/**
* Inserts the given HTML into the editable content at the currently focused point.
* @param {String} html
*/
insert_html_at_focus_point: function(html) {
// We check document.selection here as the insertHTML exec command wan't available in IE until version 11.
// In IE document.selection was removed at from version 11. Making it an easy affordable check.
if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
if (range.pasteHTML) {
range.pasteHTML(html);
}
} else {
// All other browsers are great!
document.execCommand('insertHTML', false, html);
}
}
};
File diff suppressed because one or more lines are too long
@@ -1313,6 +1313,24 @@ M.editor_atto = M.editor_atto || {
}
}
}
},
/**
* Inserts the given HTML into the editable content at the currently focused point.
* @param {String} html
*/
insert_html_at_focus_point: function(html) {
// We check document.selection here as the insertHTML exec command wan't available in IE until version 11.
// In IE document.selection was removed at from version 11. Making it an easy affordable check.
if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
if (range.pasteHTML) {
range.pasteHTML(html);
}
} else {
// All other browsers are great!
document.execCommand('insertHTML', false, html);
}
}
};
+18
View File
@@ -1311,6 +1311,24 @@ M.editor_atto = M.editor_atto || {
}
}
}
},
/**
* Inserts the given HTML into the editable content at the currently focused point.
* @param {String} html
*/
insert_html_at_focus_point: function(html) {
// We check document.selection here as the insertHTML exec command wan't available in IE until version 11.
// In IE document.selection was removed at from version 11. Making it an easy affordable check.
if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
if (range.pasteHTML) {
range.pasteHTML(html);
}
} else {
// All other browsers are great!
document.execCommand('insertHTML', false, html);
}
}
};