MDL-45468 editor_atto: Check that the common ancestor is within the editor

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:36:16 +08:00 committed by Marina Glancy
parent 18b12e7b60
commit 17f253faeb
4 changed files with 14 additions and 4 deletions

View File

@ -1175,7 +1175,10 @@ EditorSelection.prototype = {
if (range.collapsed) {
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
// It's also possible for the commonAncestorContainer to be the document, which selectNode does not handle
// so we must filter that out here too.
if (range.commonAncestorContainer !== this.editor.getDOMNode()
&& range.commonAncestorContainer !== Y.config.doc) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}

File diff suppressed because one or more lines are too long

View File

@ -1170,7 +1170,10 @@ EditorSelection.prototype = {
if (range.collapsed) {
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
// It's also possible for the commonAncestorContainer to be the document, which selectNode does not handle
// so we must filter that out here too.
if (range.commonAncestorContainer !== this.editor.getDOMNode()
&& range.commonAncestorContainer !== Y.config.doc) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}

View File

@ -272,7 +272,10 @@ EditorSelection.prototype = {
if (range.collapsed) {
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
// It's also possible for the commonAncestorContainer to be the document, which selectNode does not handle
// so we must filter that out here too.
if (range.commonAncestorContainer !== this.editor.getDOMNode()
&& range.commonAncestorContainer !== Y.config.doc) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}