MDL-45239 editor_atto: The editor cannot be active if it is not the active element

FireFox thinks that you can have an active selection on an element which
currently does not have focus. How this can be the case is a mystery.

Conflicts:
	lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
This commit is contained in:
Andrew Nicols 2014-05-08 14:31:46 +08:00 committed by Marina Glancy
parent 17f253faeb
commit 1ce043614f
4 changed files with 20 additions and 11 deletions

View File

@ -1023,6 +1023,11 @@ EditorSelection.prototype = {
return false;
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}
// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
@ -1051,9 +1056,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
},
/**

File diff suppressed because one or more lines are too long

View File

@ -1018,6 +1018,11 @@ EditorSelection.prototype = {
return false;
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}
// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
@ -1046,9 +1051,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
},
/**

View File

@ -120,6 +120,11 @@ EditorSelection.prototype = {
return false;
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}
// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
@ -148,9 +153,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
},
/**