Fixes #768, fixes #4602
This refactoring 1. simplifies updating the CKEditor source code; 2. allows many instances of the CKEditor on the same page; 3. fixes the cursor positioning on focus.