Skip to content

Commit

Permalink
Merge branch 't/9507'
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Feb 19, 2013
2 parents db1bfe8 + aaeb6ab commit d904beb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -17,6 +17,7 @@ CKEditor 4 Changelog
* [#9883](http://dev.ckeditor.com/ticket/9883): Maximizing was making the entire page editable with divarea based editors.
* [#9940](http://dev.ckeditor.com/ticket/9940): With Firefox, navigating back to a page with the editor was making the entire page editable.
* [#9966](http://dev.ckeditor.com/ticket/9966): Fixed: Unable to type square brackets with French keyboard layout. Changed magicline keystrokes.
* [#9507](http://dev.ckeditor.com/ticket/9507): [Firefox] Selection is moved before editable position when editor focused for the first time.

## CKEditor 4.0.1

Expand Down
39 changes: 26 additions & 13 deletions core/selection.js
Expand Up @@ -196,18 +196,36 @@

var isInline = editable.isInline();

var restoreSel;

// Give the editable an initial selection on first focus,
// put selection at a consistent position at the start
// of the contents. (#5156)
editable.attachListener( editable, 'focus', function( evt ) {
evt.removeListener();

if ( restoreSel !== 0 ) {
var rng = editor.createRange();
rng.moveToElementEditStart( editable );
rng.select();
}
}, null, null, -2 );

// Plays the magic here to restore/save dom selection on editable focus/blur.
editable.attachListener( editable, 'focus', function() {
editor.unlockSelection( restoreSel );
restoreSel = 0;
}, null, null, -1 );

// Disable selection restoring when clicking in.
editable.attachListener( editable, 'mousedown', function() {
restoreSel = 0;
});

// Browsers could loose the selection once the editable lost focus,
// in such case we need to reproduce it by saving a locked selection
// and restoring it upon focus gain.
if ( CKEDITOR.env.ie || CKEDITOR.env.opera || isInline ) {
var restoreSel;

// Plays the magic here to restore/save dom selection on editable focus/blur.
editable.attachListener( editable, 'focus', function() {
editor.unlockSelection( restoreSel );
restoreSel = 0;
}, null, null, -1 );

var lastSel;
// Save a fresh copy of the selection.
function saveSel() {
Expand All @@ -226,11 +244,6 @@
editor.lockSelection( lastSel );
restoreSel = 1;
}, null, null, -1 );

// Disable selection restoring when clicking in.
editable.attachListener( editable, 'mousedown', function() {
restoreSel = 0;
});
}

// The following selection related fixes applies to only framed editable.
Expand Down
2 changes: 1 addition & 1 deletion plugins/dialog/plugin.js
Expand Up @@ -2813,7 +2813,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
// undo support should dedicate to specific dialog implementation.
canUndo: false,

editorFocus: CKEDITOR.env.ie || CKEDITOR.env.webkit
editorFocus: 1
};

(function() {
Expand Down

0 comments on commit d904beb

Please sign in to comment.