MDL-45253 editor_atto: Prevent selection of all nodes when selection is empty

This commit is contained in:
Frederic Massart 2014-05-01 17:38:39 +08:00
parent d78920bdba
commit e988383645
4 changed files with 19 additions and 7 deletions

View File

@ -1145,8 +1145,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// 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()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();

File diff suppressed because one or more lines are too long

View File

@ -1140,8 +1140,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// 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()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();

View File

@ -252,8 +252,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// 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()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();