Skip to content

Instantly share code, notes, and snippets.

@garryyao
Created November 30, 2011 14:06
Show Gist options
  • Save garryyao/1409175 to your computer and use it in GitHub Desktop.
Save garryyao/1409175 to your computer and use it in GitHub Desktop.
Workaround for FF bug on selection lost when hiding the editor
// The below code is for FF only.
var editor = CKEDITOR.appendTo( 'editor1' );
setTimeout( function()
{
var focused = editor.focusManager.hasFocus;
if ( focused )
{
var sel = editor.getSelection();
sel.lock();
}
document.getElementById( 'editor1' ).style.display = 'none';
setTimeout( function()
{
document.getElementById( 'editor1' ).style.display = 'block';
if ( focused )
{
editor.focusGrabber.focus();
setTimeout( function() { editor.getSelection().unlock( true ); } );
}
}, 1000 );
}, 5000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment