0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Fix issue with focusing image within editor

This commit is contained in:
Robert O'Leary 2017-02-01 18:29:15 +01:00
parent a69c81fbd7
commit aa41badbe0
No known key found for this signature in database
GPG key ID: DD07530AA9B1D961
3 changed files with 26 additions and 6 deletions

View file

@ -2934,8 +2934,18 @@ proto.getSelection = function () {
return selection;
};
function enableRestoreSelection () {
this._restoreSelection = true;
function enableRestoreSelection (ev) {
// Blur can be called when you are focusing on other elements within the
// editor. We should only want to restore the selection if we are coming
// from outside of the editor. We need to do this on a timeout because we
// cannot determine what the new focused element is until after the blur.
var self = this;
setTimeout(function() {
var target = document.activeElement;
if( !isOrContains( self._root, document.activeElement ) ) {
this._restoreSelection = true;
}
}, 1);
}
function disableRestoreSelection () {
this._restoreSelection = false;

File diff suppressed because one or more lines are too long

View file

@ -488,8 +488,18 @@ proto.getSelection = function () {
return selection;
};
function enableRestoreSelection () {
this._restoreSelection = true;
function enableRestoreSelection (ev) {
// Blur can be called when you are focusing on other elements within the
// editor. We should only want to restore the selection if we are coming
// from outside of the editor. We need to do this on a timeout because we
// cannot determine what the new focused element is until after the blur.
var self = this;
setTimeout(function() {
var target = document.activeElement;
if( !isOrContains( self._root, document.activeElement ) ) {
this._restoreSelection = true;
}
}, 1);
}
function disableRestoreSelection () {
this._restoreSelection = false;