Skip to content

Commit

Permalink
focus before moving cursor after pasting; closes #99
Browse files Browse the repository at this point in the history
  • Loading branch information
delambo committed Feb 3, 2014
1 parent d5c1760 commit 337f993
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/plugins/IceCopyPastePlugin/IceCopyPastePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,18 +409,19 @@ IceCopyPastePlugin.prototype = {

_cleanup: function(moveTo) {
try {
// Set focus back to ice element.
if (this._ice.env.frame)
this._ice.env.frame.contentWindow.focus();
else
this._ice.element.focus();

moveTo = moveTo && moveTo.lastChild || moveTo || this._tmpNode;
// Move the range to the end of moveTo so that the cursor will be at the end of the paste.
var range = this._ice.getCurrentRange();
range.setStartAfter(moveTo);
range.collapse(true);
this._ice.selection.addRange(range);
// Set focus back to ice element.
if(this._ice.env.frame) {
this._ice.env.frame.contentWindow.focus();
} else {
this._ice.element.focus();
}

// Kill the tmp node.
this._tmpNode.parentNode.removeChild(this._tmpNode);
this._tmpNode = null;
Expand Down

0 comments on commit 337f993

Please sign in to comment.