This commit is contained in:
Andrew Nicols 2021-05-27 11:18:14 +08:00
commit 1aa1276a84
5 changed files with 21 additions and 30 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}