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.
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!");
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With