mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-71047 HTML Editor (Atto): Cursor position is not correct when paste
This commit is contained in:
parent
0b69b37f04
commit
e1c7a18677
@ -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;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -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
lib/editor/atto/yui/src/editor/js/clean.js
vendored
8
lib/editor/atto/yui/src/editor/js/clean.js
vendored
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user