MDL-45227 editor_atto: Add direction to default ATTO generated markup
This commit is contained in:
committed by
Shamim Rezaie
parent
d939d6e769
commit
b10155308f
+32
-5
@@ -150,6 +150,14 @@ Y.extend(Editor, Y.Base, {
|
||||
*/
|
||||
plugins: null,
|
||||
|
||||
/**
|
||||
* An indicator of the current input direction.
|
||||
*
|
||||
* @property coreDirection
|
||||
* @type string
|
||||
*/
|
||||
coreDirection: null,
|
||||
|
||||
/**
|
||||
* Event Handles to clear on editor destruction.
|
||||
*
|
||||
@@ -196,6 +204,9 @@ Y.extend(Editor, Y.Base, {
|
||||
this.editor.setAttribute('aria-labelledby', this.textareaLabel.get("id"));
|
||||
}
|
||||
|
||||
// Set diretcion according to current page language.
|
||||
this.coreDirection = Y.one('body').hasClass('dir-rtl') ? 'rtl' : 'ltr';
|
||||
|
||||
// Add everything to the wrapper.
|
||||
this.setupToolbar();
|
||||
|
||||
@@ -681,10 +692,16 @@ EditorTextArea.prototype = {
|
||||
* @private
|
||||
*/
|
||||
_getEmptyContent: function() {
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p></p>';
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
return '<p><br></p>';
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '></p>';
|
||||
} else {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '><br></p>';
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1324,7 +1341,11 @@ EditorClean.prototype = {
|
||||
html = editorClone.get('innerHTML');
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (html === '<p></p>' || html === '<p><br></p>') {
|
||||
if ((html === '<p></p>' || html === '<p><br></p>') ||
|
||||
(html === '<p dir="rtl" style="text-align: right;"></p>' ||
|
||||
html === '<p dir="rtl" style="text-align: right;"><br></p>') ||
|
||||
(html === '<p dir="ltr" style="text-align: left;"></p>' ||
|
||||
html === '<p dir="ltr" style="text-align: left;"><br></p>')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -2729,8 +2750,14 @@ EditorStyling.prototype = {
|
||||
|
||||
// No valid block element - make one.
|
||||
if (!nearestblock) {
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
// There is no block node in the content, wrap the content in a p and use that.
|
||||
newcontent = Y.Node.create('<p></p>');
|
||||
newcontent = Y.Node.create('<p dir="' + this.coreDirection + '" ' + alignment + '></p>');
|
||||
boundary.get('childNodes').each(function(child) {
|
||||
newcontent.append(child.remove());
|
||||
});
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
+32
-5
@@ -150,6 +150,14 @@ Y.extend(Editor, Y.Base, {
|
||||
*/
|
||||
plugins: null,
|
||||
|
||||
/**
|
||||
* An indicator of the current input direction.
|
||||
*
|
||||
* @property coreDirection
|
||||
* @type string
|
||||
*/
|
||||
coreDirection: null,
|
||||
|
||||
/**
|
||||
* Event Handles to clear on editor destruction.
|
||||
*
|
||||
@@ -194,6 +202,9 @@ Y.extend(Editor, Y.Base, {
|
||||
this.editor.setAttribute('aria-labelledby', this.textareaLabel.get("id"));
|
||||
}
|
||||
|
||||
// Set diretcion according to current page language.
|
||||
this.coreDirection = Y.one('body').hasClass('dir-rtl') ? 'rtl' : 'ltr';
|
||||
|
||||
// Add everything to the wrapper.
|
||||
this.setupToolbar();
|
||||
|
||||
@@ -676,10 +687,16 @@ EditorTextArea.prototype = {
|
||||
* @private
|
||||
*/
|
||||
_getEmptyContent: function() {
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p></p>';
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
return '<p><br></p>';
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '></p>';
|
||||
} else {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '><br></p>';
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1313,7 +1330,11 @@ EditorClean.prototype = {
|
||||
html = editorClone.get('innerHTML');
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (html === '<p></p>' || html === '<p><br></p>') {
|
||||
if ((html === '<p></p>' || html === '<p><br></p>') ||
|
||||
(html === '<p dir="rtl" style="text-align: right;"></p>' ||
|
||||
html === '<p dir="rtl" style="text-align: right;"><br></p>') ||
|
||||
(html === '<p dir="ltr" style="text-align: left;"></p>' ||
|
||||
html === '<p dir="ltr" style="text-align: left;"><br></p>')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -2715,8 +2736,14 @@ EditorStyling.prototype = {
|
||||
|
||||
// No valid block element - make one.
|
||||
if (!nearestblock) {
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
// There is no block node in the content, wrap the content in a p and use that.
|
||||
newcontent = Y.Node.create('<p></p>');
|
||||
newcontent = Y.Node.create('<p dir="' + this.coreDirection + '" ' + alignment + '></p>');
|
||||
boundary.get('childNodes').each(function(child) {
|
||||
newcontent.append(child.remove());
|
||||
});
|
||||
|
||||
+5
-1
@@ -55,7 +55,11 @@ EditorClean.prototype = {
|
||||
html = editorClone.get('innerHTML');
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (html === '<p></p>' || html === '<p><br></p>') {
|
||||
if ((html === '<p></p>' || html === '<p><br></p>') ||
|
||||
(html === '<p dir="rtl" style="text-align: right;"></p>' ||
|
||||
html === '<p dir="rtl" style="text-align: right;"><br></p>') ||
|
||||
(html === '<p dir="ltr" style="text-align: left;"></p>' ||
|
||||
html === '<p dir="ltr" style="text-align: left;"><br></p>')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -148,6 +148,14 @@ Y.extend(Editor, Y.Base, {
|
||||
*/
|
||||
plugins: null,
|
||||
|
||||
/**
|
||||
* An indicator of the current input direction.
|
||||
*
|
||||
* @property coreDirection
|
||||
* @type string
|
||||
*/
|
||||
coreDirection: null,
|
||||
|
||||
/**
|
||||
* Event Handles to clear on editor destruction.
|
||||
*
|
||||
@@ -194,6 +202,9 @@ Y.extend(Editor, Y.Base, {
|
||||
this.editor.setAttribute('aria-labelledby', this.textareaLabel.get("id"));
|
||||
}
|
||||
|
||||
// Set diretcion according to current page language.
|
||||
this.coreDirection = Y.one('body').hasClass('dir-rtl') ? 'rtl' : 'ltr';
|
||||
|
||||
// Add everything to the wrapper.
|
||||
this.setupToolbar();
|
||||
|
||||
|
||||
+7
-1
@@ -175,8 +175,14 @@ EditorStyling.prototype = {
|
||||
|
||||
// No valid block element - make one.
|
||||
if (!nearestblock) {
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
// There is no block node in the content, wrap the content in a p and use that.
|
||||
newcontent = Y.Node.create('<p></p>');
|
||||
newcontent = Y.Node.create('<p dir="' + this.coreDirection + '" ' + alignment + '></p>');
|
||||
boundary.get('childNodes').each(function(child) {
|
||||
newcontent.append(child.remove());
|
||||
});
|
||||
|
||||
+9
-3
@@ -45,10 +45,16 @@ EditorTextArea.prototype = {
|
||||
* @private
|
||||
*/
|
||||
_getEmptyContent: function() {
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p></p>';
|
||||
var alignment;
|
||||
if (this.coreDirection === 'rtl') {
|
||||
alignment = 'style="text-align: right;"';
|
||||
} else {
|
||||
return '<p><br></p>';
|
||||
alignment = 'style="text-align: left;"';
|
||||
}
|
||||
if (Y.UA.ie && Y.UA.ie < 10) {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '></p>';
|
||||
} else {
|
||||
return '<p dir="' + this.coreDirection + '" ' + alignment + '><br></p>';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user