Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

I want to add focus and blur handlers to all CKEditor instances in our web application. I would like to add the handlers in one place, instead of hunting down every part where we instantiate a CKEditor. Can this be done, like maybe in the config.js editorConfig setup?

I can’t do something like “on document ready, add handlers to all CKEditor instances on the page” either, since additional editor instances may be created dynamically.

Comments

It’s embarrassing when you post a question to stackoverflow then figure out the answer a few minutes later =/

Answer for posterity: We can use CKEDITOR.on(“instanceReady”, …) to fire whenever a new editor is created and add our custom handlers there, example:

CKEDITOR.on("instanceReady", function(ev) {
  var editor = ev.editor;
  editor.on("focus", function(ev) {
    alert("focused!");
  });
});