Merge branch 'MDL-45533-27' of git://github.com/FMCorz/moodle

This commit is contained in:
Damyon Wiese 2014-05-19 12:25:56 +08:00
commit b3eea60ecb
5 changed files with 44 additions and 8 deletions

View file

@ -201,6 +201,11 @@ Y.extend(Editor, Y.Base, {
// Disable odd inline CSS styles.
this.disableCssStyling();
// Use paragraphs not divs.
if (document.queryCommandSupported('DefaultParagraphSeparator')) {
document.execCommand('DefaultParagraphSeparator', false, 'p');
}
// Add the toolbar and editable zone to the page.
this.textarea.get('parentNode').insert(this._wrapper, this.textarea);
@ -521,7 +526,8 @@ EditorClean.prototype = {
*/
getCleanHTML: function() {
// Clone the editor so that we don't actually modify the real content.
var editorClone = this.editor.cloneNode(true);
var editorClone = this.editor.cloneNode(true),
html;
// Remove all YUI IDs.
Y.each(editorClone.all('[id^="yui"]'), function(node) {
@ -529,9 +535,15 @@ EditorClean.prototype = {
});
editorClone.all('.atto_control').remove(true);
html = editorClone.get('innerHTML');
// Revert untouched editor contents to an empty string.
if (html === '<p></p>' || html === '<p><br></p>') {
return '';
}
// Remove any and all nasties from source.
return this._cleanHTML(editorClone.get('innerHTML'));
return this._cleanHTML(html);
},
/**

File diff suppressed because one or more lines are too long

View file

@ -199,6 +199,11 @@ Y.extend(Editor, Y.Base, {
// Disable odd inline CSS styles.
this.disableCssStyling();
// Use paragraphs not divs.
if (document.queryCommandSupported('DefaultParagraphSeparator')) {
document.execCommand('DefaultParagraphSeparator', false, 'p');
}
// Add the toolbar and editable zone to the page.
this.textarea.get('parentNode').insert(this._wrapper, this.textarea);
@ -518,7 +523,8 @@ EditorClean.prototype = {
*/
getCleanHTML: function() {
// Clone the editor so that we don't actually modify the real content.
var editorClone = this.editor.cloneNode(true);
var editorClone = this.editor.cloneNode(true),
html;
// Remove all YUI IDs.
Y.each(editorClone.all('[id^="yui"]'), function(node) {
@ -526,9 +532,15 @@ EditorClean.prototype = {
});
editorClone.all('.atto_control').remove(true);
html = editorClone.get('innerHTML');
// Revert untouched editor contents to an empty string.
if (html === '<p></p>' || html === '<p><br></p>') {
return '';
}
// Remove any and all nasties from source.
return this._cleanHTML(editorClone.get('innerHTML'));
return this._cleanHTML(html);
},
/**

View file

@ -42,7 +42,8 @@ EditorClean.prototype = {
*/
getCleanHTML: function() {
// Clone the editor so that we don't actually modify the real content.
var editorClone = this.editor.cloneNode(true);
var editorClone = this.editor.cloneNode(true),
html;
// Remove all YUI IDs.
Y.each(editorClone.all('[id^="yui"]'), function(node) {
@ -50,9 +51,15 @@ EditorClean.prototype = {
});
editorClone.all('.atto_control').remove(true);
html = editorClone.get('innerHTML');
// Revert untouched editor contents to an empty string.
if (html === '<p></p>' || html === '<p><br></p>') {
return '';
}
// Remove any and all nasties from source.
return this._cleanHTML(editorClone.get('innerHTML'));
return this._cleanHTML(html);
},
/**

View file

@ -199,6 +199,11 @@ Y.extend(Editor, Y.Base, {
// Disable odd inline CSS styles.
this.disableCssStyling();
// Use paragraphs not divs.
if (document.queryCommandSupported('DefaultParagraphSeparator')) {
document.execCommand('DefaultParagraphSeparator', false, 'p');
}
// Add the toolbar and editable zone to the page.
this.textarea.get('parentNode').insert(this._wrapper, this.textarea);