MDL-71047 HTML Editor (Atto): Cursor position is not correct when paste
This commit is contained in:
+6
-9
@@ -1485,17 +1485,9 @@ EditorClean.prototype = {
|
||||
// Scrub the paste content.
|
||||
content = this._cleanPasteHTML(content);
|
||||
|
||||
// Save the current selection.
|
||||
// Using saveSelection as it produces a more consistent experience.
|
||||
var selection = window.rangy.saveSelection();
|
||||
|
||||
// Insert the content.
|
||||
this.insertContentAtFocusPoint(content);
|
||||
|
||||
// Restore the selection, and collapse to end.
|
||||
window.rangy.restoreSelection(selection);
|
||||
window.rangy.getSelection().collapseToEnd();
|
||||
|
||||
// Update the text area.
|
||||
this.updateOriginal();
|
||||
return false;
|
||||
@@ -2826,7 +2818,12 @@ EditorSelection.prototype = {
|
||||
}
|
||||
if (range) {
|
||||
range.deleteContents();
|
||||
range.insertNode(node.getDOMNode());
|
||||
range.collapse(false);
|
||||
var currentnode = node.getDOMNode(),
|
||||
last = currentnode.lastChild || currentnode;
|
||||
range.insertNode(currentnode);
|
||||
range.collapseAfter(last);
|
||||
selection.setSingleRange(range);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+6
-9
@@ -1474,17 +1474,9 @@ EditorClean.prototype = {
|
||||
// Scrub the paste content.
|
||||
content = this._cleanPasteHTML(content);
|
||||
|
||||
// Save the current selection.
|
||||
// Using saveSelection as it produces a more consistent experience.
|
||||
var selection = window.rangy.saveSelection();
|
||||
|
||||
// Insert the content.
|
||||
this.insertContentAtFocusPoint(content);
|
||||
|
||||
// Restore the selection, and collapse to end.
|
||||
window.rangy.restoreSelection(selection);
|
||||
window.rangy.getSelection().collapseToEnd();
|
||||
|
||||
// Update the text area.
|
||||
this.updateOriginal();
|
||||
return false;
|
||||
@@ -2801,7 +2793,12 @@ EditorSelection.prototype = {
|
||||
}
|
||||
if (range) {
|
||||
range.deleteContents();
|
||||
range.insertNode(node.getDOMNode());
|
||||
range.collapse(false);
|
||||
var currentnode = node.getDOMNode(),
|
||||
last = currentnode.lastChild || currentnode;
|
||||
range.insertNode(currentnode);
|
||||
range.collapseAfter(last);
|
||||
selection.setSingleRange(range);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
-8
@@ -190,17 +190,9 @@ EditorClean.prototype = {
|
||||
// Scrub the paste content.
|
||||
content = this._cleanPasteHTML(content);
|
||||
|
||||
// Save the current selection.
|
||||
// Using saveSelection as it produces a more consistent experience.
|
||||
var selection = window.rangy.saveSelection();
|
||||
|
||||
// Insert the content.
|
||||
this.insertContentAtFocusPoint(content);
|
||||
|
||||
// Restore the selection, and collapse to end.
|
||||
window.rangy.restoreSelection(selection);
|
||||
window.rangy.getSelection().collapseToEnd();
|
||||
|
||||
// Update the text area.
|
||||
this.updateOriginal();
|
||||
return false;
|
||||
|
||||
+6
-1
@@ -409,7 +409,12 @@ EditorSelection.prototype = {
|
||||
}
|
||||
if (range) {
|
||||
range.deleteContents();
|
||||
range.insertNode(node.getDOMNode());
|
||||
range.collapse(false);
|
||||
var currentnode = node.getDOMNode(),
|
||||
last = currentnode.lastChild || currentnode;
|
||||
range.insertNode(currentnode);
|
||||
range.collapseAfter(last);
|
||||
selection.setSingleRange(range);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user